Commit graph

674 commits

Author SHA1 Message Date
Martin Gräßlin
9e8f123513 [server] Don't send key release for not pressed keys and no double key press
Summary:
This change makes use of the internal key state in better way. If a
key is not considered pressed, no key release is sent. This can happen
for example if the compositor grabs a key press (global shortcut) but not
the release. The Wayland client cannot do anything with the release as it
never got the press. Thus it doesn't make sense to send the release.

Similar if a key is already pressed, it doesn't make sense to send
another press event. This ensures that if the server sends in repeating
key presses they are filtered out. Key repeat is handled on client side.
Also if several physical keys send the same key code, pressing them at
the same time won't send double press/release event.

This change might cause regressions in KWin in case KWin does not handle
the situation correctly. But that would be a bug in KWin which needs to
be fixed there. If it causes regressions the bug might have shown in
other situations as well.

BUG: 366625
FIXED-IN: 5.27

Reviewers: #plasma_on_wayland, #kwin

Subscribers: plasma-devel, kwin

Tags: #plasma_on_wayland, #kwin

Differential Revision: https://phabricator.kde.org/D2786
2016-09-15 09:35:13 +02:00
Martin Gräßlin
2f1beca4bf [server] When replacing the clipboard selection previous DataSource needs to be cancelled
Summary:
According to the Wayland documentation a data source needs to be
cancelled whenever it is no longer valid. A reason for no longer being
valid is that the data source has been replaced by another data source.

So far KWayland did not implement this aspect which resulted in clipboard
breaking in QtWayland applications. As soon as one copied once from an
application it was no longer possible to paste to it from another
application.

With this change the data source gets properly cancelled and also
ensured that the server code doesn't run into a possible crash condition
when trying to cancel an already unbound data source.

BUG: 368391

Reviewers: #plasma_on_wayland

Subscribers: plasma-devel

Tags: #plasma_on_wayland

Differential Revision: https://phabricator.kde.org/D2743
2016-09-14 10:22:38 +02:00
Martin Gräßlin
cd29376ad7 Try to fix build: add missing includes
Sorry about that, it compiled on my system.
2016-09-13 08:46:39 +02:00
Martin Gräßlin
9f92a05f52 Add support for Surface enter/leave events
Summary:
This change implements support for the wl_surface events enter and
leave. Those events are emitted whenever a surface becomes visible on
an output by e.g. mapping the surface, moving or resizing it. Similar
the leave is sent whenever the surface is no longer on an output.

The server side is not yet fully complete yet. It also needs to emit
when the client binds the output another time and needs to send a
leave before destroying the output.

Reviewers: #plasma_on_wayland

Subscribers: plasma-devel

Tags: #plasma_on_wayland

Differential Revision: https://phabricator.kde.org/D2528
2016-09-13 08:32:50 +02:00
Martin Gräßlin
2cf09cb50d [client] Track all created Outputs and add static get method
Summary:
This change starts to track all Outputs and introduces a static
method to get an Output* for a wl_output* in case the wl_output* is
known to Output.

This is needed for the enter and leave events on wl_surface.

Reviewers: #plasma_on_wayland

Subscribers: plasma-devel

Tags: #plasma_on_wayland

Differential Revision: https://phabricator.kde.org/D2526
2016-09-13 08:29:04 +02:00
Martin Gräßlin
34eb146db7 [autotests] Try to make TestWindowManagement more robust
The test started to segfault on build.kde.org. It looks like an event
survives the destruction of the server. Thus this change tries to
dispatchEvents once more before destroying everything.
2016-08-22 15:57:25 +02:00
Martin Gräßlin
31a434b633 [autotest] Try making IdleTest more robust
It started to fail on build.kde.org with a segfault. While I cannot
reproduce this locally it looks like client objects survive to the next
test and thus cause issues.

This change attempts to reduce the risk by making sure that everything
is cleaned up correctly. If that fixes the issue we can look into a
proper fix.
2016-08-22 15:32:02 +02:00
Martin Gräßlin
618bebb63b Make linux/input.h compile time optional
Summary:
Instead of hard depending on the include of linux/input.h we check
whether that include file exists and properly ifdef all usages.

Unfortunately there is no replacement for those parts which do mapping
of input event codes.

Reviewers: #plasma_on_wayland

Subscribers: plasma-devel

Tags: #plasma_on_wayland

Differential Revision: https://phabricator.kde.org/D2344
2016-08-22 14:36:11 +02:00
Martin Gräßlin
233e388e02 [autotests] Try making TestWaylandSurface::testDisconnect more robust
On build.kde.org the Surface is often already destroyed when returning
from waiting on client disconnected.

