Commit graph

84 commits

Author SHA1 Message Date
Martin Gräßlin
d0c488f4a2 Announce output changes to Wayland for platforms not handling outputs
Summary:
Most platforms like the nested and virtual do not handle the outputs
themselves and WaylandServer announces the Outputs to Wayland.

So far this was static: at startup it got announced once to Wayland
and any changes were not catched.

This change makes WaylandServer listen to changes to the Screens and
sync them to Wayland.

Unfortunately KWin's internal Screen information is not sufficient to
properly synchronize this to Wayland and also Wayland by not supporting
adding/removing modes does not help.

Thus the solution implemented here is to add new outputs reflecting the
changes and then removing the old ones. This creates situations with more
outputs being present than actually there, but prevents that there are
no outputs at all.

Test Plan: Auto test added which verifies this for the virtual platform

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D2233
2016-07-20 13:53:02 +02:00
Martin Gräßlin
c3af4c3f9c Add support for xdg-shell version 5 interface
Summary:
The WaylandServer creates the XdgShellV5 interface and hooks it up
to create a ShellSurface whenever an xdg surface or xdg popup is created.

ShellClient gains some new ctors for the different variants and is
adjusted to delegate to xdg surface respectively.

With this change KWin mostly supports xdg-shell protocol. Still missing
is support for the "geometry" request which is rather difficult to
implement in KWin.

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D2108
2016-07-13 13:20:00 +02:00
Martin Gräßlin
445335ba5f Merge signal connections for AbstractClient in Workspace
Summary:
Have one dedicated method which performs the connection for both
Client and ShellClient. This fixes the desktopPresenceChanged signal
not being passed to the effects.

Note that not all signals are merged. Most signals setup for Client
don't make sense for ShellClient as ShellClient cannot block composite
or unredirect.

Test Plan:
Test case added for ShellClient to ensure that the signal
is correctly invoked on the ShellClient, Workspace and EffectsHandler.

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D2059
2016-07-13 10:44:34 +02:00
Martin Gräßlin
3c04d5295d Handle situation of no XDG_RUNTIME_DIR gracefully
Summary:
If KWin fails to start the Wayland server due to XDG_RUNTIME_DIR not
being set, kwin_wayland should terminate with an error condition but
not crash.

This change makes sure that KWin detects that the Wayland server does
not work and terminates the startup early and ensures that it doesn't
crash while going down.

An error message is shown that we could not create the Wayland server.

Test Plan:
Test case added which verifies that WaylandServer fails to
init. Manual testing that kwin_wayland exits with error 1.

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D2078
2016-07-13 10:00:46 +02:00
Martin Gräßlin
3493e97655 Support for syncing the clipboard from X11 to Wayland and vice versa
Summary:
The clipboard sync is done by a dedicated helper binary launched by
KWin. This helper binary is forced to xcb platform to piggy-back on
Qt's implementation of the X11 clipboard. In addition it implements
the Wayland clipboard - which is much simpler. Reading the Wayland
clipboard is based on the implementation in QtWayland.

KWin internally knows the DataDeviceInterface belonging to the helper
application. Whenever an xwayland client is focussed, this DataDevice
is allowed to set the selection and KWin manually updates the current
selection in the SeatInterface. By that the sync from X11 to Wayland
is implemented. When afterwards a Wayland client is selected, it's sent
the current selection which references the X clipboard and a data
transfer can be initiated in the normal Wayland way.

For the other direction KWin sends the current selection to the helper's
DataDevice whenever an xwayland window is focused. The helper application
reads the Wayland clipboard and sets it on the X11 clipboard. Thus the
Wayland clipboard is synced to X11.

The approach used here will also be useful for implementing a clipboard
manager (aka klipper).

Currently the implementation is not yet fully completed. We need to
make sure that the helper application gets restarted in case of a crash.

Test Plan: See added test case

Reviewers: #plasma_on_wayland, #kwin

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D1973
2016-06-29 09:03:40 +02:00
Martin Gräßlin
7818a1fa9c Set internal ClientConnection to null after destroying it
Bshah hit a strange crash which I can only explain by the variable
not being set to null after destroying.
2016-06-14 16:42:52 +02:00
Martin Gräßlin
c7828eab8f Ensure that WaylandServer::shellClientAdded only gets emitted once
Summary:
When a shell client got mapped, unmapped and mapped again we emitted
the shellClientAdded signal in WaylandServer again. This resulted in
e.g. Workspace, EffectsHandler, etc. to start managing the window again.
This can be a reason for problems we see with such windows like the
Plasma panel dialog when opened the second time.

Test Plan:
Needs extensive testing on real world system as that changes
behavior now.

Reviewers: #kwin, #plasma_on_wayland

