Commit graph

744 commits

Author SHA1 Message Date
David Edmundson
ec8887ad27 KWayland::Client::Surface track output destruction
Summary:
A compositor should send left events before deleting an output; however
if it doesn't, we don't want dangly pointers in our list of outputs on
the client surface.

Test Plan: Unit test

Reviewers: #plasma, graesslin

Reviewed By: #plasma, graesslin

Subscribers: plasma-devel, #frameworks

Tags: #plasma_on_wayland, #frameworks

Differential Revision: https://phabricator.kde.org/D7379
2017-08-18 15:14:36 +01:00
David Edmundson
eac4973697 Avoid sending data offers from an invalid source.
Summary:
A DataDevice will have a source when offers are available, but it can
also be legitimately cleared.

When calling DataDeviceInterface::sendSelection(DataDeviceInterface
*other) if the other data device has no source, we should be setting
that we also have no source.

In addition this also guards against Seat tracking a DataDeviceInterface
with no source when trying to sync x clipboards.

BUG: 383054

Reviewers: #plasma

Subscribers: graesslin, plasma-devel, #frameworks

Tags: #plasma_on_wayland, #frameworks

Differential Revision: https://phabricator.kde.org/D7316
2017-08-16 00:17:32 +01:00
David Faure
cac7d766b1 Make unittest independent from the location of the executable.
Summary:
This fixes the check in the unittest when doing
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
which I intend to do globally at some point.

Turns out it's comparing with its own executable location, so we
can use QCoreApplication to get it generically.

Test Plan: Verified to work with ctest and with "./testWaylandServerDisplay"

Reviewers: graesslin, mart

Reviewed By: graesslin, mart

Subscribers: plasma-devel, #frameworks

Tags: #plasma_on_wayland, #frameworks

Differential Revision: https://phabricator.kde.org/D6974
2017-07-30 01:05:45 +02:00
David Faure
0c42a1bfeb autotests: prepare for CMAKE_RUNTIME_OUTPUT_DIRECTORY being set
Scripted with
perl -pi -e 's/add_test\(([^ ]*) (.*?)\)/add_test(NAME $1 COMMAND $2)/' CMakeLists.txt
2017-07-29 08:27:59 +02:00
David Edmundson
e8ef0ea68f Destroy all kwayland objects created by registry when it is destroyed
Summary:
Currently one has to connect every object manually to connectionDied,
which is something we can do for them.

If the user also has a connection, the second will just no-op.

This fixes objects that linger longer than the QApp.

Reviewers: graesslin

Reviewed By: graesslin

Subscribers: graesslin, plasma-devel, #frameworks

Tags: #plasma_on_wayland, #frameworks

Differential Revision: https://phabricator.kde.org/D6727
2017-07-28 09:51:46 +01:00
Martin Flöser
c6b085f5eb [client] Track all created ConnectionThreads and add API to access them
Summary:
This is change needed by KWin. KWin has the problem that it destroys its
internal Wayland connection (KWin as client for KWin as server) before
shutting down the application. Other external libraries loaded into KWin
(e.g. breeze window decoration) are unloaded later on, then try to clean
up their Wayland resources and crash KWin due to accessing a no longer
valid Wayland connection.

With the help of this new API KWin can access all connections during
the clean up and destroy them before shutting down the Wayland server and
thus exit cleanly.

Reviewers: #frameworks, #plasma, #kwin

Subscribers: plasma-devel

Tags: #plasma_on_wayland, #frameworks

Differential Revision: https://phabricator.kde.org/D6569
2017-07-21 07:14:22 +02:00
Martin Flöser
dd873cb980 [server] Send text input leave if focused surface gets unbound
Summary: As 9266a94400 just for text input.

Test Plan: Adjusted test passes, fails without adjustment

Reviewers: #plasma, #frameworks

Subscribers: plasma-devel

Tags: #plasma_on_wayland, #frameworks

Differential Revision: https://phabricator.kde.org/D6786
2017-07-19 20:17:56 +02:00
Martin Flöser
1b989a0464 [server] Send pointer leave if focused surface gets unbound
Summary: As 9266a94400 just for pointer.

Reviewers: #plasma, #frameworks

Subscribers: plasma-devel

Tags: #plasma_on_wayland, #frameworks

