KWin/Animations

From KDE Community Wiki
Revision as of 21:21, 6 October 2012 by Markg85 (talk | contribs) (→‎resize)

There are many different animations in the KWin effects. The animations differ in animation duration and the kind of animation. The idea is to have this in a more consistent way by e.g. all fade animations having the same duration and animation behavior.

To be able to do so, it is first required to gather all the animation data.

How to Find the Animation

All animations are defined in the effects source code which are located in kwin/effects in the kde-workspace git repository. Most of the animations use one or many QTimeLine for controlling the animation. These are mostly defined in variables called timeline. To find the animations which are going on one can look into a method called prePaintScreen which gets the time since the last rendered frame. There is some code which adds the time to the QTimeLine. For example in the DimScreenEffect this looks like the following:

void DimScreenEffect::prePaintScreen(ScreenPrePaintData& data, int time)
{
    if (mActivated && activateAnimation && !effects->activeFullScreenEffect())
        timeline.setCurrentTime(timeline.currentTime() + time);
    if (mActivated && deactivateAnimation)
        timeline.setCurrentTime(timeline.currentTime() - time);
    if (mActivated && effects->activeFullScreenEffect())
        timeline.setCurrentTime(timeline.currentTime() - time);
    if (mActivated && !activateAnimation && !deactivateAnimation && !effects->activeFullScreenEffect() && timeline.currentValue() != 1.0)
        timeline.setCurrentTime(timeline.currentTime() + time);
    effects->prePaintScreen(data, time);
}

From this we see that only one animation in variable "timeline" is defined.

Finding the Animation Duration

The animation duration is somewhere in the effect defined. In most cases it is either a hardcoded value or comes from a configuration value, which also includes the default hardcoded. If you have your variable look for a code section like:

variableName.setDuration(animationTime(250));

Which would tell us that the duration is 250 msec. For a configurable duration it can look like:

rotationDuration = animationTime(CubeConfig::rotationDuration() != 0 ? CubeConfig::rotationDuration() : 500);
timeLine.setDuration(rotationDuration);

This would tell us that the default animation duration is 500 msec.

Finding the Curve Shape

Each QTimeLine has either a CurveShape or a QEasingCurve assigned which describes how the animation looks like over time. If the animation uses a CurveShape you can find a code fragment looking like:

variableName.setCurveShape(QTimeLine::EaseInOutCurve);

This would tell us, that it is using an EaseInOutCurve.

If it uses a QEasingCurve it should look like:

variableName.setEasingCurve(QEasingCurve::InOutQuad);

This would tell us it is using an InOutQuad.

If there is no call for setting either the CurveShape or the EasingCurve on the QTimeLine the default behavior is a EaseInOutCurve.

Effects

Please use the following table if an effect uses an animation:

Animation Duration Shape
What gets animated (e.g. fade windows, dim windows) Duration in msec CurveShape or EasingCurve

blur

none

boxswitch

Can be ignored, scheduled for removal

coverswitch

Animation Duration Shape
Switch Windows 200 EaseInOutCurve

cube

Animation Duration Shape
Horizontal Rotation 500 EaseInOutCurve
Vertical Rotation 500 EaseInOutCurve

cubeslide

Animation Duration Shape
Slide Rotation 500 EaseInOutCurve

dashboard

Animation Duration Shape
Show dashboard 500 EaseInOutCurve
Hide dashboard 500 EaseInOutCurve

desktopgrid

Animation Duration Shape
Zoom duration 300 EaseInOutCurve

dialogparent

Animation Duration Shape
Darken parent window 300 EaseInOutCurve

diminactive

Animation Duration Shape
Darken inactive windows 250 EaseInOutCurve

dimscreen

Animation Duration Shape
Dim windows 250 EaseInOutCurve
Undim windows 250 EaseInOutCurve

explosion

No timeline.

fade

(javascript plugin)

Animation Duration Shape
Fade window in 150 unknown
Fade window out 150 unknown

fadedesktop

(javascript plugin)

Animation Duration Shape
Fade between virtual desktop 250 unknown

fallapart

Animation Duration Shape
Close windows 1000 EaseInOutCurve

flipswitch

Animation Duration Shape
Show/Hide flip effect 200 EaseInOutCurve
Switch windows 200 EaseInCurve

glide

Animation Duration Shape
Open window 350 EaseOutCurve
Close window 350 EaseInCurve

highlightwindow

Animation Duration Shape
Highlight window 150 unknown

invert

No timeline.

login

Animation Duration Shape
Fade desktop in 2000 EaseInOutCurve

logout

Animation Duration Shape
Logout animation 2000 unknown

lookingglass

Animation Duration Shape
magnifies screen 500 EaseInOutCurve

magiclamp

Animation Duration Shape
Minimize window 250 LinearCurve
Unminimize window 250 LinearCurve

magnifier

minimizeanimation

Animation Duration Shape
Minimize window 250 EaseInCurve
Unminimize window 250 EaseInOutCurve

mousemark

none

outline

none

presentwindows

resize

none

scalein

Animation Duration Shape
Scale windows in 250 EaseInOutCurve

screenshot

sheet

Animation Duration Shape
show modal dialogs 500 EaseInOutCurve

showfps

none

showpaint

slide

Animation Duration Shape
Slide windows 250 EaseInOutCurve

slideback

slidingpopups

Animation Duration Shape
Slide popup in 250 EaseInOutCurve
Slide popup out 250 EaseInOutCurve

snaphelper

Animation Duration Shape
Show Snap Helper 250 LinearCurve
Hide Snap Helper 250 LinearCurve

startupfeedback

taskbarthumbnail

thumbnailaside

trackmouse

none

translucency

none
translucency/translucency.h:25:#include <QtCore/QTimeLine> (unused include)

windowgeometry

none

windowstrip

Not in effects folder?

wobblywindows

none

zoom

Animation Duration Shape
Zoom effect 500 EaseInOutCurve