This change tries to handle the situation better: only if the signal
is not yet emitted, try to wait for it.
2016-08-08 08:38:57 +02:00
Martin Gräßlin
a092de25b4 [autotests/client] QSkip the WaylandFullscreenShellTest if _wl_fullscreenshell missing
Newer Weston renamed the interface to the unstable naming scheme. As
KWayland does not support this interface yet, the tests are failing.

This change skips the test if the Weston is too new and doesn't provide
the expected interface any more.
2016-08-08 07:45:02 +02:00
Martin Gräßlin
a612cfa499 [client] Use a QPointer for the enteredSurface in Pointer
If the client deletes the currently entered Surface the Pointer should
return null in Pointer::enteredSurface and not invalid memory.

At the same time a now incorrect assert is removed. After the client
deletes the Surface it might still get a left event for the Surface.
In that case a comparison between the enteredSurface and the Surface
from the leave event would fail.

Reviewed-By: bshah
2016-08-04 10:07:10 +02:00
Martin Gräßlin
2c79c7ff5f Drop Mainpage.dox 2016-08-03 11:45:25 +02:00
Eike Hein
117ab361bc Expose Geometry in PlasmaWindowModel.
Reviewers: #plasma, graesslin

Subscribers: plasma-devel

Tags: #plasma_on_wayland

Differential Revision: https://phabricator.kde.org/D2203
2016-07-19 20:22:11 +09:00
Martin Gräßlin
ccb4ac4280 Add a geometry event to PlasmaWindow
Summary:
This allows the compositor to expose the absolute window geometry to
processes which need it.

Reviewers: #plasma_on_wayland

Subscribers: plasma-devel

Tags: #plasma_on_wayland

Differential Revision: https://phabricator.kde.org/D2183
2016-07-15 13:31:54 +02:00
Martin Gräßlin
253cb85fdb [src/server] Verify that surface has a resource before sending pointer enter
Summary:
If we try to send a pointer enter on a null resource of a Surface
(e.g. after unbound) we hit a marshalling error:
error marshalling arguments for enter (signature uoff): null value passed for arg 1

The added test case hits this error without the change and passes
cleanly with the change.

Reviewers: #plasma_on_wayland

Subscribers: plasma-devel

Tags: #plasma_on_wayland

Differential Revision: https://phabricator.kde.org/D2159
2016-07-14 11:47:34 +02:00
Martin Gräßlin
53f27feee7 Add support for xdg-shell
Summary:
This change introduces support for the unstable xdg-shell interface in
the server. The implementation is based on version 5 of the unstable
interface. This is the version used by toolkits like e.g. GTK.

There is also a version 6 of the protocol under development which is
incompatible. This makes it difficult to implement it in a backward
compatible way.

Because of that the implementation is a little bit different to other
interfaces and inspired by the TextInput interfaces:
On client side an XdgShell class is exposed which does not represent
it directly. Instead it delegates everything to an XdgShellUnstableV5
implementation. For the Surface/Popup the same is done.

In the Registry it's possible to create an XdgShell and it accepts
the XdgShellUnstableV5 and in future will accept XdgUnstableV6, etc.

On server side it also follows the approach from TextInput. That is
there is a version enum which gets passed to the factory method in
Display. It currently supports only V5, but in future can be extended
for V6. As there is lots of similar code between wl_shell, xdg_shell
and in future xdg_shell_unstable_v6 a templated GenericShellInterface
class is added which combines the common parts.

Reviewers: #plasma_on_wayland

Subscribers: plasma-devel

Tags: #plasma_on_wayland

Differential Revision: https://phabricator.kde.org/D2102
2016-07-13 13:04:31 +02:00
Martin Gräßlin
e0716c2306 [server] Properly send a selection clear prior to keyboard focus enter
Summary:
When setting the keyboard focus the server needs also to send the current
selection to the client. So far KWayland only sent the selection if it was
set. That is if the last focused client cleared the selection it was not
updated and the client might have had an outdated selection.

To prevent this situation the server now explicitly sends the clear to the
client on enter if there is no selection. Also if the selection is cleared,
the SeatInterface now unsets it's current selection to make sure that the
next focused keyboard will get the clear selection sent.

Test Plan:
Existing test case adjusted and a new test case added which
simulates the interaction of two clients.

Reviewers: #plasma_on_wayland

Subscribers: plasma-devel

Tags: #plasma_on_wayland

