Commit Graph

125 Commits (fd702c3644f7d94327fae05f276ab3fbaac4f7c1)

Author SHA1 Message Date
Roman Gilg f7ff62e2e2 Lift output enablement into Platform
Summary:
This lifts the enablement code for outputs from the DRM backend to Platform
allowing other Wayland backends in the future to use this interface as well.

To do that we also create some helper functions on Platform level and have to
spill some KWayland classes into AbstractOutput what motivates a further split
of Platform into a Wayland child class like for AbstractOutput.

Test Plan: Disabled and enabled an output in DRM session.

Reviewers: #kwin

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D23545
2019-09-05 17:22:44 +02:00
Aleix Pol 5ed98f79e8 Fix warning text message 2019-09-05 16:47:13 +02:00
Roman Gilg 5cc626c102 Remove outputs handling alternative
Summary:
With f013a4369c, cd6b69a4d2, d960be4b3f and edb200f6bc all possible
backends of a Wayland session have been ported to using the internal functions
of AbstractWaylandOutput's for managing outputs.

This removes the alternative code path used before in these backends, what
simplifies the code and is also a prerequisite to removing the Screens global
in the future.

Reviewers: #kwin, apol, zzag

Reviewed By: #kwin, apol, zzag

Subscribers: apol, kwin

Tags: #kwin

Maniphest Tasks: T11459, T11098

Differential Revision: https://phabricator.kde.org/D23485
2019-08-28 15:00:39 +02:00
Aleix Pol f324776137 Allow blacklisting some wayland interfaces
Summary:
For some interfaces, we'll look at the X-KDE-Wayland-Interfaces property in the desktop file to see which interfaces are requested.
Requires D22570.

Reviewers: #plasma, #kwin, davidedmundson

Reviewed By: #plasma, #kwin, davidedmundson

Subscribers: fvogt, zzag, broulik, graesslin, davidedmundson, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D22571
2019-07-31 16:09:01 +02:00
Aleix Pol bb9a5e57a1 Implement the keystate protocol
Summary: Depends on D20191

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: davidedmundson, graesslin, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D20192
2019-06-22 12:34:06 +02:00
Vlad Zagorodniy e96da56f8c Fix tests
`client = new ShellClient(surface)` is most likely a leftover after a
merge conflict.
2019-02-22 03:00:44 +02:00
Martin Flöser 9b922f8833 Split out a dedicated InternalClient class
Summary:
Most of the functionality which is special to internal clients is moved
from ShellClient to InternalClient. As KWin's qpa is still bound to the
Wayland protocol InternalClient inherits from ShellClient. Due to that
some aspects in ShellClient are "weird". ShellClient still detects
whether it's an internal client and uses the variable m_internal to
capture the state. This is required as we cannot use the isInternal
method. Most of m_internal usage is in init which is called from
constructor of ShellClient. Thus it's not possible to call into virtual
methods of InternalClient.

Also some of the code is duplicated and some methods are temporarily
marked as virtual.

The next step will be to remove ShmBuffer for internal windows which
should decouple the two implementations further with the long term goal
of having InternalClient inherit AbstractClient directly.

Test Plan:
Run nested KWin, triggered outline (OpenGL case) and debug console (shm case).
InternalWindow unit test still passes.

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D18569
2019-02-21 18:51:25 +01:00
Roman Gilg 548978bfe1 [xwl] Drag and drop between Xwayland and Wayland native clients
Summary:
Building upon the generic X Selection support this patch establishes another
selection class representing the XDND selection and provides interfaces
to communicate drags originating from Xwayland windows to the Wayland
server KWin and drags originating from Wayland native drags to Xwayland.

For Wayland native drags KWin will claim the XDND selection as owner and
will simply translate all relevant events to the XDND protocol and receive
alike messages by X clients.

When an X client claims the XDND selection KWin is notified via the X protocol
and it decides if it allows the X drag to transcend into the Wayland protocol.
If this is the case the mouse position is tracked and on entering a Wayland
native window a proxy X Window is mapped to the top of the window stack. This
proxy window acts as a drag destination for the drag origin window and again
X messages will be translated into respective Wayland protocol calls. If the
cursor leaves the Wayland window geometry before a drop is registered, the
proxy window is unmapped, what triggers a subsequent drag leave event.

In both directions the necessary core integration is minimal. There is a single
call to be done in the drag and drop event filter through the Xwayland
interface class.

From my tests this patch facilitates drags between any Qt/KDE apps. What needs
extra care are the browsers, which use target formats, that are not directly
compatible with the Wayland protocol's MIME representation. For Chromium an
additional integration step must be done in order to provide it with a net
window stack containing the proxy window.

