Commit Graph

65 Commits (master)

Author SHA1 Message Date
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
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
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 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 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
David Edmundson a3cff85e7a Remove Qt module declarations in includes
Summary:
Test Plan: Compiles

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D13359
2018-06-05 18:07:23 +01:00
Martin Gräßlin 1e13deaa1d Port some displayWidth/displayHeight usages to Screens::size()
Summary:
KWin::displayWidth and KWin::displayHeight are bound to X11 which
doesn't make much sense on X11. In addition KWin internally knows
the overall display dimensions through the Screens singleton class.

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D1798
2017-09-01 17:11:10 +02:00
Andreas Hartmetz 90a33a4bc2 Fix two more const / non-const iterator mismatches.
I did some research with the result that such comparisons are indeed
not standardized to be legal before C++14. In C++14 they are.
These microoptimizations can thus be re-enabled when C++14 becomes
the required version.
2017-04-07 20:38:19 +02:00
Martin Gräßlin 2be1625822 Add support for new touch screen callbacks to KWin scripts and scripted effects
Summary:
Exposes two new global JS functions to register and unregister touch
screen edges.

Test Plan: Added test case

Reviewers: #kwin, #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D5277
2017-04-07 16:18:09 +02:00
Martin Gräßlin 6184278bec Fix for failing testScriptedEffectsLoader
By changing the loading of scripted effect config to interact with
kwinApp we broke the tests which do not use a kwinApp.

This change turns the access to the KSharedConfigPtr go through the
property system, so that the tests can also install a dummy
KSharedConfigPtr. With that scripted effects loader test passes and no
longer crashes and the integration/effects tests also still pass.
2016-11-16 16:53:17 +01:00
Martin Gräßlin af83401b83 Use KWin's KSharedConfigPtr in ScriptedEffect
Summary:
So far ScriptedEffect used EffectsHandler::effectConfig to get the
KConfigGroup for the ScriptedEffect. This has the disadvantage that the
config file name is hardcoded to kwinrc in EffectsHandler::effectConfig.

Inside KWin a KSharedConfigPtr is used which can point to somwhere else
than kwinrc. If that was the case the ScriptedEffects were not able to
pick up this customized config and instead continued to read values from
kwinrc.

With this change the ScriptedEffects use the KSharedConfigPtr provided
by KWin. Thus in e.g. autotests we can use the general way to configure
the effects and don't need to write to the config.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D3383
2016-11-16 15:31:14 +01:00
James Pike 4730be084c Support for workspace.clientList() in declarative script
Summary:
The version provided is only compatible with QtScript so it became
necessary to split WorkspaceWrapper into a base class and two child
classes, one for QtScript and one for QmlScript.

BUG: 340125
FIXED-IN: 5.8.4
REVIEW: D3185
2016-11-02 23:31:06 +00:00
Martin Gräßlin 142aab2e24 Introduce an EffectsHandler::animationsSupported -> bool
Summary:
A new method to tell the effects system whether the compositor scene
is able to drive animations. E.g. on software emulation (llvmpipe) it's
better to not do any animations at all.

This information can be used by effects to adjust their behavior, e.g.
PresentWindows could skip transitions or effects can use it in their
supported check to completely disable themselves.

As a first step all scripted effects are considered to be unsupported
if animations are not supported. They inherit AnimationEffect and are
all about driving animations.

The information whether animations are supported comes from the Scene.
It's implemented in the following way:
 * XRender: animations are always supported
 * QPainter: animations are never supported
 * OpenGL: animations are supported, except for software emulation

In addition - for easier testing - there is a new env variable
KWIN_EFFECTS_FORCE_ANIMATIONS to overwrite the selection.

Reviewers: #kwin, #plasma

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D2386
2016-08-15 17:38:33 +02:00
Marco Martin a104a4af7f try more aggressively to retarget
instead of deleting all animations when one is over,
try to retarget them all, and redo them only
if retargeting fails

REVIEW:127101
2016-02-26 10:28:47 +01:00
Thomas Lübking c9c86f29fb fix retargetting script export
pushed wrong branch, this fixes the wrong parameter count

REVIEW: 126981
2016-02-16 15:07:27 +01:00
Thomas Lübking 070b85bbcf export retarget to scripts 2016-02-16 13:59:22 +01:00
Marco Martin 5e6f0b8b4f make animate() return something JS understands
the result of animate is an array of animids: in order for
dumb QScript to understand what it is, we have to build it
as an actual JavaScript Array
reviewed-by: Martin Gräßlin <mgraesslin@kde.org>
2016-02-10 16:58:37 +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 bffbbce172 [scripting] Add dedicated logging category 2015-07-31 13:25:51 +02:00
Martin Gräßlin ca14073b54 Port scripted effect loading from KService to KPackage
Advantage: no more ksycoca cache for loading scripted effects.
2015-07-06 16:50:33 +02:00
Thomas Lübking 83a42c55be ScriptedEffect: gauss curve anim and ended signal
latter allows to chain actions in scripted effects
and former prevents the need to do that for a continuous
in/out animation
2015-04-07 23:59:18 +02:00
Thomas Lübking 060f3e9403 Remove AnimationData wrapper around metadata.
Instead allow to set metadata directly in animation
objects

REVIEW: 122679
2015-04-07 23:59:18 +02:00
Martin Gräßlin b7a8bb4f52 Drop build option KWIN_BUILD_SCREENEDGES
The build option got introduced for Plasma Active back in a time
when we did not properly aim for convergence. In a Plasma 5 world
we want to have only one shell and one window manager which adjust
itself. This means we don't want a differently compiled kwin for
plasma active, but the same one. Thus the build option doesn't
make much sense any more. A KWin for touch interface needs to support
screenedges for the case that mouse is plugged in.

