Commit Graph

31 Commits (master)

Author SHA1 Message Date
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
Aleix Pol 3a9d7a6e9d Port KWin to KWaylandServer
Summary: Away from KWayland::Server and KF5WaylandServer.

Test Plan: Builds, ran nested session

Reviewers: #kwin, #plasma, #frameworks, davidedmundson, zzag

Reviewed By: #kwin, #plasma, davidedmundson, zzag

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D29278
2020-04-30 12:56: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
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
David Edmundson 40b0296d5c [libkwineffects] Introduce API to easily show a QtQuick scene in an effect
Summary:
EffectQuickView/Scene is a convenient class to render a QtQuick
scenegraph into an effect.

Current methods (such as present windows) involve creating an underlying
platform window which is expensive, causes a headache to filter out
again in the rest of the code, and only works as an overlay.

The new class exposes things more natively to an effect where we don't
mess with real windows, we can perform the painting anywhere in the view
and we don't have issues with hiding/closing.

QtQuick has both software and hardware accelerated modes, and kwin also
has 3 render backends. Every combination is supported.

* When used in OpenGL mode for both, we render into an FBO export the
texture ID then it's up to the effect to render that into a scene.

* When using software QtQuick rendering we blit into an image, upload
that into a KWinGLTexture which serves as an abstraction layer and
render that into the scene.

* When using GL for QtQuick and XRender/QPainter in kwin everything is
rendered into the internal FBO, blit and exported as an image.

* When using software rendering for both an image gets passed directly.

Mouse and keyboard events can be forwarded, only if the effect
intercepts them.

The class is meant to be generic enough that we can remove all the
QtQuick code from Aurorae.

The intention is also to replace EffectFrameImpl using this backend and
we can kill all of the EffectFrame code throughout the scenes.

The close button in present windows will also be ported to this,
simplifiying that code base.

Classes that handle the rendering and handling QML are intentionally
split so that in the future we can have a declarative effects API create
overlays from within the same context. Similar to how one can
instantiate windows from a typical QML scene.

Notes:
I don't like how I pass the kwin GL context from the backends into the
effect, but I need something that works with the library separation. It
also currently has wayland problem if I create a QOpenGLContext before
the QPA is set up with a scene - but I don't have anything better?

I know for the EffectFrame we need an API to push things through the
effects stack to handle blur/invert etc. Will deal with that when we
port the EffectFrame.

Test Plan: Used in an effect

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D24215
2019-09-27 16:11:05 +01: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
Martin Flöser 07e394fbb7 Fix unused param warning
Sorry for introducing them.
2019-01-27 14:03:53 +01:00
Martin Flöser 932ccb2ac3 Switch ThumbnailItem to internal uuid instead of WId
Summary:
So far the ThumbnailItem in TabBox mode used the window id for finding
the window it should render a thumbnail on. In the Wayland world this is
not unique. The window id could be either an X11 window or a wayland
window. We don't guarantee that there are no conflicting ids.

With the internal id we have a way to properly identify the windows, so
this element should use them.

To support this the property changed the type to QUuid and the
clientmodel also provides the QUuid. As in TabBox the way to get the
window is through the model this should be compatible for all themes.
It's tested and verified with the Breeze switcher.

For declarative KWin scripts the ThumbnailItem also provides the
AbstractClient as a property, so there should not be any script which
uses wid. If it does, this could break, but well the script should use
the intended API.

Test Plan: ctest passes, manual testing of Breeze alt-tab switcher

Reviewers: #kwin

Differential Revision: https://phabricator.kde.org/D18405
2019-01-27 09:52:15 +01:00
Martin Flöser 02a0561016 Add windowsystem plugin for KWin's qpa
Summary:
KWindowSystem provides a plugin interface to have platform specific
implementations. So far KWin relied on the implementation in
KWayland-integration repository.

This is something I find unsuited, for the following reasons:
 * any test in KWin for functionality set through the plugin would fail
 * it's not clear what's going on where
 * in worst case some code could deadlock
 * KWin shouldn't use KWindowSystem and only a small subset is allowed
to be used

