Diffusion KWin 5e104fbc1245

[scripting] Introduce redirect function

Authored by zzag on Oct 24 2018, 7:58 PM.

Description

[scripting] Introduce redirect function

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

Details

Committed
zzagNov 17 2018, 11:44 AM
Reviewer
KWin
Differential Revision
D16449: [scripting] Introduce redirect function
Parents
R108:ee72569647c0: [libkwineffects] Port AnimationEffect to TimeLine
Branches
Unknown
Tags
Unknown