Differential Revision: https://phabricator.kde.org/D2091
2016-07-13 09:21:01 +02:00
Martin Gräßlin
ab85e957a6 [server] Handle no XDG_RUNTIME_DIR situation more gracefully
Summary:
Even if the XDG_RUNTIME_DIR is not set, KWayland should not crash
if methods are invoked which only make sense after the server was
started successfully. This was not yet the case for
Display::dispatchEvents.

Also the wl_display was not destroyed in the situation that creating
the socket failed.

Test Plan:
Test case added which simulates the situation of no
XDG_RUNTIME_DIR being set.

Reviewers: #plasma_on_wayland

Subscribers: plasma-devel

Tags: #plasma_on_wayland

Differential Revision: https://phabricator.kde.org/D2077
2016-07-13 09:20:03 +02:00
Marco Martin
cd77833c3b add .data() to qpointer access
fix build on old gcc versions
2016-06-30 16:45:29 +02:00
Martin Gräßlin
bd7d7c1936 [server] Hide unused variable warning in PlasmaWindowManagementInterface::Private::getWindowCallback 2016-06-29 11:26:29 +02:00
Martin Gräßlin
4a3bdbbd7b [autotests] Verify the directChildServerSurfaces in TestSubSurface::testSurfaceAt
Unused variable warnings were reported. Let's do some testing with those
variables.
2016-06-29 11:24:35 +02:00
Martin Gräßlin
d52485ffb7 Add a parent_window event to Plasma Window interface
Summary:
This change adds a parent_window event to Plasma Window. From server
side it's possible to specify that a window is a transient for another
window - that is it has a parent window.

On client side this is exposed respectively with a new change signal.

Reviewers: #plasma_on_wayland, hein

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D1779
2016-06-29 08:03:55 +02:00
Martin Gräßlin
5ae8ac4327 Add a ToolTip role to PlasmaShellSurface
Summary:
As Wayland doesn't have a proper ToolTip window type yet, we add it
to PlasmaShellSurface, so that we can use it for Plasma's tooltips.

Reviewers: #plasma_on_wayland

Subscribers: plasma-devel

Tags: #plasma_on_wayland

Differential Revision: https://phabricator.kde.org/D2030
2016-06-29 08:01:26 +02:00
Martin Gräßlin
89a4c2f0e1 Properly handle destroying a Pointer resource
Summary:
On client side the newer wl_pointer_release is used which is a
destructor call. On server side the shared destroy callback is used
and it's ensured that KWayland doesn't crash if called into the
PointerInterface between unbound and destroyed.

Test Plan:
Test case extended to cover the condition of an unbound
PointerInterface.

Reviewers: #plasma_on_wayland

Subscribers: plasma-devel

Tags: #plasma_on_wayland

Differential Revision: https://phabricator.kde.org/D2037
2016-06-28 18:58:41 +02:00
Martin Gräßlin
0b208fcd63 [autotests] Get Server::Cursor::pointer under coverage
Just verifying that it's returning the expected value.
2016-06-28 18:39:19 +02:00
Martin Gräßlin
594665c1df [server] Delete dead code: KeyboardInterface::Private::sendKeymap
Not called from anywhere.
2016-06-28 17:26:28 +02:00
Martin Gräßlin
782f036c0d Properly handle destroying a Keyboard resource
Summary:
On client side the newer wl_keyboard_release is used which is a
destructor call. On server side the shared destroy callback is used
and it's ensured that KWayland doesn't crash if called into the
KeyboardInterface between unbound and destroyed.

Test Plan:
Test case extended to cover the condition of an unbound
KeyboardInterface.

Reviewers: #plasma_on_wayland

Subscribers: plasma-devel

Tags: #plasma_on_wayland

Differential Revision: https://phabricator.kde.org/D2036
2016-06-28 17:14:36 +02:00
Martin Gräßlin
34df9d8b2e Properly handle release of a touch resource
Summary:
On client side use wl_touch_release to get into the proper destroy
handler on server side. There the shared destroy implementation is
used.

The test case is extended to verify the condition and ensure that
our code doesn't crash in case SeatInterface calls into the already
unbound TouchInterface.

Reviewers: #plasma_on_wayland

Subscribers: plasma-devel

Tags: #plasma_on_wayland