The last point needs some further explanation. KWin internally does not
and cannot use KWindowSystem. KWindowSystem (especially KWindowInfo) is
exposing information which KWin sets. It's more than weird if KWin asks
KWindowSystem for the state of a window it set itself. On X11 it's just
slow, on Wayland it can result in roundtrips to KWin itself which is
dangerous.

But due to using Plasma components we have a few areas where we use
KWindowSystem. E.g. a Plasma::Dialog sets a window type, the slide in
direction, blur and background contrast. This we want to support and
need to support. Other API elements we do not want, like for examples
the available windows. KWin internal windows either have direct access
to KWin or a scripting interface exposed providing (limited) access -
there is just no need to have this in KWindowSystem.

To make it more clear what KWin supports as API of KWindowSystem for
internal windows this change implements a stripped down version of the
kwayland-integration plugin. The main difference is that it does not use
KWayland at all, but a QWindow internal side channel.

To support this EffectWindow provides an accessor for internalWindow and
the three already mentioned effects are adjusted to read from the
internal QWindow and it's dynamic properties.

This change is a first step for a further refactoring. I plan to split
the internal window out of ShellClient into a dedicated class. I think
there are nowadays too many special cases. If it moves out there is the
question whether we really want to use Wayland for the internal windows
or whether this is just historic ballast (after all we used to use
qwayland for that in the beginning).

As the change could introduce regressions I'm targetting 5.16.

Test Plan:
new test case for window type, manual testing using Alt+Tab
for the effects integration. Sliding popups, blur and contrast worked fine.

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D18228
2019-01-27 08:59:58 +01:00
David Edmundson f521d4bbe1 [wayland] add enter/leave virtual desktop API
Summary:
As setDesktop was changed to "move" this left unSetDesktop non-symetric.

This replaces it with explicit API to enter/leave.

This also moves new API to the new object based API rather than still
using ints.

Where numbers are used it has been tidied up so that desktop IDs are
uint, which should be used when we have a list of desktops.
int is used only when we have either a desktop ID or NET::OnAllDesktops
(-1)

Effects API cleared up to use this and use a set of x11 IDs, which
avoids any potential complications of handling add and removes any
ambiguity with what happens if you leave all desktops and such.

Test Plan:
testVirtualDesktops passes (with pending kwayland patch)
Moving a window in the desktop grid on X11 behaves
Moving a window in the desktop grid on wayland behaves

Reviewers: #kwin, zzag

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16704
2018-11-14 11:08:46 +00: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
Martin Gräßlin 857d8a9c37 Add a KSharedConfigPtr for kcminputrc to KWin::Application
Summary:
There are a few places where KWin needs to read values from kcminputrc.
As I need to add yet another one it makes more sense to properly
structure it like in other cases and have only one kcminputrc hold in
the application. This also allows to better mock the config values in
the integration tests.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D5540
2017-04-24 21:01:03 +02:00
Martin Gräßlin 2132b1e0c8 [effects] Use arg="true" in the kcfg files
Summary:
By changing all kcfg to have arg="true" we can pass in the same
KSharedConfigPtr into all effects. This allows to have fake config in
the tests and in the planned effect demo mode.

Also it means that we don't have to hardcode the name kwinrc into the
files. In the configs - where we cannot access the effectshandler - we
use the define KWIN_CONFIG which gets generated based on the compile
time arguments.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D3571
2017-04-15 10:03:34 +02:00
Martin Gräßlin e6aabf5b9f Add callback functionality for touch screen swipe gestures
Summary:
This is implemented through QActions following the general approach
inside KWin and not the older approach used by ScreenEdges for pointer
callback activation.

Test Plan: Extended auto test

Reviewers: #kwin, #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D5263
2017-04-07 16:16:34 +02:00
Martin Gräßlin 22c91df2ec Add support for global touchpad swipe gestures
Summary:
This change adds global touchpad swipe gestures to the
GlobalShortcutsManager and hooks up the swipe gestures as defined at the
Plasma Affenfels sprint:
 * swipe up: Desktop Grid
 * swipe down: Present Windows
 * swipe left: previous virtual desktop
 * swipe right: next virtual desktop

The main work is handled by two new classes: SwipeGesture and
GestureRecognizer. This is implemented in a way that it can be extended
to also recognize touch screen gestures and pinch gestures.