Differential Revision: https://phabricator.kde.org/D6754
2017-07-19 07:13:18 +02:00
Martin Flöser
3db6bd64fe Drop unused variable 2017-07-17 17:03:40 +02:00
Martin Flöser
63102e1215 [client] Properly track enteredSurface in Keyboard
Summary:
ASAN found a heap-use-after-free when deleting the focused keyboard
surface in the client library. Keyboard did not track the lifetime of
the focused surface and thus one can access already freed memory.

Test Plan: Adjusted auto test to verify the variable gets cleared

Reviewers: #frameworks, #plasma

Subscribers: plasma-devel

Tags: #plasma_on_wayland, #frameworks

Differential Revision: https://phabricator.kde.org/D6741
2017-07-16 20:25:12 +02:00
Martin Flöser
9266a94400 [server] Send keyboard leave when client destroys the focused surface
Summary:
This is a change inspired by https://bugreports.qt.io/browse/QTBUG-61930.
When Qt closes a window due to a key press event it starts to repeat the
event as KWayland does not send a keyboard leave event. Weston on the
other hand does send out the keyboard leave. In my opinion it doesn't
make much sense to send out the keyboard leave in this situation and in
my opinion that is a client bug, but if it makes clients happy we can
send them the keyboard leave. Similar this should be done for pointer,
touch, etc.

BUG: 382280

Test Plan: Run the example added to the Qt bug and it worked fine

Reviewers: #frameworks, #plasma

Subscribers: plasma-devel

Tags: #plasma_on_wayland, #frameworks

Differential Revision: https://phabricator.kde.org/D6683
2017-07-16 16:25:25 +02:00
Martin Gräßlin
464ba18321 [autotests/server] Check whether test is run as root
If the test is run as root we cannot compare the user id to not be 0.
Thus let's check for that and expect fail.
2017-07-01 17:01:18 +02:00
Friedrich W. H. Kossebau
ac1a3b8b90 [FEATURE] Option to build & install QCH file with the public API dox
Using the new extra-cmake-modules module ECMAddQch (since 5.36.0)
this adds the option to automatically build and install a file
in QCH format with the docs about the public API, which then can be
used e.g. in Qt Assistant, Qt Creator or KDevelop.

Additionally the installed cmake config files will be extended
with a target KF5Wayland_QCH containing information about how to "link"
into the generated QCH file, which then can be used in the cmake build
system of other libraries building on this library, by
simply listing this target in "LINK_QCHS" of their ecm_add_qch() usage.
And a respective doxygen tag file with all the metadata about the
generated QCH file and used for the "linking" will be created and
installed.

Pass -DBUILD_QCH=ON to cmake to enable this.
2017-06-05 03:03:25 +02:00
Friedrich W. H. Kossebau
c010a9fae0 Autotests: solve warning for QProcess::ProcessState metatype registration 2017-06-03 01:16:11 +02:00
Friedrich W. H. Kossebau
2da0a9428d Fix for TestQtSurfaceExtension in path with spaces
Use the QProcess::start() variant with explicit (empty, in these cases)
arguments, so the program strings are not parsed as shell commands,
thus preserving paths with spaces as such.
2017-06-03 00:16:59 +02:00
Friedrich W. H. Kossebau
43aca8a949 API dox: add some minimal docs to more class to have them covered by doxygen 2017-05-26 18:33:25 +02:00
Friedrich W. H. Kossebau
36fdc9c811 API dox: add some minimal docs to class to have them covered by doxygen 2017-05-26 03:35:03 +02:00
Friedrich W. H. Kossebau
70d23d068a API dox: Use doxygen notation to have comments used 2017-05-26 03:34:55 +02:00
Friedrich W. H. Kossebau
c4ba4bd593 API dox: fix @link usage
@link either needs a matching @endlink tag,
or being used in javadoc style, {@link target [label]}
2017-05-26 02:57:20 +02:00
Marco Martin
7d10af91b1 add requestToggleKeepAbove/below
Summary: client requests to toggle those states, to be used by libtaskmanager

Test Plan: setting keep above from the taskbar works

Reviewers: #plasma, hein, graesslin, #plasma_on_wayland

Reviewed By: #plasma, hein

Subscribers: graesslin, hein, plasma-devel, #frameworks

Tags: #frameworks, #plasma

Differential Revision: https://phabricator.kde.org/D5757
2017-05-24 18:02:22 +02:00
David Edmundson
e182a2cc24 Remove pid changedSignal in Client::PlasmaWindow
Summary: Verified it it send before the initial_state and adjust tests and docs accordingly

Test Plan: All unit tests pass

Reviewers: #plasma, graesslin

