Commit graph

656 commits

Author SHA1 Message Date
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
Martin Gräßlin
8e28a6c1c2 [autotest] Extend test for PlasmaShellSurface on server side
Verifies that the shell is returned correctly and the static getter
for wl_resource works as expected.
2016-06-13 13:31:00 +02:00
Martin Gräßlin
ee5e92fe14 [autotests] Add test for PlasmaShellSurface::setSkipTaskbar
Test exposes that the changed signal gets emitted even if the value
did not change.
2016-06-13 11:32:05 +02:00
Martin Gräßlin
19f8ca8376 [autotests] Verfiy setting the position in PlasmaShellSurface 2016-06-10 16:44:29 +02:00
Martin Gräßlin
597e0104fc [autotests] Extend the TestPlasmaShell::testRole to test change to Normal
Test case changes back to Normal and verifies that this is correct in
both client and server.
2016-06-10 15:50:20 +02:00
Martin Gräßlin
41ac06747e [autotest] Verify the static getter on PlasmaShellSurface
Extends the test to verify that the PlasmaShellSurface::get returns
the PlasmaShellSurface for a given Surface.
2016-06-10 15:46:40 +02:00
Martin Gräßlin
c89ae2105e [autotests] Verify that PlasmaShell::createSurface returns from cache
If a PlasmaShellSurface got already created for a Surface, the
PlasmaShell::createSurface should return that one. This change justs
adds a check to an autotest to verify this condition.
2016-06-10 15:38:05 +02:00
Martin Gräßlin
2120d13632 Introduce an initial state event into Plasma Window protocol
Summary:
The event is sent to the client once all initial state is transmitted.
This means the client is able to see the PlasmaWindow completely created
and not in the intermediate state with further updates being pushed after
being created.

The client side API is adjusted to emit the windowCreated signal after
the initial state event is received. In addition if the window is already
unmapped, the signal will never be emitted which means the not valid
windows are not exposed to the client at all.

The tests are adjusted to reflect the new reality, which in most cases
just means removing the comment that this needs to be improved.

There is one kind of unrelated change included: when an empty icon is
set, the client side now creates a QIcon() instead of going through
QIcon::fromTheme. This wrong behavior was exposed now by the auto tests.

Reviewers: #plasma, hein

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D1773
2016-06-06 13:07:35 +02:00
Martin Gräßlin
076e8ba253 [server] Trigger error if a transient request tries to parent to itself
Summary:
If the surface passed in the transient request is to the surface of the
shell surface, KWin aborts. It's an obvious invalid request, so handle
it properly by sending an error.

Reviewers: #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D1755
2016-06-03 12:45:05 +02:00
Martin Gräßlin
b3ccc12b75 [client] Detect errors in ConnectionThread
Summary:
So far ConnectionThread dispatched events without checking for (protocol)
errors. But Wayland errors are considered fatal. We do need to consider
them.

This change introduces a way to detect errors and expose them in
ConnectionThread. Errors are handled gracefully, they are exposed, but
not considered application fatal. E.g. a new ConnectionThread could be
created afterwards.

This allows to add tests to verify error conditions.

Reviewers: #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D1753
2016-06-03 11:27:04 +02:00
Martin Gräßlin
682652714d Introduce a test server
Summary:
The idea of shipping a test server is to have something like Xvfb for
Wayland. To be able to run a test application with a fake Wayland server.

To make this super easy the test server binary is installed into libexec
directory and provides a cmake function to run a test application with
the test server.

The test server takes full control over the process. It's a guiless
application and starts the passed test application once it is fully
set up. The environment is setup to have the test application connect
to the fake server (WAYLAND_SOCKET env variable and QT_QPA_PLATFORM).

When the started application finishes the test server goes down and
exits with the exit value of the test application. This allows a good
integration with ctest.

The test server is a virtual server which supports the following
interfaces:
* Shm
* Compositor
* Shell
* Seat
* DataDeviceManager
* Idle
* SubCompositor
* Output (1280x1024 at 60 Hz with 96 dpi)
* FakeInput

This is sufficient to bring up a QtWayland based application and
allows some basic interactions from a test application (e.g. fake
input).

So far the server fakes a repaint every 16 msec, but does not yet
pass events to the test applications.

To integrate this into an application for testing use:
    find_package(KF5Wayland CONFIG)
    add_executable(myTest myTest.cpp)
    target_link_libraries(myTest Qt5::Gui Qt5::Test)
    kwaylandtest(myTest)