Test Plan: Manually. Auto tests planned.

Reviewers: #kwin

Subscribers: zzag, kwin, alexde

Tags: #kwin

Maniphest Tasks: T4611

Differential Revision: https://phabricator.kde.org/D15627
2019-02-19 13:09:18 +01:00
Roman Gilg 2776f829ef Remove X clipboard sync helper and rename its autotest
Summary:
With the gneric X selections infrastructure and clipboard support the X
clipboard sync helper utility can be removed. Also rename its autotest as it
tests the inner workings of the new mechanism since this mechanism was
introduced.

Test Plan: Autotest still passes under new name.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: graesslin, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D15063
2019-02-19 12:30:43 +01:00
Roman Gilg 6e08fb2fa5 [xwl] Generic X selections translation mechanism with Clipboard support
Summary:
In this patch an infrastructure is created to represent generic X selections
in a Wayland session and use them for data transfers between Xwayland windows
and Wayland native clients.

The central manager is the DataBridge class, in which Selection objects can be
created. This is hard-coded and such a Selection object persists until the end
of the session, so no arbitrary selections can be created on the fly. For now
the X Clipboard selection is supported, whose corresponding mechanism in the
Wayland protocol is just called Selection.

A Selection object listens for selection owner changes on the X side and for
similar events into the Wayland server interfaces. If a data provider is
available a selection source object is created by the Selection object. In case
data is requested on the other side, a data transfer is initialized by creating
a Transfer object. A Selection keeps track of all transfers and makes sure that
they are destroyed when they are finished or in case they idle because of
misbehaving clients.

The Clipboard class translates the X Clipboard via a proxy window. Selection
changes on the Wayland side are listened to through a new signal on the active
KWayland seat interface.

The previously used X clipboard syncer helper is disabled. The clipboard sync
autotest is changed to the new mechanism.

BUG: 394765
BUG: 395313

Test Plan: Manually and clipboard sync autotest.

Reviewers: #kwin

Subscribers: zzag, graesslin, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D15061
2019-02-19 12:24:27 +01:00
David Edmundson 7d10ab0fe7 [wayland] Drop Qt extended surface
Summary:
This is only relevant on Qt and when WlShell is used.
This was only the case before Qt5.10.

We will depend on Qt5.12 next release.
Static Qt builds which are that old typically wouldn't contain QtWayland

Test Plan: Compiles. Not used in tests

Reviewers: #kwin, graesslin

Reviewed By: #kwin, graesslin

Subscribers: graesslin, zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D18594
2019-01-30 01:00:41 +00:00
David Edmundson 4240c4af05 [wayland] Call ShellClient install interface methods consistently
Summary:
When we create a new Shellclient there may be a pending relevant
interface.

For every other case this is handled in WaylandServer, the class
responsible for attaching new interfaces at runtime.
The only exception is ServerSideDecorationInterface which is handled in
the ShellClient constructor.

This makes everything consistent.

No behavioural changes.

Test Plan: Ran unit tests

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D18592
2019-01-30 01:00:41 +00:00
Roman Gilg 4729a42c34 Name Wayland socket automatically when no socket name was specified
Summary:
Wayland provides functionality for servers to acquire an unused socket name
automatically. Do this through the recently added functionality in KWayland
in case no socket name was specified as an argument to KWin.

Test Plan: Manually, autotests pass.

Reviewers: #kwin, fvogt

Reviewed By: fvogt

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D18522
2019-01-25 13:38:54 +01:00
David Edmundson ac45977e9e [wayland] XdgDecoration Support
Summary:
Does something similar to our existing ServerDecoration, but based
around XDG Shell patterns and with a few subtle differneces.

We'll probably still need both in kwin for the forseeable future as GTK3
won't ever change from using the KDE Server Decoration.

Test Plan:
Relevant unit test. It's a bit simpler as spec states
toolkits must follow what the compositor configures if they
bind the interface.

Modified plasma-integration to remove ServerIntegration
(as Qt5.12 has native support) all my windows look and act the same.

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D17756
2019-01-01 17:53:48 +00:00
Martin Flöser a0b482cbab Introduce a command line option to disable any kind of global shortcuts
Summary:
This command line option is useful for KWin in embedded use case. That
is when KWin is just used as a compositor for one application instead of
a complete desktop environment. In such a setup global shortcuts are not
wanted and interfere with the application. E.g. one does not want Alt+F4
to close the window, that would render the system unusable.

