Commit Graph

53 Commits (3ad56045805b50ade252e4353eac158e7eee7b5f)

Author SHA1 Message Date
Vlad Zagorodniy 396d528075 [scripting] Introduce complete function
Summary:
Effects that prefer to manipulate direction of animations sometimes need
to create animations in some particular state so later on they can be
played backward (swapping from and to is not enough and it would be wrong).

The proposed complete function lets such effects to fast-forward animations to
to the target position so they can be played backwards later on.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16450
2018-11-17 13:44:20 +02:00
Vlad Zagorodniy 5e104fbc12 [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
2018-11-17 13:44:16 +02:00
Vlad Zagorodniy ee72569647 [libkwineffects] Port AnimationEffect to TimeLine
Summary:
TimeLine has nice API for controlling its direction that can be re-used
later by AnimationEffect.

Test Plan: The existing tests for scripting effects still pass.

Reviewers: #kwin, davidedmundson, graesslin

Reviewed By: #kwin, davidedmundson, graesslin

Subscribers: davidedmundson, abetts, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16448
2018-11-17 13:43:57 +02:00
Vlad Zagorodniy 688d946ffb [libkwineffects] Gracefully release previous window pixmap
Summary:
If the cross fade animation is cancelled, we are not gracefully
unreference the previous window pixmap.

This change addresses that issue by using RAII approach to
reference/unreference the previous window pixmap.

Test Plan: Manually. The Maximize and the Morphing Popups effect still work.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16391
2018-11-12 12:51:08 +02:00
Vlad Zagorodniy 1b7cad95c7 [libkwineffects] Don't enable painting for windows that are not kept alive
Summary:
862bf0f153 introduced a regression(sorry
for that): if you close a confirmation dialog(with the Scale effect and the
Dialog Parent effect being enabled), the main window(s) will flicker.

That flickering happens because the C++ version of the Scale effect and
AnimationEffect unref deleted windows in different places. AnimationEffect
unrefs deleted windows in prePaintScreen, which btw is not the best
place to do that. The C++ version unrefed windows in postPaintScreen.

So, when the Scale effect has finished animating the main windows, it
will unref them, but windowDeleted signal won't be emitted immediately.
Which means that the Dialog Parent won't be able to delete corresponding
animations on its side and main windows will be painted for a single
frame.

This change addresses flickering by adjusting prePaintWindow in
AnimationEffect so deleted windows won't be painted if none of
animations keeps them alive.

Test Plan:
(make sure that both the scale and the dialog parent effect are enabled)
* Go to System Settings > Application Style > Window Decorations;
* Select a decoration that is different from the current;
* Close the system settings window (don't click "Apply" button);
* When a dialog is shown, click "Discard" or "Apply" button.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16542
2018-10-31 15:49:11 +02:00
Vlad Zagorodniy a281f2bce1 [effects/dialogparent] Fix flickering of parent windows
Summary:
If a modal window is closed and some alternative effect that animates
the disappearing of windows is enabled(e.g. the Glide effect, or the
Scale effect), the Dialog Parent effect can cause flickering of the
parent window because its animation duration doesn't match duration of
those alternative effects.

Also, if the Fade effect, the Glide effect, and the Scale effect are
disabled, the Dialog Parent will keep the parent window alive for no
good reason.

This change addresses that problem by adding keepAlive property to
`animate` function so scripted effects have more control over lifetime
of animated windows.

If both a modal window and its parent window are closed at the same time
(and there is no effect that animates the disappearing of windows), the
Dialog Parent will stop immediately(because windowDeleted will be
emitted right after windowClosed signal).

If both a modal window and its parent window are closed at the same time
(and there is effect that animates the disappearing of windows), the
Dialog Parent won't reference the latter window. Thus, it won't cause
flickering. I.e. it will "passively" animate parent windows.

BUG: 355036
FIXED-IN: 5.15.0

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D14919
2018-10-10 18:34:12 +03:00
Vlad Zagorodniy 5d5816be2b [libkwineffects] Don't expose the fullscreen effect lock to the public API
Summary:
The fullscreen effect lock is purely an implementation detail of the
AnimationEffect, we don't need to have it in the public API.

Test Plan: KWin still compiles.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16075
2018-10-09 19:06:04 +03:00
David Edmundson 99b33e7428 [libkwineffects] Expose getting/setting activeFullScript to scripted effects
Summary:
Getter is exposed as a property on scripted effect in a way that hides
pointers from the scripting side.

Setter is implicitly handled as a property of newly created animations
and holds the activeFullScreenEffect whilst any of them are active. Like
existing effects it remains up to the effect author to avoid the
problems of multiple full screen effects. The RAII lock pattern is
somewhat overkill currently, but it's the direction I hope we can take
EffectsHandler in next API break.

BUG: 396790

--

This patch is against the QJSEngine port, though it's not conceptually a
requirement.

Test Plan: Unit test

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D14688
2018-10-04 00:57:44 +03:00
David Edmundson 5d279a0ddd [autotests] Unit most scripted effects API
Summary:
Ready for QJSEngine port and upcoming other fixes.
Split as it makes it easier to do any before/after testing.

Test Plan:
All tests pass with the current QScriptEngine
Verified expected API against a wiki page and current code.

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D14482
2018-07-31 12:29:04 +01:00
Marco Martin 595c5937c9 use a global static for animation ids
using stack adresses makes it possible (even tough not frequent)
for two animations (onle just killed, one just created) to have
the same id, causing scripts to be potentially really confused.
this replaces the id with a global counter, and the
"flying tooltips" bug is gone.

REVIEW:127276
BUG:360068
CCBUG:352254
2016-03-04 18:19:40 +01:00
Thomas Lübking 5ee90dce3d fix validation cnp bugs
pushed wrong branch, this fixes the unguarded
from resolution in the to branches

REVIEW: 126981
2016-02-16 15:08:21 +01:00
Thomas Lübking 1faa8aa039 allow to retarget animations 2016-02-16 13:59:22 +01:00
Thomas Lübking 07cc30d136 protect against cancel of just ended animations 2016-02-16 13:58:24 +01:00
Kevin Funk a33c2730ba AnimationEffect: Fix memory leak
Detected by ASAN

```
Direct leak of 144 byte(s) in 6 object(s) allocated from:
    #0 0x4dc922 in operator new(unsigned long)
(/home/kfunk/devel/install/kf5/bin/kwin_x11+0x4dc922)
    #1 0x7f43dc33d019 in KWin::AnimationEffect::AnimationEffect()
/home/kfunk/devel/src/kf5/kwin/libkwineffects/kwinanimationeffect.cpp:50:44
    #2 0x7f43dbb63e9a in KWin::ScriptedEffect::ScriptedEffect()
/home/kfunk/devel/src/kf5/kwin/scripting/scriptedeffect.cpp:422:1
    #3 0x7f43dbb60513 in KWin::ScriptedEffect::create(QString const&,
QString const&, int)
/home/kfunk/devel/src/kf5/kwin/scripting/scriptedeffect.cpp:407:30
    #4 0x7f43dbb5fcbb in KWin::ScriptedEffect::create(KPluginMetaData
const&)
/home/kfunk/devel/src/kf5/kwin/scripting/scriptedeffect.cpp:402:12
    #5 0x7f43db955fa3 in
KWin::ScriptedEffectLoader::loadEffect(KPluginMetaData const&,
QFlags<KWin::LoadEffectFlag>)
/home/kfunk/devel/src/kf5/kwin/effectloader.cpp:242:25
    #6 0x7f43db9994bf in
KWin::EffectLoadQueue<KWin::ScriptedEffectLoader,
KPluginMetaData>::dequeue()
/home/kfunk/devel/src/kf5/kwin/effectloader.h:257:9
    #7 0x7f43dbf0e2bd in
KWin::AbstractEffectLoadQueue::qt_static_metacall(QObject*,
QMetaObject::Call, int, void**)
/home/kfunk/devel/build/kf5/kwin/moc_effectloader.cpp:179:17
    #8 0x7f43d54de7b0 in QObject::event(QEvent*)
(/usr/lib/x86_64-linux-gnu/libQt5Core.so.5+0x2b67b0)
    #9 0x7f43d5da39db in QApplicationPrivate::notify_helper(QObject*,
QEvent*) (/usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5+0x15b9db)
```

Differential Revision: https://phabricator.kde.org/D942
2016-02-15 17:42:32 +01:00
Nick Shaforostoff 3a8d7d866a optimize string operations
-use qstringliteral only when necessary (i.e. not in concat or comparison)
-use qbytearray instead of qstring when dealing with latin1 input and output (glplatform)
-use qstringref to extract numbers from strings (glplatform)
-define qt_use_qstringbuilder to optimize all string concatenations
-anidata: use ctor init lists, add windowType member initialization

REVIEW: 125933
2015-11-05 14:14:06 +00:00
Martin Gräßlin bf4ba54647 Remove displayWidth and displayHeight from the compositor
Instead of getting size from displayWidth() and displayHeight() use
the information we have from Screens. This means there is only one
place to have the information and by that we can ensure that all
components use the same data to rely on. displayWidth/displayHeight
seem to provide the wrong information when unplugging an output
without disabling the output. This results in rendering artefacts.
But KWin::Screens has the correct information available.
2014-11-27 09:00:19 +01:00
Fredrik Höglund 0aff9830df Remove the decoration opacity property
It has been broken since cross-fading was introduced, and no one has
filed any bug reports about it.
2014-08-25 17:25:04 +02:00
Martin Gräßlin 014cdf9267 [kwin] Mark unused variables as unused
--warnings
2014-02-03 11:36:21 +01:00
Alex Richardson 109c504ef7 fix mismatched struct/class forward declaration
Found by compiling with clang
2013-09-13 16:52:25 +02:00
Martin Gräßlin 9291b18cee Merge branch 'master' into frameworks-scratch
Conflicts:
	CMakeLists.txt
	kwin/effects.cpp
	kwin/effects/logout/logout.cpp
	kwin/effects/presentwindows/main.qml
	kwin/effects/presentwindows/presentwindows.cpp
	kwin/effects/presentwindows/presentwindows.h
	kwin/effects/zoom/zoom_config.cpp
	kwin/libkwineffects/kwinglutils_funcs.cpp
	kwin/libkwineffects/kwinxrenderutils.cpp
	kwin/nvidiahack.cpp
	kwin/xcbutils.h
	plasma/desktop/containments/desktop/plasma-containment-desktop.desktop
	plasma/generic/wallpapers/image/image.cpp
	plasma/generic/wallpapers/image/plasma-wallpaper-image.desktop
2013-08-07 10:10:06 +02:00
Thomas Lübking b92ebe02aa add synthetic repaint after crossfade finished
prevents glitches after crossfading translucent window

REVIEW: 111888
2013-08-06 09:12:05 +02:00
Martin Gräßlin 330d40f425 Fix no cast to/from ASCII intrduced issues
* "" needs to be wrapped in QStringLiteral
* QString::fromUtf8 needed for const char* and QByteArray
* QByteArray::constData() needed to get to the const char*
2013-07-24 09:58:33 +02:00
Thomas Lübking 88be3d0caf ensure to init animationeffect bindings
it seems an animation can be triggered and the resp.
window deleted in the first event cycle (before the deleted
signal is bound) - so we add an initialization flag to ensure
the binding happens before the first animation is added

BUG: 320562
FIXED-IN: 4.11
REVIEW: 110872
2013-06-10 16:38:03 +02:00
Martin Gräßlin 5660801192 Add DecorationOpacity to AnimationEffect
Just like Opacity for transforming only the decoration opacity.

It's an ABI break as the new enum value had to be included as anonther
non-float base value.
2013-06-05 08:27:09 +02:00
Martin Gräßlin 941c02a60f Introduce cross-fading with previous pixmap
Cross fading with previous pixmap is achieved by referencing the old
window pixmap. WindowPaintData has a cross-fade-factor which interpolates
between 0.0 (completely old pixmap) to 1.0 (completely new pixmap).

If a cross fading factor is set and a previous pixmap is valid this one
is rendered on top of the current pixmap with opacity adjusted. This
results in a smoother fading.

To simplify the setup the AnimationEffect is extended and also takes care
about correctly (un)referencing the previous window pixmap. The maximize
effect is adjusted to make use of this new capabilities.

Unfortunately this setup has a huge problem with the case that the window
decoration gets smaller (e.g. from normal to maximized state). In this
situation it can happen that the old window is rendered with parts outside
the content resulting in video garbage being shown. To prevent this a set
of new WindowQuads is generated with normalized texture coordinates in
the safe area which contains real content.

For OpenGL2Window a PreviousContentLeaf is added which is only set up in
case the crass fading factor is set.

REVIEW: 110578
2013-06-05 08:18:28 +02:00
Martin Gräßlin aa92d2dbd9 No repaints for keepAtTarget and before started
Do not schedule repaints in AnimationEffect if there are no animations
going on. If an animation is waiting for starting or kept after ending
the visual appearance is no longer changed, so no repaint is needed.

REVIEW: 110795
2013-06-03 15:45:02 +02:00
Montel Laurent dd8cf0b678 normalize signal/slot 2013-05-11 14:09:15 +02:00
Thomas Lübking ee1d6d568d add effect debug interface and dbus export
allows for effect specific debugging details

REVIEW: 107063
2013-03-28 20:31:02 +01:00
Thomas Lübking a5cce085af catch geometry updates of moving clients
and bind geometry change signals dynamically

REVIEW: 109570
2013-03-20 22:23:43 +01:00
Thomas Lübking 5299f728fe catch geometry updates of moving clients
and bind geometry change signals dynamically

REVIEW: 109570
(cherry picked from commit eb2db41304f1ec1e597e9bd282a9c4f0b7dd1e54)

Conflicts:
	kwin/libkwineffects/kwinanimationeffect.cpp
2013-03-20 22:23:41 +01:00
Martin Gräßlin b01f5684c5 Remove not needed includes from kwineffect header files
Only include what's actually needed in the headers. This causes of course
some additional needed includes in some implementation files.
2013-03-06 10:23:09 +01:00
Thomas Lübking 39499de9cc add AnimationEffect::set() and ::cancel()
This will allow to sue the AnimationEffect class for
(temorarily) persistent changes like required by the
translucency effect

REVIEW: 109211
2013-03-05 19:24:30 +01:00
Thomas Lübking 56cd3f8928 fix copy and paste error
setting from because to is invalid is rather wrong
2013-01-30 10:45:21 +01:00
Thomas Lübking b3f71b5986 protect list iterators against ext. manipulation
REVIEW: 108151
2013-01-08 20:47:50 +01:00
Thomas Lübking 7bc5832429 use QELapsedTimer to measure animation delay
QElapsedTimer uses a monotic clock on all relevant systems
and is thus invarant against date/time changes (while the
bug was likely caused by daybreaks)

BUG: 306186
REVIEW: 107250
FIXED-IN: 4.10

use monitc clock
2012-11-14 21:16:32 +01:00
Jurica Vukadin e68955866d Fix C++11 narrowing warnings
REVIEW: 106992
2012-10-24 20:42:14 +02:00
Martin Gräßlin c7262e8bd3 Getter/setters for opacity, saturation and brightness in WindowPaintData
The public member variables for opacity, saturation and brightness
are removed in favor for getter and setters. The variables are
moved into a private class. Those are now qreal instead of double.

To make usage inside the effects easier a multiply method is added
which multiplies the current value with passed in factor and returns
the new value in a functional programming style.

This commit is the top-most of a patch series to refactor
ScreenPaintData and WindowPaintData. Other related commits are:
* 0811772
* ebdc7ec
* 2c8dd8d
* 7699726
* 68e0201
* 611cb09

REVIEW: 105141
BUG: 303314
FIXED-IN: 4.10
2012-07-19 18:25:48 +02:00
Martin Gräßlin dd067b075b Split out common part of ScreenPaintData and WindowPaintData
New common d-pointered class PaintData is added which cannot
be instantiated.
2012-07-19 18:25:03 +02:00
Martin Gräßlin a2b0d42916 Replace translation by QVector3D in Screen/Window PaintData 2012-07-19 18:25:03 +02:00
Martin Gräßlin 0eff12eb92 Use QGraphicsScale for scale information in ScreenPaintData 2012-07-19 18:25:03 +02:00
Martin Gräßlin 966047ccd2 Replace custom RotationData with QGraphicsRotation 2012-07-19 18:25:03 +02:00
Martin Gräßlin 812c310dcf Fix unused variable warnings
SVN_SILENT
2012-05-27 16:35:04 +02:00
Thomas Lübking 41a39a9928 add clipping support to AnimationEffect
REVIEW: 104898
2012-05-10 19:35:13 +02:00
Thomas Lübking c67ba0fafb change animationEnded signature 2012-05-03 17:53:02 +02:00
Thomas Lübking 590d9b42d8 restrict animationeffect repaints
REVIEW: 103932
2012-05-03 17:52:49 +02:00
Martin Gräßlin 2007a7eab8 Use namespaced parameters in signals
Required to get scripting bindings working.
2012-03-12 21:37:40 +01:00
Thomas Lübking d73f2f25ab Revert "restrict AnimationEffect repainting"
Fun with git/rebase ...

This reverts commit ff167657282c8e424984155018a4f4113870c34f.
2012-02-12 17:34:47 +01:00
Thomas Lübking 39fb788103 restrict AnimationEffect repainting
BUMPs Effect API to 183
2012-02-12 17:29:01 +01:00
Thomas Lübking 2062b8eabd Nanny the Sun compiler by an explicit cast ;-)
BUG: 291690
2012-01-16 22:11:46 +01:00
Thomas Lübking daf4255f1b call animationEnded when the animation ended... 2011-12-10 21:26:21 +01:00