Commit Graph

374 Commits (master)

Author SHA1 Message Date
Vlad Zahorodnii 1e9bd43368 scripting: Fix initialization of WorkspaceWrapper
Workspace::clientList() only returns X11 clients, while allClientList()
returns all managed clients (both X11 and Wayland).
2020-10-01 10:20:31 +00:00
Vlad Zahorodnii 1251b2cbb3 scripting: Make ClientFilterModel work for Wayland windows 2020-10-01 10:20:31 +00:00
Vlad Zahorodnii faf6b8e049 scripting: Properly initialize clients model for Wayland windows
In some cases, a ClientLevel model may not contain all Wayland windows
because of missing if (waylandServer()) {} code path in init() method.
2020-10-01 10:20:31 +00:00
Vlad Zahorodnii 0c266e760b Replace remaining usages of old connect syntax with new connect syntax
This change replaces the remaining usages of the old connect syntax with
the new connect syntax.

Unfortunately, there are still places where we have to use SIGNAL() and
SLOT() macros, for example the stuff that deals with d-bus business.

Clazy was used to create this change. There were a few cases that needed
manual intervention, the majority of those cases were about resolving
ambiguity caused by overloaded signals.
2020-09-24 09:33:45 +00:00
Vlad Zahorodnii 90b53f416c Use universal helper for writing toplevels to QDebug streams
Toplevel::debug() is one of annoyances that you need to deal with when
implementing a new client type. It can be tempting to just write "this"
to the stream, but it will result in a crash.

In order to make implementing new client types easier, this change
introduces a debug stream insertion operator overload that works for all
kinds of the Toplevel class.
2020-08-21 11:42:53 +00:00
Kai Uwe Broulik 16f74986fb Expose effect ID to scripting via `effect.pluginId`
This can be used to avoid code duplication by installing an effect multiple
times and tweaking behavior slightly based on the returned ID.

Internally it is called `scriptName` but for consistency with other similar
APIs the name `pluginId` is chosen, and returns e.g. `kwin4_effect_maximize`
2020-08-11 18:50:24 +02: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 a17a86999b Emit clientAdded for wayland clients
Emit the clientAdded() signal also for Wayland clients in order to unify
the API of the Workspace class for different client types.
2020-07-27 15:01:07 +00:00
l10n daemon script a1c0d43deb SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2020-07-23 06:10:20 +02:00
l10n daemon script c10fe06d06 SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2020-06-18 05:44:57 +02:00
l10n daemon script 0e117c49a1 SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2020-06-17 14:12:29 +02:00
Tiago Corrêa 232984c123 scripting: Provide methods to create and remove virtual desktops
Summary: There are methods to create and remove virtual desktops via dbus, but I think it would be convenient to provide these methods for KWin scripts as well.

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D29786
2020-05-21 09:14:55 +03:00
Vlad Zahorodnii 7b751099bf Emit Workspace::clientAdded() with AbstractClient
Summary:
Currently, if one wants to monitor for new X11 and Wayland clients, they
have to listen for two signals. Workspace::clientAdded() is emitted only
for X11 and Xwayland clients, while WaylandServer::shellClientAdded() is
emitted only for xdg-shell clients. Such design doesn't scale well.

As the first towards emitting Workspace::clientAdded() for new Wayland
clients, this change replaces the X11Client parameter in the clientAdded
signal with AbstractClient.

Test Plan: Tests still pass.

Reviewers: #kwin, cblack

Reviewed By: cblack

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D29665
2020-05-12 08:38:01 +03:00
Tiago Corrêa 45c6e4b811 scripting: Introduce ClientModelByScreenAndActivity
Summary: Provide for KWin scripts the possibility to work with a activities aware ClientModel. In the same way that the ClientModelByScreenAndDesktop works with virtual desktops.

Reviewers: #kwin, mart, zzag

Reviewed By: #kwin, zzag

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D29284
2020-05-11 14:27:00 +03:00
Tiago Corrêa e38a241048 scripting: Make workspace.currentActivity writable
Summary: Allows KWin scripts to change the value of workspace.currentActivity property.

