Commit graph

48 commits

Author SHA1 Message Date
Vlad Zahorodnii
9f2cb0ae1b Provide expected presentation time to effects
Effects are given the interval between two consecutive frames. The main
flaw of this approach is that if the Compositor transitions from the idle
state to "active" state, i.e. when there is something to repaint,
effects may see a very large interval between the last painted frame and
the current. In order to address this issue, the Scene invalidates the
timer that is used to measure time between consecutive frames before the
Compositor is about to become idle.

While this works perfectly fine with Xinerama-style rendering, with per
screen rendering, determining whether the compositor is about to idle is
rather a tedious task mostly because a single output can't be used for
the test.

Furthermore, since the Compositor schedules pointless repaints just to
ensure that it's idle, it might take several attempts to figure out
whether the scene timer must be invalidated if you use (true) per screen
rendering.

Ideally, all effects should use a timeline helper that is aware of the
underlying render loop and its timings. However, this option is off the
table because it will involve a lot of work to implement it.

Alternative and much simpler option is to pass the expected presentation
time to effects rather than time between consecutive frames. This means
that effects are responsible for determining how much animation timelines
have to be advanced. Typically, an effect would have to store the
presentation timestamp provided in either prePaint{Screen,Window} and
use it in the subsequent prePaint{Screen,Window} call to estimate the
amount of time passed between the next and the last frames.

Unfortunately, this is an API incompatible change. However, it shouldn't
take a lot of work to port third-party binary effects, which don't use the
AnimationEffect class, to the new API. On the bright side, we no longer
need to be concerned about the Compositor getting idle.

We do still try to determine whether the Compositor is about to idle,
primarily, because the OpenGL render backend swaps buffers on present,
but that will change with the ongoing compositing timing rework.
2020-12-10 07:14:42 +00:00
Vlad Zahorodnii
4ce853e8e4 Prettify license headers 2020-08-07 19:57:56 +00:00
Vlad Zahorodnii
1fb9f6f13a Switch to SPDX license markers
The main advantage of SPDX license identifiers over the traditional
license headers is that it's more difficult to overlook inappropriate
licenses for kwin, for example GPL 3. We also don't have to copy a
lot of boilerplate text.

In order to create this change, I ran licensedigger -r -c from the
toplevel source directory.
2020-08-07 19:57:56 +00:00
Vlad Zahorodnii
55b4912004 Update my email address 2020-01-14 18:17:18 +02:00
Albert Astals Cid
e144748c7a Add some const &
Summary:
Won't make things go much faster since everything that was
being passed by value is refcounted but still const & is a bit faster
than refcounting

For shared pointers instead of adding const & we move them into the
destination variable saving some cpu usage but at the same time making
clear the pointer is being stored by not being const &

Reviewers: zzag

Reviewed By: zzag

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D25022
2019-10-30 19:23:01 +01:00
Vlad Zahorodnii
f93875535c Update my last name 2019-09-29 17:03:25 +03:00
Vlad Zagorodniy
684b4b635e Use more traditional doxygen style
Summary:
So far we were following a bit unique and rare doxygen comment style:

    /**
     * Contents of the comment.
     **/

Doxygen comments with this style look balanced and neat, but many people
that contribute to KWin don't follow this style. Instead, they prefer
more traditional doxygen comment style, i.e.

    /**
     * Contents of the comment.
     */

Reviewing such changes has been a bit frustrating for me (so selfish!)
and for other contributors.

This change switches doxygen comment style in KWin to a more traditional
style. The main reason for doing this is to make code review process easier
for new contributors as well us.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D22812
2019-07-29 22:06:19 +03:00
Vlad Zagorodniy
8af2fa73dc Run clang-tidy with modernize-use-override check
Summary:
Currently code base of kwin can be viewed as two pieces. One is very
ancient, and the other one is more modern, which uses new C++ features.

The main problem with the ancient code is that it was written before
C++11 era. So, no override or final keywords, lambdas, etc.

Quite recently, KDE compiler settings were changed to show a warning if
a virtual method has missing override keyword. As you might have already
guessed, this fired back at us because of that ancient code. We had
about 500 new compiler warnings.

A "solution" was proposed to that problem - disable -Wno-suggest-override
and the other similar warning for clang. It's hard to call a solution
because those warnings are disabled not only for the old code, but also
for new. This is not what we want!

The main argument for not actually fixing the problem was that git
history will be screwed as well because of human factor. While good git
history is a very important thing, we should not go crazy about it and
block every change that somehow alters git history. git blame allows to
specify starting revision for a reason.

The other argument (human factor) can be easily solved by using tools
such as clang-tidy. clang-tidy is a clang-based linter for C++. It can
be used for various things, e.g. fixing coding style(e.g. add missing
braces to if statements, readability-braces-around-statements check),
or in our case add missing override keywords.