This change introduces a command line option and disables the following
event filters and spies:
 * global shortcuts
 * modifier only shortcuts
 * terminate session
 * virtual terminal switching
 * screen edges

KGlobalAccel still gets inited, otherwise the (non-functional) binary
would be launched when KWin registers it's global shortcuts.

Test Plan:
New test added based on existing tests for the global
shortcuts, ctest passes

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D17304
2018-12-13 19:36:28 +01:00
Martin Flöser 543b6955d4 Add more debug output around starting the x clipboard syncer process
Summary:
Trying to get some more information on why the related test fails on
build.kde.org.

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16748
2018-11-08 08:44:43 +01:00
Martin Flöser e637d43211 Remove potential endless loop from XClipboardSyncTest
Summary:
We need to wait till the helper process created the datadevice. For this
we used a while loop. On build.kde.org the test gets stuck in this loop
and times out after 10 minutes.

This change introduces a dedicated signal and we just wait for it. So if
something fails we wait only 5 sec instead of endless. This should help
investigate why the test doesn't work on build.kde.org.

Test Plan: Test works locally

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16741
2018-11-07 20:10:32 +01:00
Martin Flöser 7221864cd2 Start xclipboard sync process from build dir if available
Summary:
The xclipboard sync test times out on build.kde.org as KWin is not
installed prior to running the tests. This is due to KWin not finding
the executable for the clipboard sync helper.

This change looks whether the binary exists in the same directory as
KWin's executable. If it exists it is started instead of the hardcoded
path in libexec.

Test Plan: Run the test and verified the correct binary is loaded

Reviewers: #kwin

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16732
2018-11-07 15:19:25 +01:00
David Edmundson 7e8facc3fd [wayland] Use the new plasma virtual desktop protocol
Summary:
implement virtual desktop support for Wayland.
use the new virtual desktop protocol from D12820
The VirtualDesktopManager class needed some big change in order
to accomodate it, which is where most changes are.
Other than that, it's mostly connections to wire up
VirtualDesktopsManager and VirtualDesktopsManagement(the wayland protocol impl)

Depends on D12820
Other notable detail, is the client visibility updated to reflect the presence
of the client in the plasmavirtualdesktop.
(and the unSetDesktop concept)

Test Plan: used a bit a plasma session together with D12820, D13748 and D13746

Reviewers: #plasma, #kwin, graesslin, davidedmundson

Reviewed By: #plasma, #kwin, davidedmundson

Subscribers: hein, zzag, davidedmundson, kwin

Tags: #kwin

Maniphest Tasks: T4457

Differential Revision: https://phabricator.kde.org/D13887
2018-11-01 16:35:29 +01:00
David Edmundson fcf9acfec5 Add XDG WmBase support
Test Plan:
Compiled latest GTK
Ran gtk4-demo and used WAYLAND_DEBUG to confirm it used the correct
shell
tested a top level and a popup

Reviewers: #plasma, romangg

Reviewed By: #plasma, romangg

Subscribers: romangg, mart, graesslin, zzag, kwin

Tags: #kwin
BUG: 398614
FIXED-IN: 5.15.0

Differential Revision: https://phabricator.kde.org/D13530
2018-09-14 12:18:47 +01:00
David Edmundson 1403fcf316 Add XDG Output support
Test Plan:
Very minimal expansion of unit tests which uses WaylandScreens
Wrote mini app to debug actual output of xdg-output for testing the DRM code

Main relevant user of this is xwayland > 1.20 which I don't have, so that
part remains untested

Reviewers: #plasma, graesslin

Reviewed By: #plasma, graesslin

Subscribers: romangg, graesslin, bshah, kwin

Tags: #kwin

Maniphest Tasks: T8501

Differential Revision: https://phabricator.kde.org/D12243
2018-05-18 14:16:13 +01:00
Martin Flöser 339a08de38 Acknowledge the server side deco mode in WaylandServer not ShellClient
Summary:
With GTK applications our code showed issues. With GTK the sequence for
a menu or dialog window is:
 1. create surface
 2. create server side decoration
 3. request csd
 4. create xdg_shell_surface

Which result in KWin to have the ServerSideDecoration object being
created before the ShellClient is created. The connect for mode changed
happens in ShellClient, which is too late to catch that the window
requested client side decoration. Thus KWin created a decoration about
things such as a menu.

This change moves the acknowledge of the mode to WaylandServer. As we
anyway always acknowledge the requested mode we can also do it there and
don't require ShellClient to be present. Thus when the ShellClient is
created the mode is properly reflected and no decoration is created.

BUG: 389117
FIXED-IN: 5.12.0