Reviewers: #kwin

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D29458
2020-05-07 08:36:02 +03:00
Vlad Zahorodnii 890c770033 Merge branch 'Plasma/5.18' 2020-04-24 13:28:57 +03:00
Vlad Zahorodnii fd106de650 [scripting] Re-evaluate exclusions after switching between virtual desktops or activities
Summary:
OtherDesktopsExclusion and OtherActivitiesExclusion flags must be
re-evaluated after user has switched between virtual desktops or
activities; otherwise ClientLevel may contain clients that are not
necessarily on the current virtual desktop or activity.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Maniphest Tasks: T12877

Differential Revision: https://phabricator.kde.org/D28827
2020-04-24 13:28:39 +03:00
Vlad Zahorodnii be759b7d33 Use AbstractClient instead of XdgShellClient wherever possible
Summary:
Currently, we have only one shell client type - XdgShellClient. We use
it when we are dealing with Wayland clients. But it isn't really a good
idea because we may need to support shell surfaces other than xdg-shell
ones, for example input panel surfaces.

In order to make kwin more extensible, this change replaces all usages
of the XdgShellClient class with the AbstractClient class.

Test Plan: Existing tests pass.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D27778
2020-03-04 09:57:13 +02:00
Vlad Zahorodnii 76297196e8 [scripting] Expose Workspace::sendClientToDesktop()
Summary:
BUG: 416093
FIXED-IN: 5.18.0

Test Plan: Only compile-time check.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D26988
2020-01-29 17:14:41 +02:00
Vlad Zahorodnii 9d4a32596c Drop some custom list typedefs
Summary:
Qt has its own thing where a type might also have corresponding list
alias, e.g. QObject and QObjectList, QWidget and QWidgetList. I don't
know why Qt does that, maybe for some historical reasons, but what
matters is that we copy this pattern here in KWin. While this pattern
might be useful with some long list types, for example

    QList<QWeakPointer<TabBoxClient>> TabBoxClientList

in general, it causes more harm than good. For example, we've got two
new client types, do we need corresponding list typedefs for them? If
no, why do we have ClientList and so on?