The SwipeGesture defines what is required for the gesture to trigger.
Currently this includes the minimum and maximum number of fingers
participating in the gesture and the direction. The gesture gets
registered in the GestureRecognizer.

The events for the gesture are fed into the GestureRecognizer. It
evaluates which gestures could trigger and tracks them for every update
of the gesture. In the process of the gesture tracking the
GestureRecognizer emits signals on the Gesture:
 * started: when the Gesture gets considered for a sequence
 * cancelled: the Gesture no longer matches the sequence
 * triggered: the sequence ended and the Gesture still matches

The remaining changes are related to hook up the existing shortcut
framework with the new touchpad gestures. The GlobalShortcutManager
gained support for it, InputRedirection and EffectsHandler offer methods
to register a QAction. VirtualDesktopManager, PresentWindows and
DesktopGrid are adjusted to support the gesture.

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel

Tags: #plasma_on_wayland

Differential Revision: https://phabricator.kde.org/D5097
2017-03-27 17:43:44 +02:00
Martin Gräßlin d38bce776f Add support for skip close animation to OnScreenMessage
Summary:
This change adds support for marking the OnScreenMessage as it should
skip close animation. The screenshot effect is adjusted to use the
on screen message instead of the custom effect frame.

Test Plan: Message window is not captured when taking screenshot

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D4091
2017-01-25 13:54:34 +01:00
Martin Gräßlin ab45659677 Add support for on-screen-message to kwineffects
Summary:
This adds support for the new on-screen-message support to the
kwineffects API and makes use of it in the colorpicker effect.

Not yet added to screenshot effect as for that we need support for
skip close animation on the on-screen-message window.

Reviewers: #plasma, #kwin

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D3803
2016-12-24 09:56:48 +01:00
Martin Gräßlin f9f7b84cb4 Add interactive position selection to screenshot screen under cursor
Summary:
A second interactive selection mode gets added to select a position on
the screen. This is handled by the same input event filter as for the
window selection. Just that instead of returning a window, it returns a
QPoint.

This allows to pick a point on the screen which we need to screenshot
the screen under the mouse cursor and in future for color picking.

The screenshot effect provides two new dbus methods to (interactively)
select a screen or fullscreen. This allows spectacle to screenshot the
(full) screen with still having the user in control.

Reviewers: #kwin, #plasma_on_wayland, bgupta

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3475
2016-11-25 07:38:37 +01:00
Martin Gräßlin 27376e39ef [effects] Add interactive window selection mode to ScreenshotEffect
Summary:
EffectsHandler gains a new method to startInteractiveWindowSelection
which just delegates to the one in Platform. That way a window can be
selected and returned to an Effect.

The screenshot effect makes use of this new functionality and provides
an interactive window screenshot mode which saves to a temporary file.
Note that this is not yet the variant intended for use in spectacle.

Test Plan: Took a screenshot on Wayland

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3367
2016-11-17 14:06:01 +01:00
Martin Gräßlin 346619aa36 Remove KWin::display from kwinglobals
Summary:
And finally nothing inside libkwineffects, libkwinglutils,
libkwinxrenderutils and kwineffect and kwin core uses KWin::display.
We are finally XLib free!

This change drops KWin::display and removes the include to QX11Info from
kwinglobals.h. And the libraries no longer need to link X11Extras.  Due
to that removal a few seeming unrelated changes are required to add the
include where needed and linkage to X11Extras.

The biggest change is to x11 platform plugin which still needs the
display and caches it in the Platform and passes it to various places in
a way that the code doesn't need to be adjusted.

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3337
2016-11-16 18:00:00 +01:00
Martin Gräßlin 4783e45ab7 [libkwineffects] Remove EffectsHandler::registerPropertyType
Summary:
There is no effect using this method. As it's X11 specific it should be
removed.

Internally the EffectsHandlerImpl still requires the method. Thus it's
moved into the private part.

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3297
2016-11-16 09:06:12 +01:00
Martin Gräßlin 3041b871ea [libkwineffects] Delete EffectsHandler::deleteRootProperty
Summary:
The method is not used by any Effect and is X11 specific, thus better
remove it for good.

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3298
2016-11-16 07:46:27 +01:00
Martin Gräßlin bedc01b108 [kwineffects] Add hide/show cursor to EffectsHandler
Summary:
The implementation delegates to the Platform to perform the actual
show/hide of the cursor image.