Reviewed By: #plasma, graesslin

Subscribers: graesslin, plasma-devel, #frameworks

Tags: #plasma_on_wayland, #frameworks

Differential Revision: https://phabricator.kde.org/D5887
2017-05-16 15:54:08 +01:00
Sebastian Kügler
1154b2a6fd add pid to plasma window management protocol
Summary:
This patch adds a pid event to the plasma window management protocol. It
allows the compositor to tell allow a mapping between windows and processes.

Bumps the version number of the interface to 8 to indicate this.

Test Plan: autotest added, passed

Reviewers: #plasma, hein, graesslin

Reviewed By: #plasma, hein, graesslin

Subscribers: apol, davidedmundson, plasma-devel, #frameworks

Tags: #frameworks, #plasma_on_wayland

Differential Revision: https://phabricator.kde.org/D5747
2017-05-13 17:09:12 +02:00
David Edmundson
67521b975b Validate surface is valid when sending TextInput leave event
Summary:
It's possible for the surface to be unbound when we send the leave
event; we've called Resource::unbind() of Surface, so the Surface has,
deleteLater called, but it's still a valid object, and the first check
passes.

We get in this situation because when a surface is destroyed, we're
handling text input from the same source event.

Sending a nullpointer is a protocol error, and wayland kindly closes the
connection.

This fixes my constant:
"Did the Wayland server die" error messages when running clients.

Test Plan:
Got errors after setting up qt virtual keyboard.
Had reproducible case.
Restarted kwin after this patch, now doesn't crash.

Reviewers: #plasma, graesslin

Subscribers: apol, graesslin, plasma-devel, #frameworks

Tags: #plasma_on_wayland, #frameworks

Differential Revision: https://phabricator.kde.org/D5712
2017-05-05 18:51:34 +02:00
Adriaan de Groot
6df5c8733e Fix autotests on the FreeBSD CI.
Summary: Include <errno.h> explicitly, for EPROTO.

Reviewers: bcooksley, graesslin, davidedmundson

Reviewed By: davidedmundson

Subscribers: plasma-devel, #frameworks

Tags: #plasma_on_wayland, #frameworks

Differential Revision: https://phabricator.kde.org/D5717
2017-05-05 17:27:24 +02:00
Martin Gräßlin
bccb1f4cba Add support for wl_shell_surface::set_popup and popup_done
Summary:
This extends the client side API to support creating popup ShellSurface
windows and the server side API to send out the popup_done request.

This is needed to properly support popup windows (e.g. context menus)
in KWin.

Reviewers: #plasma_on_wayland, #frameworks, #kwin

Subscribers: plasma-devel

Tags: #plasma_on_wayland, #frameworks

Differential Revision: https://phabricator.kde.org/D5174
2017-03-25 17:43:47 +01:00
Kevin Funk
a1c8ea01d7 Prefer nullptr over Q_NULLPTR 2017-01-16 18:17:33 +01:00
Kevin Funk
218631efce Use nullptr everywhere
Differential Revision: https://phabricator.kde.org/D3987
2017-01-16 09:44:16 +01:00
Sven Brauch
1c6b81f9ce GIT_SILENT add missing include(CMakeFindDependencyMacro) 2017-01-04 00:57:30 +01:00
Martin Gräßlin
49d57b342c [client] Fix nullptr dereference in ConfinedPointer and LockedPointer
The setRegion call allows a null region. This means nullptr is an
allowed value which can be passed to ConfinedPointer::setRegion and
LockedPointer::setRegion.

In that case we crash if we try to convert the Region into a wl_region.
Thus add proper nullptr check, just like in
PointerConstraints::lockPointer and ::confinePointer.

Auto test adjusted to cover the condition.
2016-11-25 13:14:14 +01:00
Martin Gräßlin
a1990e9cc5 [server] Fix regression in SeatInterface::end/cancelPointerPinchGesture
Regression with c72510c932 which removed a
needed source code line.

Thanks build.kde.org!
2016-11-24 09:36:18 +01:00
Martin Gräßlin
b44a8fb556 Implementation of PointerConstraints protcol
Summary:
The pointer constraints protocol is an unstable protocol and thus
the implementation follows the semantics of unstable protocols.

The protocol allows to create a constraint on the pointer - either a
lock or a confinement on a surface. Those are not activated at once, but
when the compositor actively grants it.

During lock no further pointer motion is emitted, during confinement the
pointer is kept in a certain area.