Differential Revision: https://phabricator.kde.org/D1784
2016-06-14 07:36:33 +02:00
Sebastian Kügler
a5189cc393 Actually create the outputmanagement interface
Summary: It's instantiated, but never created. This means that libkscreen's wayland backend is going to hang initializing.

Test Plan: Ran libkscreen against it, works with and doesn't work without patch.

Reviewers: graesslin, #plasma

Reviewed By: graesslin, #plasma

Subscribers: plasma-devel

Projects: #plasma

Differential Revision: https://phabricator.kde.org/D1524
2016-05-03 01:10:10 +02:00
Martin Gräßlin
319869881c Connect Application::screensCreated to WaylandServer::initOutputs
Summary:
Instead of having the Application invoke initOutputs after creating
the Screens, we can just connect to the signal emitted there.

This allows to make initOutputs a private, WaylandServer internal
method.

Reviewers: #plasma

Subscribers: plasma-devel

Projects: #plasma

Differential Revision: https://phabricator.kde.org/D1482
2016-05-02 15:52:07 +02:00
Martin Gräßlin
f8f8e61466 Make integration with KScreenLocker optional in WaylandServer
Summary:
In order to start the WaylandServer in kwin_x11 we need to make sure
that WaylandServer does not start the KScreenLocker integration. On
X11 the lock screen is provided by a different application (in Plasma
by ksmserver).

A new init flag is added to WaylandServer to not integrate with
KScreenLocker. Thus the default is still to integrate with KScreenLocker.

All direct usages of KScreenLocker are guarded to not be called if
the screenlocker integration is not present.

Reviewers: #plasma

Subscribers: plasma-devel

Projects: #plasma

Differential Revision: https://phabricator.kde.org/D1481
2016-05-02 15:51:19 +02:00
Martin Gräßlin
e64450c807 Merge branch 'Plasma/5.6' 2016-04-26 13:13:17 +02:00
Martin Gräßlin
6d60f01ad9 Skip DontCrashEmptyDecorationTest if we don't have a /dev/dri/card0 device
Without the /dev/dri/card0 mesa fails to initialize egl and the test
fails. In order to silence the failure till the system provides the
device file, we better skip the test.

A nullptr crash in that case is fixed in WaylandServer tear-down.
2016-04-26 12:47:02 +02:00
Martin Gräßlin
d31e9e88b4 Rename abstract_backend.(h|cpp) to platform.(h|cpp)
Reviewers: #plasma

Subscribers: plasma-devel

Projects: #plasma

Differential Revision: https://phabricator.kde.org/D1340
2016-04-07 16:18:12 +02:00
Martin Gräßlin
1d4cd55b9d Drop backend() -> AbstractBackend* from WaylandServer
No longer needed, provided through Application::platform().

Reviewers: #plasma

Subscribers: plasma-devel

Projects: #plasma

Differential Revision: https://phabricator.kde.org/D1339
2016-04-07 15:00:11 +02:00
Martin Gräßlin
7996d954c5 Provide the platform() -> AbstractBackend* in KWin::Application
Summary:
This is the first change in a refactoring series. The aim is to:
* rename AbstractBackend to Platform
* move backends/ to plugins/platforms/
* don't bind platforms to Wayland only
* provide a platform plugin for "normal" X11
* share more code between X11 and Wayland

This change moves the platform/backend from waylandServer to Application.
The init of the plugin happens directly in the Application from the
KPluginMetaData. There is no need to externally init it and set the
parent.

WaylandServer::backend() currently just delegates to
kwinApp()->platform(), the idea is to drop this method completely.

The test infrastructure is also adjusted to this change.

Test Plan: kwin_wayland still works, all tests pass

Reviewers: #plasma, sebas

Subscribers: plasma-devel

Projects: #plasma

Differential Revision: https://phabricator.kde.org/D1331
2016-04-07 08:00:12 +02:00
Martin Gräßlin
8d851a0252 Announce support for subcompositor protocol
Reviewers: #plasma

Subscribers: plasma-devel

Projects: #plasma

Differential Revision: https://phabricator.kde.org/D1282

BUG: 361403
2016-04-07 07:59:28 +02:00
Sebastian Kügler
d8a3e0525f First part of outputmanagement wayland interface
This patch implements read access to the outputmanagement interface in
kwin_wayland's drm backend.

- outputdevices are created in DrmOutput, just like the wl_outputs
- wayland_server implements the outputmanagement interface and
- passes the changesets down into the backend

This means that the interface is announced, independently of the DRM
backend, but the actual outputs are currently only there if the DRM
backend is used.