Test Plan: Played a lot with evince

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D9967
2018-01-23 16:58:33 +01:00
Martin Flöser b002b27903 Simulate user activity on fake input events
Summary:
This ensures that using KDE Connect to control input properly inhibits
idle timeouts.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D9555
2018-01-10 17:43:42 +01:00
David Edmundson 01d6878dc2 Add explicit protocol for colour scheme management
Summary:
To replace the deprecated/broken qt extended surface

BUG: 385214

Test Plan: Ran test in plasma-integration

Reviewers: #plasma, graesslin

Reviewed By: #plasma, graesslin

Subscribers: plasma-devel, kwin, #kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D9660
2018-01-04 18:32:18 +00:00
Martin Flöser a561f91d29 Add missing include
Fix build.
2017-12-27 09:50:39 +01:00
David Edmundson ee28104c7a Port to new AppMenu iface
Plus test

Test Plan:
Ran kwin with menus and patched QPT
Ran test

Reviewers: graesslin

Reviewed By: graesslin

Subscribers: graesslin, kwin, #kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D9262
2017-12-22 14:38:31 +00:00
Martin Flöser ff2e883469 Add support for new IdleInhibition protocol
Summary:
A small helper class is added which manages inhibiting idle for the
ShellClients. So far only very basic functionality is added. That is
only the inhibition on the Surface is followed. It is not yet checked
whether the ShellClient is visible at all. That needs some changes in
ShellClient.

BUG: 385956
FIXED-IN: 5.12

Test Plan: New test case passes

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D8856
2017-11-30 21:51:36 +01:00
Martin Flöser 02d3daf28a Add physicalSize to the Screens API
Summary:
Allows to share the implementation in a better way and is a requirement
to get the Screen implementation in the QPA plugin to be based on
KWin::Screens instead of KWayland::Output.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D8344
2017-10-19 18:02:32 +02:00
Martin Flöser 6b8943bddd Fix new unused variable warning 2017-10-16 17:17:15 +02:00
Marco Martin 735fcc6e95 Make use of foreign protocol
Summary:
not sure if that is the right "parent" that has
to be set, set the transient for surfaces that
have setParentOf of an imported set

Test Plan:
m_XdgForeign->transientFor(surface()) finds the surface is expected,
not sure how to test it further

Reviewers: #plasma, graesslin

Reviewed By: #plasma, graesslin

Subscribers: luebking, graesslin, davidedmundson, plasma-devel, kwin, #kwin

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D7521
2017-10-13 11:32:22 +02:00
Martin Flöser 4c334098f3 Ensure internal Wayland connection is properly setup before creating LockScreen integration
With the new Wayland only mode we start too fast and it can happen that
the initWithWorkspace is called before the client connection is fully
setup. This would result in a crash in the idletime plugin once it tries
to create a seat.

To prevent this problem the code is split out into a dedicated method
and only invoked if all interfaces have been announced on the internal
connection.
2017-09-30 16:33:45 +02:00
David Edmundson e492f9e298 XdgV6 - Kwin side
Summary:
Adds XDGV6 support for the kwin side.

Popup placement support is limited to the stuff v5 had,
a simple offset, rather than the awesome new positioner.

But Qt doesn't make use of it yet either.
Also ideally we should do all the positioning before sending the first
configure, but again Qt doesn't actually do anything with that anyway.

Also integrate pinging clients

Test Plan: gtk3-demo  works nicely.

Reviewers: #plasma, graesslin, mart

Reviewed By: #plasma, graesslin

Subscribers: mart, graesslin, kwin, plasma-devel, #kwin

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D6591
2017-09-25 16:47:30 +01:00
Martin Flöser 06433997e8 Emit connectionDied on all Wayland connections of plugins on teardown
Summary:
Some libraries loaded into KWin (e.g. breeze) also have a Wayland
connection. If KWin destroyes it's own Wayland connection before the
libraries destroy theirs, KWin might crash on tear down when the
libraries call into libwayland with an invalid connection.

This change requires D6569 in KWayland.

Reviewers: #kwin, #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D6571
2017-07-28 20:30:54 +02:00
David Edmundson fd58c68ba5 Set wayland output scale
Summary:
Provides a virtual method in Screens where backends can supply the scale
of each screen, this is then set on each output.

For the X windowed backend this value is taken from a command line
parameter.

Test Plan:
Ran windowed mode with --scale 1 and 2
then kate --platform=wayland from another screen.
On the latter case UI elements were scaled up correctly

Reviewers: #plasma