When now running ctest in the build directory the test server gets
started and will start the myTest binary and report the passed/failed
in the expected and normal way.

This way a test case can easily be run against both X11 and Wayland.

Reviewers: #plasma

Subscribers: plasma-devel

Tags: #plasma

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

Changelog: Virtual framebuffer server for auto tests
2016-06-01 16:15:08 +02:00
Martin Gräßlin
151a910f4c [server] Properly handle the case that a PlasmaWindow is unmapped before client bound it
Summary:
So far we directly destroyed the resource on the server side. But this
causes a wayland error when the client tries to cleanup. This results in
the client being destroyed. A problem which brings down plasmashell
regularly when short living windows are shown. This happens e.g. in
Dolphin with the adress auto complete.

This change addresses the problem by creating a temporary
PlasmaWindowInterface for the already unmapped window. It doesn't get
added to the list of known windows and it's only purpose is to properly
handle the unmap and the destroy of the just created resource.

Reviewers: #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D1734
2016-06-01 15:43:21 +02:00
Martin Gräßlin
92c379d474 [autotests] Make PlasmaWindowModel Test a little bit more stable
This change ensures that when the PlasmaWindow got created on client
side is also processed on the server side before we go into unmap.
2016-06-01 14:53:38 +02:00
Martin Gräßlin
0b19734dd0 [server] Don't destroy SlideInterface when parent SurfaceInterface is destroyed
Summary:
Destroying the SlideInterface on the server side before the client has a
chance to cleanup results in a protocol error:
wl_display@1: error 0: invalid object 7

Which would terminate the client. If we would not destroy the resource,
but only delete the SlideInterface it could result in heap-use-after-free.

So just don't do anything, the client needs to cleanup which will result
in the SlideInterface being deleted.

Reviewers: #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D1714
2016-06-01 07:34:10 +02:00
Martin Gräßlin
555ef7f15a [server] Properly handle destructor in SlideInterface
Summary:
The destructor was not properly implement. Let's use the generic one
from Resource.

Test case is adjusted to verify that the SlideInterface gets cleaned up.

Reviewers: #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D1713
2016-06-01 07:33:43 +02:00
Martin Gräßlin
1f48daea1e [server] Don't destroy ShadowInterface when SurfaceInterface gets destroyed
Summary:
Unlike the other cases this one is not as dangerous as the shadow
protocol doesn't have a destructor request (yet).

Once that is added the problem would be the same: destroying the
ShadowInterface when the parent SurfaceInterface gets destroyed would
result in a protocol error on client side.

Reviewers: #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D1711
2016-06-01 07:33:12 +02:00
Martin Gräßlin
33e802913f [server] Don't destroy ServerSideDecorationInterface when parent SurfaceInterface is destroyed
Summary:
Destroying the ServerSideDecorationInterface on the server side before
the client has a chance to cleanup results in a protocol error:
wl_display@1: error 0: invalid object 7

Which would terminate the client. If we would not destroy the resource,
but only delete the ServerSideDecorationInterface it could result in
heap-use-after-free.

So just don't do anything, the client needs to cleanup which will result
in the ServerSideDecorationInterface being deleted.

Reviewers: #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D1710
2016-06-01 07:32:38 +02:00
Martin Gräßlin
5232dc5f0f [server] Don't destroy ContrastInterface when parent SurfaceInterface is destroyed
Summary:
Destroying the ContrastInterface on the server side before the client has
a chance to cleanup results in a protocol error:
wl_display@1: error 0: invalid object 7

Which would terminate the client. If we would not destroy the resource,
but only delete the ContrastInterface it could result in
heap-use-after-free.

So just don't do anything, the client needs to cleanup which will result
in the ContrastInterface being deleted.

Reviewers: #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D1709
2016-06-01 07:32:03 +02:00
Martin Gräßlin
3f1db0cfde [server] Don't destroy BlurInterface when parent SurfaceInterface is destroyed
Summary:
Destroying the BlurInterface on the server side before the client has a
chance to cleanup results in a protocol error:
wl_display@1: error 0: invalid object 7

Which would terminate the client. If we would not destroy the resource,
but only delete the BlurInterface it could result in heap-use-after-free.

So just don't do anything, the client needs to cleanup which will result
in the BlurInterface being deleted.

Reviewers: #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D1708
2016-06-01 07:31:25 +02:00