The changes are not applied (passed into the kernel's drm interface
yet). This is obviously work-in-progress, so it's incomplete. Since it
allows us to run kwin[master] with the libkscreen KWayland backend, it's
a significant step allowing testing and further development.

Reviewed-by: Martin Gräßlin
2016-03-10 19:57:07 +01:00
Martin Gräßlin
2b34f97344 Always notify lock screen when a lock surface got created
WaylandServer considers AcquiringLock already as locked thus we
never notified KSldApp about the added window.

Reviewed-By: Bhushan Shah
2016-02-16 12:53:58 +01:00
Martin Gräßlin
ed3f55b953 [wayland] Fix heap-use-after-free in idle time plugin
We need to also destroy all idle objects when we tear down the
internal client connection. Otherwise the cleanup tries to free
the object after our Wayland connection is already destroyed.
2016-02-02 12:00:12 +01:00
Martin Gräßlin
b5cbca3617 Also consider the AcquiringLock state as a locked screen
KSld goes to state AcquiringLock when starting the greeter process.
During this state it expects the input to be grabbed. So from KWin
perspective this means that the screen is locked and KWin should
filter out input events.
2016-02-02 10:19:46 +01:00
Martin Gräßlin
5cef26d275 [wayland] Add support for ServerSideDecorationManager
We announce support for it and depending on whether we have a plugin
or not set the default mode to Server or None.

When a decoration interface is created it gets installed on the
ShellClient. But there it isn't properly used yet as we don't have
support for decorations in ShellClient yet.
2015-12-18 16:41:49 +01:00
Martin Gräßlin
e2dc6380d1 [wayland] Pass processStartupEnvironment to ScreenLocker
Need to pass a proper env to ScreenLocker to ensure we don't mess
with the greeter's environment by e.g. unsetting QT_IM_MODULE or
setting EGL_PLATFORM.

Reviewed-By: Bhushan Shah
2015-12-04 16:09:47 +01:00
Martin Gräßlin
8b4d1a2f3f [wayland] Properly set position of OutputInterface on creation
Before all outputs were positioned at 0/0 in a multi-nested window
setup.
2015-11-26 08:33:07 +01:00
Martin Gräßlin
3be016fba4 [wayland] Destroy all ClientConnections on tear down
Ensures that all Wayland objects are destroyed and the cleanup handling
is performed before tearing down the Compositor. This fixes for example
a crash if a Surface with a Shadow is still around at tear down.
2015-11-18 10:29:10 +01:00
Bhushan Shah
450bbaafdc [wayland] Introduce property to identify lockscreen and inputmethods
This introduces Toplevel::isLockScreen() and Toplevel::isInputMethod(),
this can be used to allow only lockscreen/inputmethods to get input
events and shown when screen is locked.
2015-11-16 15:49:38 +05:30
Martin Gräßlin
fa6fbbdfc1 [wayland] Destroy input method connection after process finished
More cleanup.
2015-11-10 14:38:45 +01:00
Martin Gräßlin
0bf51d99f6 [wayland] Destroy our internal wayland connection from server side
More cleanup.
2015-11-10 14:27:43 +01:00
Martin Gräßlin
affcbac7e7 [wayland] Destroy Xwayland's ClientConnection on tear down
We need to destroy the ClientConnections we create. Also we need
to disconnect our Xwayland error handling before destroying it, otherwise
it would trigger the abort for crashing Xwayland.
2015-11-10 14:21:48 +01:00
Martin Gräßlin
acb0dfd893 [wayland] Don't leak our internal client connection thread object
Thanks ASAN!
2015-11-10 11:43:30 +01:00
Martin Gräßlin
8175562a7a [wayland] Fix cleanup handling on tear down
ASAN righly complained: we need to delete our Wayland objects before
we destroy the internal client connection. Solved by better setting
parent relationships in the QPA plugin and correctly delete objects
in destroy of internal client connection.
2015-11-10 11:35:00 +01:00
Martin Gräßlin
1998d5ac1a [wayland] Improve tear-down to not crash if X11 applications are still around
We need to destroy the compositor after Xwayland terminated and after
the internal Wayland connection is destroyed. This means when destroying
the Workspace we may no longer destroy the Compositor at the same time.
Also we need to ensure that other tear down functionality doesn't call
into the no longer existing internal client connection.

With this change kwin doesn't crash when exiting with Wayland and/or
X11 windows still open.
2015-11-10 08:56:32 +01:00
Bhushan Shah
6e70dd0ba2 [wayland] connect to greeterClientConnectionChanged instead of locked signal
locked signal might be too late to identify the greeter and its windows.
2015-11-09 14:15:04 +05:30
Bhushan Shah
3a1371989e [wayland] Introduce ShellClient::isLockScreen method
This allows to check if specific ShellClient is from LockScreen or not,
as well as this adds method to verify if ShellClient is from input
method like maliit.