Differential Revision: https://phabricator.kde.org/D2035
2016-06-28 17:06:49 +02:00
Martin Gräßlin
f53bc666eb [autotests] Extend test case for SeatInterface::setSelection
Verifies the condition that the currentSelection is the same as the
DataDeviceInterface passed to setSelection.
2016-06-28 14:57:42 +02:00
Martin Gräßlin
1c16f881e2 [autotests] Bring SeatInterface::focusedTextInputSurface under coverage 2016-06-28 14:53:45 +02:00
Martin Gräßlin
59bfac50ba [server] Add support for setting the clipboard selection DataDeviceInterface manually
Summary:
So far SeatInterface handled automatically which DataDeviceInterface
holds the current clipboard selection. While this works fine and is
correct it doesn't support use cases like a clipboard manager where
the clipboard is hold by a different ClientConnection than the one
from the focused keyboard.

This change allows to manually set the selected DataDeviceInterface
to override the automatic selection, though the automatic selection
is still in place. Thus the next update of a selection will override
the manually set selection again.

Reviewers: #plasma_on_wayland

Subscribers: plasma-devel

Tags: #plasma_on_wayland

Differential Revision: https://phabricator.kde.org/D1972
2016-06-28 10:48:30 +02:00
Martin Gräßlin
db602b8188 [server] Ensure that Resource::Private::get returns nullptr if passed a nullptr
Summary:
A Resource might be unbound, but not yet destroyed. In that case this
return a Resource instead of nullptr.

This change adds an explicit nullptr check.

Reviewers: #plasma_on_wayland

Subscribers: plasma-devel

Tags: #plasma_on_wayland

Differential Revision: https://phabricator.kde.org/D1938
2016-06-27 08:21:10 +02:00
Martin Gräßlin
b612251015 [tests] Add a test application for PlasmaShellSurface
Summary:
Creates a PlasmaShellSurface and allows to set the different roles
through command line argument.

Needed to verify that KWin properly handles the notification type.

Reviewers: #plasma_on_wayland

Subscribers: plasma-devel

Tags: #plasma_on_wayland

Differential Revision: https://phabricator.kde.org/D1932
2016-06-27 08:20:43 +02:00
Martin Gräßlin
52eeb16156 Add a notification role to PlasmaShellSurface
Summary:
Plasma needs to be able to mark windows as Notifications, so that KWin
can put them into the right layer.

Reviewers: #plasma_on_wayland

Subscribers: plasma-devel

Tags: #plasma_on_wayland

Differential Revision: https://phabricator.kde.org/D1928
2016-06-27 08:20:01 +02:00
Martin Gräßlin
7844e38e79 [autotests] Add test for showing desktop in PlasmaWindowManagement 2016-06-25 21:04:48 +02:00
Martin Gräßlin
c9ec19d522 [autotest] Extend testing for the requests in PlasmaWindowInterface 2016-06-25 11:41:19 +02:00
Martin Gräßlin
3f69ab1bf0 [server] Add resource check in QtExtendedSurfaceInterface::close
Summary:
The QtExtendedSurfaceInterface might be unbound and thus the resource
might be null when calling into close. Thus we need to do a nullptr
check.

Hit a crash there.

Test Plan:
Unfortunately no test case as we don't have a client side
implementation for this.

Reviewers: #plasma_on_wayland

Subscribers: plasma-devel

Tags: #plasma_on_wayland

Differential Revision: https://phabricator.kde.org/D1961
2016-06-20 16:27:13 +02:00
Martin Gräßlin
262b49d713 [server] Unset SurfaceInterface pointer in referenced objects when being destroyed
Summary:
This is a gotcha moment:
1. Create Surface with id 1
2. destroy that Surface
3. Create another Surface

Now if in step 3 the id is by pure chance getting reused and also 1, the
wl_resource pointer of the SurfaceInterface of step 1 and step 3 are
the same. This is rather unexpected and causes problems.

When creating a ShellSurface in step 1 and step 3 it would fail. KWayland
finds a ShellSurface which was already created for the Surface. The same
can happen with QtSurfaceExtensionInterface and PlasmaShellInterface which
also go into error state.

On client side this would trigger a protocol error and terminate the
application. An easy way to reproduce is opening the file open dialog
from within Kate multiple times.

This change addresses this problem by setting the surface pointer in
those classes to null when the parent Surface gets destroyed. Thus
creating a new ShellSurface won't find the old referenced Surface any
more.

For ShellSurface and PlasmaShellSurface a test case is added which hit
the condition without this change. For QtSurfaceExtension we don't have
the client side, so we cannot really simulate the condition.

Reviewers: #plasma_on_wayland

Subscribers: plasma-devel

Tags: #plasma_on_wayland