This implements T4451.

Reviewers: #plasma_on_wayland

Subscribers: plasma-devel

Tags: #plasma_on_wayland

Differential Revision: https://phabricator.kde.org/D3466
2016-11-24 09:19:36 +01:00
Martin Gräßlin
c72510c932 [server] Reduce overhead of pointersForSurface
Summary:
In SeatInterface we need to get all PointerInterfaces related to a given
Surface (Client) and call a method on it. The implementation we had so
far went through all Pointers and put all PointerInterfaces into a new
temporary QVector. In most cases all we did then was iterating over the
returned vector.

Which means we created a temporary vector for nothing.

This change implements a kind of std::for_each with the constraints of
the previously used pointersForSurface which does the check that Surface
is not null and that the client matches. If a PointerInterface is found
for that, the passed in method is invoked on it.

Reviewers: #plasma_on_wayland

Subscribers: plasma-devel

Tags: #plasma_on_wayland

Differential Revision: https://phabricator.kde.org/D3295
2016-11-24 09:19:12 +01:00
David Edmundson
8b3ecf8436 Return SurfaceInterface::size in global compositor space
REVIEW: 129358
2016-11-16 14:50:50 +00:00
Martin Gräßlin
bfbc8b9c54 [tools/generator] Generate enum FooInterfaceVersion on server side
With this change the generator is able to detect whether an interface
follows the unstable semantics. In that case the header file on server
side looks different. An enum needs to be generated containing the
interface version. Each of the generated classes has a new method
interfaceVersion returning that enum. The ctor of the class is protected
instead of private.

So far only the header side is adjusted. The implementation currently
generates not matching code.
2016-11-10 08:25:45 +01:00
Martin Gräßlin
40ae294abd [tools/generate] Wrap wl_fixed request args in wl_fixed_from_double
We pass a qreal to the wl_fixed and for that need to wrap it in
wl_fixed_from_double.
2016-11-08 12:29:32 +01:00
Martin Gräßlin
ccdcb43680 [tools/generate] Generate implementation of client side requests
Like in the factored method case, just for generic requests.
2016-11-08 10:58:45 +01:00
Martin Gräßlin
8cbf16b737 [tools/generator] Generate client side resource factories
The code needed in a client global to create a client resource is pretty
much the same in all interfaces. Thus we can generate it.
2016-11-08 10:17:43 +01:00
Martin Gräßlin
64f0117b43 [tools/generator] Generate callbacks and listener on client side
* static void fooCallback definitions added to Private class
* static const foo_listener s_lister added to Private class
* Private::setup generates the foo_add_listner call
* implementation of s_listener added
* base implementation with a TODO marker added for the callbacks
2016-11-08 09:45:28 +01:00
Martin Gräßlin
1bc3818e54 [tools/generator] Pass this as q pointer to Client::Resource::Private
Experience showed that in most cases we need the q pointer in the
resource private class on the client side.
2016-11-08 08:25:33 +01:00
Martin Gräßlin
dba0d77318 [tools/generator] Generate Private::setup(wl_foo *arg) on client side
Experience showed that most generated classes need a dedicated setup
method in the Private in order to add a listener.
2016-11-08 08:00:40 +01:00
Martin Gräßlin
58a6740e48 Fix build - KWayland_SOURCE_DIR instead of KWAYLAND_SOURCE_DIR
Change was prepared prior to project name change. Sorry about breaking.
2016-11-07 13:34:08 +01:00
Martin Gräßlin
a3a7356995 Implementation of PointerGestures protocol
Summary:
Pointer gestures are created for a pointer and there are two types of
gestures: swipe and pinch.

At a given time there can only be one active gesture. The implementation
in SeatInterface ensures that there can only be one active gesture.

Each gesture consists of a start event, 0 to multiple update events and
an end event. The end can also be a cancel. To better support this the
implementation doesn't follow the protocol and splits end and cancel
into dedicated methods in the server side and into dedicated signals in
the client side.

Reviewers: #plasma_on_wayland

Subscribers: plasma-devel

Tags: #plasma_on_wayland

Differential Revision: https://phabricator.kde.org/D3169
2016-11-07 13:28:44 +01:00
Friedrich W. H. Kossebau
4513dad684 Unbreak build: adapt cmake var names to KWAYLAND->KWayland change
project() sets more variables than I remembered