This replaces the implementation in the zoom effect which so far
directly interacted with xfixes to show/hide the cursor. This is now
provided by the x11/standalone platform. And due to this change the zoom
effect can now properly hide the cursor on platform DRM (wayland) as
well.

Test Plan: Zoom effect on Wayland hides the cursor

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3120
2016-10-31 11:47:20 +01:00
Martin Gräßlin ea52ef9e57 Add a PlatformCursorImage to Platform and EffectsHandler
Summary:
There are several effects (screenshot, zoom) which need access to the
cursor image and cursor hotspot. So far these effects used X11
unconditionally to get the cursor which obviously does not work on
Wayland.

This change adds a new class PlatformCursorImage to kwinglobals which
wraps what a cursor is (image and hotspot) and adds a new virtual method
to Platform to provide such a PlatformCursorImage. By default it's the
cursor image the Platform tracks. On X11/standalone platform this new
virtual method is overriden and provides a PlatformCursorImage from X11
using the code previously used in screenshot effect.

Screenshot effect and zoom are adjusted to use the new API instead of
X11.

Test Plan:
Zoom effect tested on Wayland, now gets the proper cursor icon.
X11 functionality not yet tested.

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3093
2016-10-20 07:51:49 +02: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 5a55727056 support the slide protocol
take and apply thhe informations from the wayland slide
protocol in the sliding popups effect

REVIEW:125120
2015-09-14 16:39:39 +02:00
Marco Martin 3f5bf65a9e Use the kwayland blur protocol in the blur effect
use the new blur protocol to fetch information about the
region of blur behind to apply to windows like Plasma::Dialog
REVIEW:125017
2015-09-02 14:43:44 +02:00
Michael Pyne 85d87297b0 Return false for a bool instead of nullptr.
Fixes compiler warning (error by default in gcc 5).

REVIEW:123077
2015-03-19 23:22:46 -04:00
Martin Gräßlin 4230a0d331 [effects] Get xcb_connection_t* and rootWindow through EffectsHandler API
So far the effects could just use the connection() and rootWindow()
provided by kwinglobals. Thus an internal detail from KWin core is
accessed directly.

To be more consistent with the rest of the API it's wrapped through the
EffectsHandler and with a convenient method in Effect.

The connection() is provided as xcbConnection() to free the very generic
name connection which could create confusion once we provide a wayland
connection to the Effects.

The rootWindow() is provided as x11RootWindow() to indicate that it is
for the X11 world.

REVIEW: 117597
2014-04-16 16:05:05 +02:00
Martin Gräßlin 0fd9a1eeee [kwin] Introduce a new Effect Loading mechanism
Effect loading gets split by the kind of effects KWin supports:
* Built-In Effects
* Scripted Effects
* Binary Plugin Effects

For this a new AbstractEffectLoader is added which will have several
sub-classes:
* BuiltInEffectLoader
* ScriptedEffectLoader
* PluginEffectLoader
* EffectLoader

The EffectLoader will be what the EffectsHandlerImpl is using and it just
delegates to the three other types of loaders. Thus the handler doesn't
need to care about the different kinds of effects. The loading is
supposed to be completely async and the EffectLoader emits a signal
whenever an Effect got loaded. The EffectsHandlerImpl is supposed to
connect to this signal and insert it into its own Effect management.
Unloading is not performed by the loader, but by the EffectsHandler.

There is one important change which needs to be implemented: the ordering
cannot be provided by the loader and thus needs to be added to the
Effects directly.

So far only the BuiltInEffectsLoader is implemented. It's not yet
integrated into the EffectsHandlerImpl, but a unit test is added which
tries to perform the various operations provided by the loader and the
BuiltInEffects. The test should cover all cases except the Check Default
functionality which is only used by Blur and Contrast effects. This
cannot be mocked yet as the GLPlatform doesn't allow mocking yet.
2014-03-28 14:04:54 +01:00