Skip to content
  • Vlad Zahorodnii's avatar
    [scripting] Introduce redirect function · 5e104fbc
    Vlad Zahorodnii authored
    Summary:
    Consider current implementation of the Squash effect: if a window was
    minimized, an animation will be started; if the window is unminimized
    and the animation is still active (that can happen when user clicks on
    app's icon really fast), the animation will be stopped and a new one will
    be created. Such behavior can lead to rapid jumps in the observed
    "animation".
    
    A better approach would be first try to **reverse** the already active
    animation, and if that attempt wasn't successful, start a new animation.
    
    This patch introduces a new function to the scripted effects API that
    lets JavaScript effects to control direction of animations. The
    prototype of the function looks as follows:
    
        redirect(<animation id(s)>, <direction>, [<termination policy>])
    
    the first argument is an animation id or a list of animation ids, the
    second argument specifies the new direction of the animation or
    animations if a list of ids was passed as the first argument. The
    third argument specifies whether the animation(s) should be terminated
    when it(they) reaches the source position, currently it's relevant only
    for animations that are created with set() function. The termination
    policy argument is optional, by default it's Effect.TerminateAtSource.
    
    We can use this function to fix issues with rapid jumps in the Squash
    effect. Also, redirect() lets us to write effects for simple animations
    in slightly different style: first, we have to start the main animation
    (e.g. for the Dialog Parent effect, it would be dimming of main windows)
    and then change direction of the animation depending on external events,
    e.g. when the Desktop Cube effect is activated.
    
    Reviewers: #kwin, davidedmundson
    
    Reviewed By: #kwin, davidedmundson
    
    Subscribers: davidedmundson, abetts, kwin
    
    Tags: #kwin
    
    Differential Revision: https://phabricator.kde.org/D16449
    5e104fbc