Now that KWin knows about which window is from Screenlocker it can apply
various security restrictions like no other window then greeter is on
top of it.

Reviewed-By: Martin Gräßlin
2015-11-06 19:44:13 +05:30
Bhushan Shah
c957b145a4 [wayland] Adapt to changes in the kscreenlocker
Initialize is no longer called by KSldApp ctor, and also pass
KWayland::Server::Display* to KSldApp.

Reviewed-By: Martin Gräßlin
2015-11-06 16:53:20 +05:30
Bhushan Shah
bacfd876fe [wayland] Start ksldapp from the WaylandServer
This introduces --lockscreen option in kwin_wayland which when used will
lock screen immediately. Also dependency to newly created kscreenlocker
repo is introduced.

REVIEW: 125954
2015-11-05 18:39:23 +05:30
Martin Gräßlin
7253235a28 [wayland] Dispatch the WaylandServer once more before killing internal client
This is needed to not deadlock during tear down in case the client wants
to dispatch events and the server is in wait for client.
2015-10-22 10:07:02 +02:00
Martin Gräßlin
43f6c1e041 [wayland] Add support for DpmsInterface
Our server announces the DpmsManagerInterface and in the DRM backend
we announce support for Dpms on the OutputInterface (if the Output
supports it) and we connect to changing Dpms requests.
2015-09-10 14:32:41 +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
Martin Gräßlin
9afbecf4a6 [wayland] Drop workaround for faking frame rendered for Qt windows
No longer needed with our own QPA plugin.
2015-08-25 14:33:51 +02:00
Martin Gräßlin
8add14fe89 [wayland] Drop hack for faking input for Qt popups
This reverts 29c2ae57.
2015-08-25 14:33:51 +02:00
Martin Gräßlin
e0103b15b7 [wayland] Remove the specific socket pair for QtWayland
Our own QPA plugin shares the internal connection, so we don't need the
dedicated connection for the QPA any more.
2015-08-25 14:33:50 +02:00
Martin Gräßlin
9272d01a2d Add a WaylandServer::findClient which takes a QWindow
Of course only works with internal clients.
2015-08-25 14:33:50 +02:00
Martin Gräßlin
a9e5343eb6 [wayland] Use an event thread for the internal Wayland connection 2015-08-25 14:33:50 +02:00
Martin Gräßlin
6294961ba4 [wayland] Keep Registry for internal connection around
Allows to interact with the Registry for the internal connection in
other parts of KWin and makes it possible to create more than just the
ShmPool for this Registry.
2015-08-25 14:33:50 +02:00
Martin Gräßlin
df1146bfa6 [wayland] Shadow gains support for a Wayland protocol
For Wayland clients we now are able to get shadows.

Internally this reuses large parts of the X11 implementation. This
could be improved to make the Scene's better aware of the Wayland
shadow, so that less memory is needed.
2015-07-15 11:25:16 +02:00
Martin Gräßlin
282321bfb5 [wayland] Announce support for idle interface 2015-07-09 10:10:58 +02:00
Martin Gräßlin
72635101f0 [wayland] Improve creation of KWayland::Server::PlasmaWindowInterface
The creation of PlasmaWindowInterface is moved from WaylandServer into
AbstractClient. This allows the sub classes to better control when to
create/destroy the Client.

For creation it's bound to becoming visible - that is Windows which are
only created but never shown are not announced at all.

For Client it's destroyed with the normal tear-down of a Client, for
ShellClient it's destroyed on unmapped (which also means a new one
will be created again in case of another mapping of the surface).

As a side effect, this works around the problem that ShellClients do not
yet get destroyed for QtWayland's menus (needs further investigation).
2015-07-09 09:10:33 +02:00
Martin Gräßlin
085c77810b [wayland] Create PlasmaWindow as child of AbstractClient
Ensures that the PlasmaWindow gets destroyed together with the window.
Note: when a ShellClient gets unmapped the PlasmaWindow does not yet
get destroyed. It should probably get destroyed and recreated on next
mapping.
2015-06-29 10:09:15 +02:00
Martin Gräßlin
8b6fef457b [wayland] Export themed icon name to PlasmaWindow interface
If the icon doesn't have a name, we pass the generic xorg icon. Most
likely our xwayland clients won't have a theme name, so giving them
the xorg icon seems a good enough work around. If we would want to
pass the real icon for xwayland clients we would need a way to
serialize them which seems like quite some needless overhead for legacy
applications. Can be considered for the future nevertheless.
2015-06-20 02:48:48 +02:00
Martin Gräßlin
69d78fe8db Fix unused variable warning 2015-06-20 00:12:22 +02:00