Fix-up for f90f647227508943ec8f919285fd16f0440261b9
2016-11-03 16:46:37 +01:00
Harald Sitter
99bcb89c3b Remove /KF5 include directory injection
This is ancient code that is outright wrong most of the time and at best
just incredibly unnecessary.
It is also not present in the great majority of frameworks due to this.

Its wrongness comes from the fact that it hardcodes the installation path,
which breaks relocatability of the KF5 tree as it will always attempt to
find the include dir $PREFIX/KF5 (e.g. /usr/include/KF5), which may or may
not exist given that the tree was relocated.
Worse yet, in a cross-building scenario we maybe for example
build on ARM and install to /usr but for cross building take the entire ARM
tree and shift it into /arm/usr/. If we then crossbuild on that tree the
bogus include list in this framework will make sure that we always search
in /usr/include/KF5 and thus potentially load a !ARM header simply because
the relevant ARM header was not installed etc.. Similarly of course a
build in $HOME can pick up /usr/include/KF5 headers because the home ones
are missing, causing unexpected results.
This happens whenever the KDE_INSTALL_INCLUDEDIR_KF5 var is absolute, which
it usually is.

On top of all that the premise of the code in question is flawed. It seeks
to add $PREFIX/$KF5INCLUDES to the search paths (e.g. /usr/include/KF5).
This is unnecessary because the target itself is properly installed via
cmake's install(TARGETS ... EXPORT ...) function [1]. This function has
smart functionality built in which will add the passed INCLUDES destination
to the INTERFACE_INCLUDE_DIRECTORIES property of the targets (i.e. what
the useless code wants to do) [2].
So what happens is that we install the target to the
KF5 locations, which has "include/KF5" as INCLUDES location,
thus causing the correct path to be added to the includes list of the
Targets.cmake file.
In particular thanks to more internal magic in cmake it will do so with
automatically resolved root paths such that the installed tree is
relocatable and able to relatively find the other KF5/* headers. So it
does what the code in question wants to do, just correctly.

Since cmake automatically takes care of injecting $prefix/include/KF5 we
can simply get rid of the wrong custom inejection code. This makes the
generated cmake file find the correct include/KF5/ directory and stops it
from always expecting a /usr/include/KF5/ directory to be present.

[1] https://cmake.org/cmake/help/v3.0/command/install.html
[2] https://cmake.org/cmake/help/v3.0/command/install.html
> The INCLUDES DESTINATION specifies a list of directories which will be
> added to the INTERFACE_INCLUDE_DIRECTORIES target property of the
> <targets> when exported by the install(EXPORT) command.

REVIEW: 129273
CHANGELOG: Improved relocatability of CMake export
2016-10-28 14:08:44 +02:00
Martin Gräßlin
de59c3d9b2 [autotests] Fix TestWaylandConnectionThread::testConnectFdNoSocketName
Same as 611df30ecc for the next test
method.
2016-10-28 09:15:24 +02:00
Martin Gräßlin
611df30ecc [autotest] fix WaylandConnectionThread::testConnectFd
The test destroyed the connection prior to destroying registry and event
queue. Thus causing problems. Hopefully this change fixes the segfault
on build.kde.org.
2016-10-28 08:57:22 +02:00
Martin Gräßlin
3f0c879713 [autotests] Try fixing TestWaylandOutputManagement
The test has KWayland::Client objects like Registry as member variables
of the test object. This causes the objects to be destroyed with the
dtor after cleanupTestCase is run which destroys the connection and
Wayland server. At least on the CI system this seems to cause problem.

In general our tests do not keep any state around, especially not
KWayland::Client objects. The normal way is to have a new dedicated
client connection for every test method. This test doesn't follow this
approach at all.

In case that this change does not fix the test and still crashes on
build.kde.org the only option is to drop the test and replace it by a
new variant which follows the approach of other tests.
2016-10-28 08:39:28 +02:00
Martin Gräßlin
37d17b2929 [autotests] Improve TestWaylandOutputManagement::cleanupTestCase
Reorder the cleanup code. It doesn't make sense to delete the client
side objects after deleting the server side objects. This might be a
reason for the failing tests on build.kde.org.
2016-10-28 07:39:15 +02:00
Martin Gräßlin
945b5f086f [tools] Fix generation of wayland_pointer_p.h
It was missing the _p suffix.
2016-10-26 08:44:42 +02:00
Martin Gräßlin
971694c28f [tools] Generate eventQueue methods only for global classes
The event queue gets set by the factory method for resource classes.
2016-10-25 14:29:19 +02:00