Subscribers: plasma-devel, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D3159
2017-03-29 20:53:22 +01:00
Martin Gräßlin 8edd0336e6 Support creation of PlasmaShellSurface prior to ShellSurface
Summary:
So far KWin did not support the sequence:
1. Create wl_shell
2. Create PlasmaShellSurface
3. Create wl_shell_surface

KWin only supported the case that the PlasmaShellSurface is the last
thing to get created. This is rather limiting and can be considered a
bug. At least we had a QEXPECT_FAIL auto test for this situation. So
it was a known issue.

This change should make it easier to support the QtWayland changes in
Qt 5.8.

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D4482
2017-02-07 19:26:36 +01:00
Martin Gräßlin a7f5c16754 Reduce code-duplication of socketpair in WaylandServer
Summary:
WaylandServer creates a socketpair for several Wayland connections. So
far this duplicated code quite a bit.

This change introduces one method to perform the socketpair and the
error checking plus creating the server side ClientConnection from the
pair.

Test Plan: Tests still pass

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3576
2016-12-17 09:47:55 +01:00
Martin Gräßlin 0c5ca405cc Implement support for pointer constraints
Summary:
There are two types of constraints supported:
1. Pointer confinement
2. Pointer locking

In the case of confinement the pointer is confined to a given region of
the surface. This is comparable to general operation where the pointer
is confined to the screen region.

In the second case the pointer gets locked. That means it cannot move at
all. No further position updates are provided, only relative motion
events can go to the application. There is a hint about cursor position
update on unlock which is not yet implemented in KWayland::Server, thus
also not in this change.

The implementation in KWin grants the requests for pointer constraints
when the pointer enters the constrained region, either by pointer
movement or by e.g. stacking order changes. There is no confirmation
from user required to enter that mode. But we want to show an OSD when
the pointer gets constrained, this is not yet implemented, though.

Breaking an active constraint is relatively easy. E.g. changing the
stacking order will break the constraint if another surface is under the
cursor. Also (in case of confinement) moving the pointer to an
overlapping window breaks the confinement. But as soon as one moves the
pointer back to the window a constraint might get honoured again.

To properly break there is a dedicated event filter. It listens for a
long press of the Escape key. If hold for 3sec the pointer constraint is
broken and not activated again till the pointer got moved out of the
window. Afterward when moving in the pointer might activate again.

The escape filter ensures that the key press is forwarded to the
application if it's a short press or if another key gets pressed during
the three seconds. If the three seconds way fires, the later escape
release is not sent to the application.

This basic interaction is also ensured through an added auto test.

This change implements T4605.

Test Plan: Added auto test and nested KWin Wayland with D3488

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3506
2016-12-08 19:50:24 +01:00
Martin Gräßlin b6af777230 Forward pointer gestures to Wayland server
Summary:
This change implements forwarding the pointer gestures to the new API in
SeatInterface.

While screen is locked no gestures are forwarded to the server. Also
locking the screen cancels any active gesture. Similar if areas inside
KWin would start to intercept the gestures, they need to be cancelled on
the Wayland SeatInterface.

Test Plan: Not yet

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D3174
2016-11-07 13:45:08 +01:00
Martin Gräßlin 1c1dca6da4 Move registerMetaType for SurfaceInterface* to main.cpp
Toplevel has the SurfaceInterface* exposed as a property which results
in a (incorrect) runtime warning on X11 about not registered meta type.
2016-08-26 15:27:07 +02:00
Martin Gräßlin 455c5c07a0 Move implementation of iconGeometry from ShellClient to AbstractClient
Summary:
This allows Client to use the Wayland-specific implementation if there
is no icon geometry set through the X11 way. That way Xwayland windows
have an icon geometry even if Plasma is using Wayland and setting the
icon geometry in the Wayland way. Which is expected as Plasma is
ignorant about the windowing system a PlasmaWindow uses.

In order to move the code from ShellClient to AbstractClient
WaylandServer gained a new findAbstractClient(Surface*) method which
is just like findClient(Surface*) with the difference that it returns
an AbstractClient instead of a ShellClient*.

Test Plan:
minimized/unminimized an X client on Wayland, verified
animation is correct (though broken in general for minimize)

Reviewers: #kwin, #plasma_on_wayland

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D2530
2016-08-24 13:11:32 +02:00
Martin Gräßlin 697ea3ae00 Delay query whether screenlocker is registered till WaylandServer is initialized
If we try to query before WaylandServer created the KSldApp the service
owner change is never delivered. Thus a delay till we know that the
service is there on Wayland. On X11 the initialization can be done
directly.

To know when the WaylandServer is fully initialized an additional
signal is added to WaylandServer.
2016-08-16 10:17:14 +02:00
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