CCBUG: 340960
REVIEW: 121200
2014-11-24 10:48:49 +01:00
Martin Gräßlin 3bbc9436db [kwin] Add a virtual Effect::requestedEffectChainPosition
This method replaces the X-KDE-ORDERING property in the Effect's desktop
files. This change is a preparation step for integrating the new Effect
Loader which doesn't read the ordering information. Thus it needs to be
provided by the Effect itself so that the EffectsHandler can properly
insert it into the chain.

Also for the built-in Effects on the long run it doesn't make much sense
to install the desktop files. And binary plugin effects will migrate to
json metadata which also doesn't have the KService::Ptr. Thus overall it
simplifies to read this information directly from the Effect.
2014-03-28 14:04:54 +01:00
Martin Gräßlin 42ff5e0c08 [kwin] Move finding of scripted effect source file to ScriptedEffect
New ScriptedEffect::create(KService::Ptr). This is a preparation for
adding the ordering directly to the Effect.
2014-03-28 14:04:54 +01:00
Martin Gräßlin ba12fe3cc0 [kwin] Add a ScriptedEffectLoader
This implementation of the AbstractEffectLoader is able to to load the
scripted KWin Effects. It uses KServiceTypeTrader to find all the
candidates to load.
2014-03-28 14:04:54 +01:00
Martin Gräßlin 77fff7af6a [kwin] Port away from deprected KCoreConfigSkeleton::readConfig
Most is just switched to the ::read(). That should be enough for all the
Effects which have a KSharedConfig::Ptr underneath. If not we just need
to find a good place to put the reload.
2014-03-25 16:29:03 +01:00
Aleix Pol c72e519d9c Remove KDE/ prefix in include directories
It's unneeded and deprecated since KF5.
2014-03-17 16:24:10 +01:00
Martin Gräßlin 3f0ff9b8d5 Migrate effects from displayWidth()/displayHeight() to virtualScreenSize()/virtualScreenGeometry()
Rational behind this change is that displayWidth and displayHeight are
X specific API calls in kwinglobals. For the future it's easier to only
rely on functionality which goes through the EffectsHandler API which
allows easier adjustments in KWin core.

displayWidth() and displayHeight() are only used to get the size or the
complete rect of all screens. This is also provided by:

effects->virtualScreenGeometry() or
effects->virtualScreenSize()

REVIEW: 116021
2014-03-07 08:01:44 +01:00
Matteo De Carlo c01446583e Replace NULL with nullptr in scripting folder
Replacing all NULL to nullptr in all the files in scripting folder
(also substituting some "0" used as nullptr with nullptr)

REVIEW: 115915
2014-02-24 16:33:40 +01:00
Mihail Ivchenko ba2ff9757d [kwin/scripting] Port from Plasma::ConfigLoader to KConfigLoader
REVIEW: 114492
2013-12-16 11:50:37 +01:00
Martin Gräßlin 57905c0cc2 And we got rid of KDebug
Usages of kBacktrace got dropped.
2013-09-02 13:14:39 +02:00
Anselmo L. S. Melo d97069590a Porting kwin scripting to Qt5/KF5: QStandardPaths
REVIEW: 111974
2013-08-13 17:55:25 -03: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 3faecf5075 fix effect script parsing
REVIEW: 109987
2013-04-16 22:07:07 +02:00
Thomas Lübking 77bcadc5b4 export AnimationEffect::set and ::cancel to script
Also harmonize script parsing - any combination of animationarray
and global animation setting that results in a valid animation is
possible using the global settings as default on the array values

REVIEW: 109212
2013-03-28 19:47:30 +01:00
Martin Gräßlin 3aa7cd3f97 Fix incorrect include order 2013-03-07 13:50:08 +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
Martin Gräßlin d9d9aad674 Use Plasma::ConfigLoader to read config values in scripted effects
Advantage is that the default value is no longer needed and scripted
effects are anyway supposed to add a kconfigxt file.
2013-03-04 10:29:24 +01:00
Martin Gräßlin 7a7f9d1a34 Change the way how screen edges interact with Effects/Scripts
The main difference is that the activation of an edge is no longer
broadcasted to all effects and scripts, but instead a passed in slot of
the Effect/Script is invoked.

For this the EffectsHandler API is changed to take the Effect as an
argument to (un)reserveElectricBorder. As callback slot the existing
borderActivated is used.

In addition the ScreenEdge monitors the object for beeing destroyed and
unregisters the the edge automatically. This removes the need from the
Effect to call unregister in the dtor.

BUG: 309695
FIXED-IN: 4.11
2013-02-07 09:46:52 +01:00
Martin Gräßlin d9aedf620b Rewrite of KWin's Screen Edge Handling
This rewrite is mostly motivated by the need to handle multi screen
setups correctly. That is have edges per screen and not for the combined
geometry. Also porting from XLib to XCB has been a motivation for the
rewrite.

The design of the new ScreenEdge handling is described in the
documentation of ScreenEdges in screenedge.h.

In addition the following changes have been performed:
* move configuration from Options to ScreenEdge
* add screen edge information to Workspace::supportInformation (obviously
  replaces what had been read from Options)
* have Workspace hold a pointer to ScreenEdges instead of an object
* forward declaration of ScreenEdges in workspaces.h, this explains the
  seemingly unrelated changes of just another include in some files

BUG: 290887
FIXED-IN: 4.11
2013-02-07 09:46:52 +01:00
Martin Gräßlin 85d2f1cb61 Export QEasingCurve to scripted Effects
That allows reference QEasingCurve::Type to be used in the animate
functions.

REVIEW: 107265
2012-11-24 10:19:59 +01:00