Differential Revision: https://phabricator.kde.org/D1937
2016-06-20 10:30:08 +02:00
Martin Gräßlin
aa5cf3143a [server] Fix error message in QtSurfaceExtension Interface
If a SurfaceExtension is already created for a Surface we should say
that and not that a PlasmaShellSurface is already created.
2016-06-17 15:25:03 +02:00
Martin Gräßlin
2417faff4d [autotests] Extend TestDataDevice for unbound check in createDataOffer
Extends the test case for checking that the nullptr check is taken
when trying to send a selection on an already unbound DataDevice.
2016-06-15 09:33:10 +02:00
Martin Gräßlin
e2d46c574c [server] Introduce a Resource::unbound signal emitted from unbind handler
Summary:
So far for internal cleanup we mostly listen to QObject::destroyed.
When a Resource gets unbind the wl_resource is set to null and the
Resource gets deleteLater. This creates a short time frame when the
Resource is still there, but the wl_resource is null. For most internal
usages the Resource is completely useless at that point and should no
longer be considered. So far it was still considered and could hit
crashers, if a code path did not nullptr check. Unfortunately
libwayland-server is not nullptr safe: if called with a null value it
tends to crash.

So this check introduces a new signal unbound which can be listend to
in addition to the destroyed signal. It's used in SeatInterface for
DataDeviceInterface, where we experienced a crash related to that.

A test case is added which exposes the crash, but it already needs
the unbound signal to get into the crashy condition. The actual crash
is fixed twice - with the help of the unbound signal, but also by
introducing the nullptr check where it's needed.

Reviewers: #plasma_on_wayland

Subscribers: plasma-devel

Tags: #plasma_on_wayland

Differential Revision: https://phabricator.kde.org/D1868
2016-06-15 09:05:13 +02:00
Martin Gräßlin
07e0f92d80 [autotests] Fix build with older compiler
We cannot create a QSignalSpy on a QPointer.
2016-06-14 11:22:58 +02:00
Martin Gräßlin
9a44631c24 [server] Don't assert when destroying a still referenced BufferInterface
Summary:
The fact that the buffer is still referenced - that is used - when the
BufferInterface gets destroyed is an error, but it is not fatal.

Unfortunately KWin/Wayland is still hitting this assert from time to
time and the assert is not helping to find the cause as a backtrace
does not show where a reference is still hold.

This change removes the hard assert by a soft warning. The advantage
of the warning is that the compositor is not killed and that we can
observe the reason and find a usage pattern which triggers the condition.

With that we will hopefully be able to find the case where the buffer
is still referenced when being destroyed and fix that.

Reviewers: #plasma_on_wayland

Differential Revision: https://phabricator.kde.org/D1783
2016-06-14 07:44:09 +02:00
Martin Gräßlin
acb0e85bb6 Add destructor request to org_kde_kwin_shadow and org_kde_kwin_shadow_manager
Summary:
This improves the cleanup of a shadow from client side. The server now
notices when the client destroyed the shadow.

Reviewers: #plasma_on_wayland

Subscribers: plasma-devel

Differential Revision: https://phabricator.kde.org/D1789
2016-06-14 07:37:11 +02:00
Martin Gräßlin
37f5256688 [autotests] Extend test for OutputInterface
Just adds more test conditions to the already existing test.
2016-06-13 19:19:06 +02:00
Martin Gräßlin
c11b1f1217 [autotest] Improve test for ShellSurface
Just verifying a few more conditions.
2016-06-13 16:49:31 +02:00
Martin Gräßlin
268f2ef6ff [autotests] Add test for error case of two PlasmaShellSurfaces for same Surface
Tricky to test as our client implementation is too smart to go into it.
Thus the Surface needs to be created with normal Wayland functionality.
2016-06-13 16:26:27 +02:00
Martin Gräßlin
57148c4bae [autotests] Extend test for PlasmaShellSurface::setRole
If the role is set to the same as before it should not emit the changed
signal.
2016-06-13 16:01:54 +02:00
Martin Gräßlin
65b7fd68d2 [autotests] Try to fix the flaky TestWayalndSurface::disconnect
Sometimes the test is failing due to a wait on the signalspy not
working and then the cleanup triggers a heap-use-after-free.

This change tries to address the problem by using a QTRY_COMPARE
instead of a wait on signalspy.
2016-06-13 14:55:36 +02:00
Martin Gräßlin
33c8634c00 [autotests] Add test for PlasmaShellSurface::setPanelBehavior
Also adds the metatypes on client and server side.
2016-06-13 14:01:49 +02:00