Another problem with these typedefs is that you need to include utils.h
header in order to use them. A better way to handle such things is to
just forward declare a client class (if that's possible) and use it
directly with QList or QVector. This way translation units don't get
"bloated" with utils.h stuff for no apparent reason.

So, in order to make code more consistent and easier to follow, this
change drops some of our custom typedefs. Namely ConstClientList,
ClientList, DeletedList, UnmanagedList, ToplevelList, and GroupList.

Test Plan: Compiles.

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D24950
2019-11-27 15:54:08 +02:00
David Edmundson e4ac215fcb [effects] Add effect to hold the desktop window static after plasmashell quits
Summary:
When a plasma session quits, the order of plasmashell and clients quitting is undetermined.

This looks bad as our desktop background disappears quite early. Rather than changing the real order, we can have kwin reference the last pixmap of any desktop and hold on to it.

Lasting till the compositor quits means it stays on the X frontbuffer till X quits and the experience is seamless.

Test Plan: Logged out (with relevant other ksmserver patches)

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D24864
2019-11-01 17:14:55 +00:00
Vlad Zahorodnii 69a3517e02 Merge branch 'Plasma/5.17' 2019-10-25 17:50:13 +03:00
Vlad Zahorodnii a738ecce85 [scripting] Provide conversion functions for AbstractClient
Summary:
If no conversion functions are provided for a QObject-subclass, then
QScriptEngine will use QScriptEngine::newQObject() method without any
special options to convert an instance of that QObject-subclass to a
QScriptValue. However, it's very important that every client object is
wrapped with PreferExistingWrapperObject option. We need that option
because a script may set a property on a client object and that property
must remain until it's deleted by the script.

BUG: 413044
FIXED-IN: 5.17.2

Test Plan: New test.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D24944
2019-10-25 17:39:45 +03:00
Vlad Zahorodnii ffcbe24e2b Rename Client to X11Client
Summary:
Currently each managed X11 client is represented with an instance of
Client class, however the name of that class is very generic and the
only reason why it's called that way is because historically kwin
was created as an x11 window manager, so "Client" was a sensible choice.

With introduction of wayland support, things had changed and therefore
Client needs to be renamed to X11Client in order to better reflect what
that class stands for.

Renaming of Client to X11Client was agreed upon during the last KWin
sprint.

Test Plan: Compiles, the test suite is still green.

Reviewers: #kwin, romangg

Reviewed By: #kwin, romangg

Subscribers: romangg, davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D24184
2019-09-25 21:11:37 +03:00
Vlad Zagorodniy 168ea98845 Rename ShellClient to XdgShellClient
Summary:
Rename ShellClient to XdgShellClient in order to reflect that it
represents only xdg-shell clients.

Test Plan: Compiles, tests still pass.

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D23589
2019-09-23 17:28:56 +03:00
Vlad Zahorodnii 62a7db7028 Use nullptr everywhere
Summary:
Because KWin is a very old project, we use three kinds of null pointer
literals: 0, NULL, and nullptr. Since C++11, it's recommended to use
nullptr keyword.

This change converts all usages of 0 and NULL literal to nullptr. Even
though it breaks git history, we need to do it in order to have consistent
code as well to ease code reviews (it's very tempting for some people to
add unrelated changes to their patches, e.g. converting NULL to nullptr).

Test Plan: Compiles.

Reviewers: #kwin, davidedmundson, romangg

Reviewed By: #kwin, davidedmundson, romangg

Subscribers: romangg, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D23618
2019-09-19 17:48:21 +03:00
Vlad Zahorodnii 5ad3c0ee13 Port away from deprecated qVariantFromValue
Summary:
qVariantFromValue is deprecated since Qt 5.14. It's advised to use
QVariant::fromValue instead.

Test Plan: Compiles.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D24042
2019-09-18 16:20:06 +03:00
Vlad Zahorodnii dcf91d4321 Cleanup style in CMakeLists.txt files
We have lots of inconsistency at the moment in CMakeLists.txt files. Most
of it is due to kwin being a very old project. This change hopefully fixes
all of it.
2019-09-17 16:03:05 +03:00
Frederik Gladhorn b64e67ce7c Remove disabled TabGroup feature
Summary:
This has been commented out since 2014, I doubt it will come back.
This is a big amount of code, maintenance will be easier without it.

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: romangg, graesslin, kwin

Tags: #kwin, #documentation

Differential Revision: https://phabricator.kde.org/D23069
2019-09-14 10:58:48 +02: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
l10n daemon script 9c0a71c37f SVN_SILENT made messages (.desktop file) - always resolve ours
In case of conflict in i18n, keep the version of the branch "ours"
To resolve a particular conflict, "git checkout --ours path/to/file.desktop"
2019-07-13 05:18:09 +02:00
Vlad Zagorodniy 0be5bc45a7 Don't use deprecated QAbstractItemModel::setRoleNames
Summary:
setRoleNames() method is deprecated since Qt 5.0. It is strongly advised
to reimplement roleNames() method instead.

Reviewers: #kwin, apol

Reviewed By: apol

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D22358
2019-07-10 02:02:39 +03:00
Vlad Zagorodniy 4bbef8d128 [scripting] Emit clientAdded for Wayland clients
Summary:
Currently, if a script relies on clientAdded to setup some required
connections, then it probably won't work with Wayland clients because
clientAdded is emitted only for X11 clients.

Test Plan:
* Installed sticky window snapping script, it works;
* Installed a couple of tiling scripts, with some small changes, they work.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: strobach, TomButler, davidedmundson, mart, graesslin, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D17097
2019-05-24 00:27:32 +03:00
Vlad Zagorodniy 689d89ae4e [scripting] Port the remaining bits of API to AbstractClient
Currently, clientArea(ClientAreaOption, const Client *) and clientList()
are quite X11-specific, which results in having some tiling scripts not
working with Wayland clients. This change is the first step towards working
tiling scripts in the Wayland session.
2019-05-24 00:27:11 +03:00
David Edmundson 47be4be020 [scripting] Make DBus invokable run method return result after execution
Summary:
In 403038 the user expected the DBus call to run to finish before
processing the next request. For a singleshot script that makes a lot of
sense, otherwise you have no idea when it finishes.

This also allows us to return errors.

CCBUG: 403038

Test Plan:
NUM=$(qdbus org.kde.KWin /Scripting org.kde.kwin.Scripting.loadScript /noFile.js Minimize)
qdbus org.kde.KWin /$NUM org.kde.kwin.Scripting.run
  Error: org.kde.kwin.Scripting.FileError
  Could not open /noFile.js

Running a real script behaved effectively the same as before.

Reviewers: #kwin, graesslin

Reviewed By: #kwin, graesslin

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D18127
2019-02-22 14:40:15 +00:00
Vlad Zagorodniy 7b20e1f66f Overhaul doxygen comments
Summary:
We have a mix of different doxygen comment styles, e.g.

    /*!
      Foo bar.
     */

    /**
     * Foo bar.
     */

    /** Foo bar.
     */

    /**
     * Foo bar.
     */

    /**
     * Foo bar.
     **/

To make the code more consistent, this change updates the style of all
doxygen comments to the last one.

Test Plan: Compiles.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D18683
2019-02-12 19:29:33 +02:00
Martin Flöser cfecb1e077 Fix reorder warning in AbstractScript
Summary:
scripting/scripting.h:205:13: warning: ‘KWin::AbstractScript::m_pluginName’ will be initialized after [-Wreorder]
     QString m_pluginName;
             ^~~~~~~~~~~~
scripting/scripting.h:204:13: warning:   ‘QString KWin::AbstractScript::m_fileName’ [-Wreorder]
     QString m_fileName;
             ^~~~~~~~~~
scripting/scripting.cpp:230:1: warning:   when initialized here [-Wreorder]
 KWin::AbstractScript::AbstractScript(int id, QString scriptName, QString pluginName, QObject *parent)
 ^~~~

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D18560
2019-01-27 13:25:40 +01:00
Yuri Chornoivan d17a3ff88f Fix minor Doxygen issues 2019-01-12 12:31:32 +02:00
David Edmundson ba7aecfe53 [scripting] Avoid threading issues when loading from a file
Summary:
KWin::Script::loadScriptFromFile ran in it's own thread and accessed
member variables of KWin::Script without any guards.

Potentially script could be destroyed whilst the file is loading.

Rather than adding mutexes everywhere, this patch scopes the QFile
object to be local to the threaded function making it independent.

BUG: 403038

Test Plan: Ran a script from a file

Reviewers: #kwin, graesslin

Reviewed By: #kwin, graesslin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D18126
2019-01-09 23:37:37 +00: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 8d0554e45a [scripting] Allow effects to grab windows
Summary:
Some JavaScript based effects need to grab particular windows in order
to avoid conflicts with other effects.

Example usage:

```lang=js
effects.windowAdded.connect(function (window) {
    if (effect.grab(window, Effect.WindowAddedGrabRole)) {
        window.coolWindowTypeAnimation = animate({
            ...
        });
    }
});
```

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: romangg, graesslin, davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D13153
2018-10-29 10:17:21 +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 b9653b4e95 [scripting] Propagate fullScreenEffect from global settings to local settings
Test Plan: Ran the test.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16097
2018-10-10 18:27:52 +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 d485dfe7ef Avoid crash with on scripted window teardown with threaded quick render loop
Summary:
Qt render loops behave quite differently to each other.

KWin scripting as a workaround for another situation cleans
(17553e5a1f) handles tracking of script
windows by deleting the underlying window handle on hide.

This currently happens before the window gets the hideEvent.

Arguably this is a quirk with Qt, but in the current state:

- QSGThreadedRenderLoop deletes the platform window and cleans up
- We then get the hide() event. This no-ops because there's no window.
   (else branch of     case WM_TryRelease in qsgthreadedrenderloop.cpp)
- We carry on rendering animations despite having no platform
- undefined behaviour

Normally this isn't a problem as typically destruction of the platform window
happens only when a window is being deleted, we're messing with Qt
internals here.

If we make sure the QHideEvent is processed by the render loop first,
things seem fine.

BUG: 397767

Test Plan:
Ran QSG_RENDER_LOOP=threaded
Read output with scenegraph logging rules on

Reviewers: #kwin, broulik

Reviewed By: broulik

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D15025
2018-09-13 10:19:12 +01:00
David Edmundson 3332b32101 [scripting] Fix effect.animate() curve argument being actually used
Summary:
One cannot use a non metatype frrom an external class inside an
invokable. https://bugreports.qt.io/browse/QTBUG-58454

End result is the script engine arguments wouldn't match up and MOC
would just use the default value.

As far as I can tell this has been broken for 6 years.
The global animate method that unboxes a QJSValue as an object is
unaffected.
No shipped kwin effect actually used it.

To some extent we didn't even actually want to enforce the enum as we
also accept custom value of ScriptedEffect::GuassianCurve, so it has
been switched for an int.

Test Plan: Unit test

Reviewers: #kwin, broulik

Reviewed By: broulik

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D14669
2018-08-07 21:33:29 +01: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