Test Plan: Compiles.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, apol, romangg, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D22371
2019-07-22 20:03:22 +03:00
Vlad Zagorodniy
50c89d4858 Fix -Wdeprecated-copy
Summary:
    /home/vlad/Workspace/KDE/src/kde/workspace/kwin/scripting/scriptedeffect.cpp:408:57: warning: implicitly-declared ‘constexpr KWin::FPx2& KWin::FPx2::operator=(const KWin::FPx2&)’ is deprecated [-Wdeprecated-copy]
      408 |         fpx2 = FPx2(value1.toNumber(), value2.toNumber());
          |                                                         ^
    In file included from /home/vlad/Workspace/KDE/src/kde/workspace/kwin/scripting/scriptedeffect.h:24,
                     from /home/vlad/Workspace/KDE/src/kde/workspace/kwin/scripting/scriptedeffect.cpp:21:
    /home/vlad/Workspace/KDE/src/kde/workspace/kwin/libkwineffects/kwinanimationeffect.h:39:5: note: because ‘KWin::FPx2’ has user-provided ‘KWin::FPx2::FPx2(const KWin::FPx2&)’
       39 |     FPx2(const FPx2 &other) { f[0] = other.f[0]; f[1] = other.f[1]; valid = other.valid; }
          |     ^~~~

Reviewers: #kwin, apol

Reviewed By: apol

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D22361
2019-07-10 02:03:39 +03:00
Vlad Zagorodniy
c7639fd7ed Port away from deprecated headers
Summary: Headers like stdio.h are deprecated in C++.

Test Plan:
Compiles.

clangd no longer spews these warnings

{F6997789, size=full}

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D22351
2019-07-09 23:59:07 +03:00
Vlad Zagorodniy
dffd9777c7 [libkwineffects] Make AnimationEffect::AniMap protected
Summary:
We need AniMap only for test purposes so it would be better to make the
typedef protected (and mark as internal as well).

Test Plan: Compiles.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D17833
2019-02-26 11:37:44 +02:00
Vlad Zagorodniy
5a98591fff [libkwineffects] Adjust whitespace in AnimationEffect's header
Test Plan: Compiles.

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D17835
2019-02-01 00:31:01 +02:00
Vlad Zagorodniy
09cf04eec4 [libkwineffects] Use Q_DISABLE_COPY in AnimationEffect
Summary:
AnimationEffect is an identity so delete copy constructor and copy
assignment operator.

Test Plan: Compiles.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D17838
2019-02-01 00:29:25 +02:00
Yuri Chornoivan
9dbb74afb7 Fix minor Doxygen issues 2019-01-11 15:36:22 +02:00
Vlad Zagorodniy
be3ab3871e [libkwineffects] Overhaul AnimationEffect's documentation
Summary: This change reformats the documentation so it's more easier to read it.

Test Plan:
Generated Doxygen documentation, started Python's Simple HTTP server, navigated
to AnimationEffect's documention, haven't noticed any serious issues.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: graesslin, davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D17832
2019-01-08 20:08:38 +02:00
Vlad Zagorodniy
7dec4643f7 [libkwineffects] Use Q_ENUM in AnimationEffect
Summary: Q_ENUMS is deprecated.

Test Plan: The Window Aperture effect still works.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D17587
2018-12-21 02:26:13 +02:00
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
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
Thomas Lübking
1faa8aa039 allow to retarget animations 2016-02-16 13:59:22 +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
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
Jacob Logan
0c4518cca9 added export header through cmake for kwineffects
REVIEW: 114233
2013-12-02 07:43:26 +01: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
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
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
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
32b6ef42b9 Strip module path from all Qt #include <>
Done with:
fixqt4headers.pl --strip-modules

REVIEW: 109176
2013-03-06 10:26:56 +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
Martin Gräßlin
533d57da60 Mark most ctors as explicit as reported by Krazy2 checker 2013-01-02 18:35:46 +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
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
e824412535 Export FPx2 to scripted effects
Simplifies the API. An FPx2 can be defined as a single real value
or a complex object with two real values:
{
value1: 1.0,
value2: 2.0
}
For a default ctor a null value can be used.
2012-03-12 21:37:40 +01:00
Martin Gräßlin
5592dffb48 JavaScript bindings for KWin effects
Scripted effects follow the Plamsoid package structure and the effect
loader recognizes a scripted effect at the according line in the desktop
file. If it is a scripted effect a different loader is used which
instantiates an object of the ScriptedEffect class. This class inherits
the AnimationEffect and exports the animate method and the EffectsHandler.
2012-03-12 21:37:40 +01: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
Martin Gräßlin
11be6d5b40 Fix typos
SVN_SILENT
2012-01-01 09:26:27 +01:00
Martin Gräßlin
5c6febf147 Use Q_SLOTS instead of slots
Krazy wants it that way.
SVN_SILENT
2012-01-01 09:23:48 +01:00
Thomas Lübking
5f9f4db401 export AnimationEffect class, add non float Point/Size construtors to FPx2
CCMAIL:kde-bindings@kde.org
This API change is in the kwin effect library and probably not of interest
2011-11-24 20:17:19 +01:00
Thomas Lübking
67e79ea13a Add AnimationEffect class
REVIEW: 102922
2011-10-27 21:40:14 +02:00