Commit graph

351 commits

Author SHA1 Message Date
Martin Gräßlin
04ccf04596 [server] Add a workaround for a freeze in QtWayland
Summary:
See: https://bugreports.qt.io/browse/QTBUG-52092

Freeze happens if a sub-surface is rendered to before the main surface
is rendered. The compositor has no chance to know that this is a window
which needs to be rendered, thus the application might freeze without
ever becoming visible.

Famous example applications being affected: all kcms with a nested
QQuickView. E.g.: kcmshell5 kwineffects

Reviewers: #plasma

Subscribers: plasma-devel

Projects: #plasma

Differential Revision: https://phabricator.kde.org/D1208
2016-03-23 17:04:26 +01:00
Martin Gräßlin
84118fad13 [server] Add method to get to the main surface from a sub surface
Summary:
Recursively go up to the main surface, that is the top level surface
which doesn't have a parent.

This is useful to know to which surface tree a sub-surface belongs to.

Reviewers: #plasma

Subscribers: plasma-devel

Projects: #plasma

Differential Revision: https://phabricator.kde.org/D1207
2016-03-23 17:01:14 +01:00
Martin Gräßlin
bfc94ce985 [server] Improve variable naming
transformFactorChanged -> transforChanged. It's not a factor.

Reviewed-By: sebas
2016-03-23 14:34:51 +01:00
Martin Gräßlin
610fbc672f [server] Don't double buffer adding/removing of sub-surfaces
QtWayland doesn't commit the parent surface when creating a sub-surface.
This results in a QtWayland application to freeze as it renders to the
surface and waits for the frame rendered, which it will never get as the
Compositor waits for the commit on the parent prior to mapping the
sub-surface.

To work around this behavior, we apply the adding/removing directly.
The behavior around this is actually not fully documented, so QtWayland
is not wrong per se. See:

https://lists.freedesktop.org/archives/wayland-devel/2016-March/027540.html

Once this is properly clarified and implemented in the Client, we should
revert this change.

Differential Revision: https://phabricator.kde.org/D1191
2016-03-23 14:21:29 +01:00
Martin Gräßlin
263e5d7969 [server] Add a subSurfaceTreeChanged signal to SurfaceInterface
The idea behind this signal is to notify whenever the tree of sub
surfaces changes in a way that a repaint of the Surface is required.
Possible situations are:
* surface damaged
* surface unmapped
* subsurface added/removed
* subsurface moved (position changed)
* subsurface stacking changed

Ideally it would be possible to provide the actual area which needs
repainting, but due to the possible complexity of the tree, synced
and desynced changes this doesn't look worth the effort. A user of
the signal might trigger too many repaints with it, but if it really
wants to be only notified about the actual changes, it can just track
the individual sub-surfaces.
2016-03-23 14:20:26 +01:00
Martin Gräßlin
b7f470e51b [server] Cache the state of synchronized sub surfaces
When committing the state of a sub-surface, the state should not
be immediately applied if the sub-surface is in synchronized mode.
Instead it should be cached and only applied after the parent surface's
state is applied.

To implement this the Surface::Private has now a third cached state
buffer. When committing the state is either swapped between pending and
current or pending and subSurfacePending. Once the parent state is
applied the state is swapped between subSurfacePending and current.

The logic for applying state changes is changed. Instead of copying the
complete state object, the individual state changes are now copied and the
source gets completely reset to default values. Only the children tree is
copied back, as that list needs to be modified.
2016-03-23 14:20:26 +01:00
Martin Gräßlin
8323d217a6 [server] Add a bool SubSurfaceInterface::isSynchronized() const
The mode is not sufficient to determine whether a SubSurface is in
synchronized mode.

Quoting spec:
"Even if a sub-surface is in desynchronized mode, it will behave as in
synchronized mode, if its parent surface behaves as in synchronized mode.
This rule is applied recursively throughout the tree of surfaces.
This means, that one can set a sub-surface into synchronized mode, and
then assume that all its child and grand-child sub-surfaces are
synchronized, too, without explicitly setting them."
2016-03-21 16:03:31 +01:00
Martin Gräßlin
05993458e2 [server] Send frameRendered to all sub-surfaces
If a surface got rendered it implies that all sub-surfaces also got
rendered. So pass the frameRendered to the complete sub-surface tree.
2016-03-21 16:03:31 +01:00
Martin Gräßlin
598896987b [tests] Add a sub-surface test application
The test application creates a sub-surface tree consisting of overall
three surfaces:
* blue main surface
* red sub surface
* green sub surface to the red sub surface

All surfaces are in synchronized mode. There is a timer to turn the
green surface into yellow after five seconds.
2016-03-21 16:03:31 +01:00
Martin Gräßlin
35e50175fd [client] Add setScale to Surface
Summary:
The wrapper for wl_surface::set_buffer_scale was still missing.
Main reason for implementation is the need for the added auto-test.

Reviewers: #plasma

Subscribers: plasma-devel

Projects: #plasma

Differential Revision: https://phabricator.kde.org/D1188
2016-03-21 15:59:23 +01:00
Martin Gräßlin
09176d06b6 Merge branch 'Plasma/5.6' 2016-03-15 11:01:31 +01:00
Martin Gräßlin
5295d9d330 [server] Add more Q_DECLARE_METATYPE
For some types used in signals.
2016-03-15 10:59:08 +01:00
Martin Gräßlin
3d1b068da9 Merge branch 'Plasma/5.6' 2016-03-12 12:30:27 +01:00
Martin Gräßlin
31435417fd Add a default mode event to ServerSideDecorationManager
Summary:
The ServerSideDecorationManager gains a new event which gets sent
to the client when it binds the manager. The event indicates the
default server decoration mode used by the server. This allows the
client to know the decoration mode when it creates a decoration and
thus does not need to roundtrip to the server to get the mode.

Reviewers: #plasma, sebas

Subscribers: plasma-devel

Projects: #plasma

Differential Revision: https://phabricator.kde.org/D1129
2016-03-12 12:29:31 +01:00
Martin Gräßlin
eab2ed8106 Merge branch 'Plasma/5.6' 2016-03-09 16:21:12 +01:00
Martin Gräßlin
1d8319cb3b [server] Default initialize the role of a PlasmaShellSurface
We want Normal as default and not a random value.
2016-03-09 16:19:33 +01:00
Martin Gräßlin
e3dc783548 [autotests] Add test case for PlasmaShellSurface setting role 2016-03-09 16:17:01 +01:00
Martin Gräßlin
aa2cc874e2 [server] Declare metatype for KWayland::Server::PlasmaShellSurfaceInterface::Role 2016-03-09 16:16:29 +01:00
Martin Gräßlin
fb6256dc48 [client] Add support for drag'n'drop
DataDevice exposes new methods to get the DataOffer provided through
drag'n'drop and also signals to indicate the various changes on the
DataDevice during drag'n'drop.

This allows to add a first basic auto test for the drag'n'drop
functionality covering both server and client side.
2016-03-03 09:47:12 +01:00
Martin Gräßlin
23a719c8af [server] Implement support for drag'n'drop through pointer device
Summary:
How drag'n'drop works on Wayland:
When a surface has a pointer grab and a button pressed on the surface
(implicit grab) the client can initiate a drag'n'drop operation on the
data device. For this the client needs to provide a data source
describing the data to be transmitted with the drag'n'drop operation.

When a drag'n'drop operation is active all pointer events are interpreted
as part of the drag'n'drop operation, the pointer device is grabbed.
Pointer events are no longer sent to the focused pointer but to the
focused data device. When the pointer moves to another surface an
enter event is sent to a data device for that surface and a leave
event is sent to the data device previously focused. An enter event
carries a data offer which is created from the data source for the
operation.

During pointer motion there is a feedback mechanism. The data offer
can signal to the data source that it can or cannot accept the data
at the current pointer position. This can be used by the client being
dragged from to update the cursor.

The drag'n'drop operation ends with the implicit grab being removed,
that is the pressed pointer button which triggered the operation gets
released. The server sends a drop event to the focused data device.

The data transfer can now be started. For that the receiving client
creates a pipe and passes the file descriptor through the data offer
to the sending data source. The sending client will write into the
file descriptor and close it to finish the transfer.

Drag'n'drop could also be initiated through a touch device grab, but
this is not yet implemented.

The implementation in this change focuses on the adjustments for pointer.
For the user of the library drag'n'drop is implemented in the
SeatInterface. Signals are emitted whenever drag is started or ended.
The interaction for pointer events hardly changes. Motion, button press
and button release can still be indicated in the same way. If a button
release removes the implicit grab the drop is automatically performed,
without the user of the library having to do anything.

The only change during drag and drop for the library user is that
setFocusedPointerSurface is blocked. To update the current drag target
the library user should use setDragTarget. Sending the enter/leave to the
data device gets performed automatically.

The data device which triggered the drag and drop operation is exposed
in the SeatInterface. The user of the library should make sure to render
the additional drag icon provided on the data device. At least QtWayland
based applications will freeze during drag and drop if the icon doesn't
get rendered.

The implementation is currently still lacking the client side and due to
that also auto test. It's currently only tested with QtWayland clients.

Reviewers: #plasma, sebas

Subscribers: plasma-devel

Projects: #plasma

Differential Revision: https://phabricator.kde.org/D1046
2016-03-02 08:18:41 +01:00
Martin Gräßlin
eff6a69544 [autotest] Fix crash in TestWindowManagement::cleanup
Didn't delete the m_windowManagement causing a crash on teardown.
2016-03-02 08:16:23 +01:00
Martin Gräßlin
b6cea86610 [server] Properly initialize Cursor
Summary:
The Cursor wasn't properly initialized. E.g. the damage signal didn't
get connected resulting in the server not noticing when the cursor
changes. The damage only got connected if a new cursor got instelled by
the client on the same pointer.

This change ensures that the Cursor is properly initialized by calling
into the same method as when the cursor changed.

The tests are extended by a new test case for damaging the surface.

Reviewers: #plasma

Subscribers: plasma-devel

Projects: #plasma

Differential Revision: https://phabricator.kde.org/D1022
2016-02-24 16:50:05 +01:00
Martin Gräßlin
b6b22da591 [server] Add a signal SeatInterface::focusedPointerChanged
Summary:
The signal gets emitted whenever the focused PointerInterfaces gets
newly set or reset to nullptr. This is needed to better track the
current cursor image in the compositor.

Reviewers: #plasma, sebas

Subscribers: plasma-devel

Projects: #plasma

Differential Revision: https://phabricator.kde.org/D1007
2016-02-22 14:56:42 +01:00
Martin Gräßlin
0c3c71428e [server] Only send modifiers to client if they actually changed 2016-02-19 11:41:08 +01:00
Martin Gräßlin
565c832d39 [server] Expose executable path in ClientConnection
Summary: Convenient API to get the absolute executable path for the pid.

Reviewers: sebas, mart

Subscribers: plasma-devel

Differential Revision: https://phabricator.kde.org/D858
2016-01-25 10:56:16 +01:00
Martin Gräßlin
f51038c2b4 Add .arcconfig 2016-01-25 10:53:57 +01:00
Martin Gräßlin
b7d0bbaa6f Merge branch 'Plasma/5.5' 2016-01-20 08:48:55 +01:00
Martin Gräßlin
4f8f9849f9 [autotest] Add tests for ServerSideDecoration protocol
REVIEW: 126301
2015-12-17 13:29:38 +01:00
Martin Gräßlin
d2f01dbbbe [server] Add implementation for server side decoration protocol 2015-12-17 13:29:38 +01:00
Martin Gräßlin
07c36644a2 Add protocol for server side decoration 2015-12-17 13:29:38 +01:00
Sebastian Kügler
18458d3252 fix OutputDevice::edid()
This patch transports the EDID data base64-encoded over the wire.

Apparently, we can't just send random QByteArrays as "strings" over, it
has to be encoded and decoded. So...

* base64-encode the data before sending to the client
* base64-decode it on the client side
* document the above, fix documentation woes in the xml definition
* change test accordingly

The test data used was actually invalid, it's a base64 string of the
actual data, so fix the tests (which actually breaks it), and encode on
the server-side and decode on the client side.

REVIEW:126380
2015-12-16 13:57:10 +01:00
Sebastian Kügler
2ce09845ae fix OutputDevice::edid()
This patch transports the EDID data base64-encoded over the wire.

Apparently, we can't just send random QByteArrays as "strings" over, it
has to be encoded and decoded. So...

* base64-encode the data before sending to the client
* base64-decode it on the client side
* document the above, fix documentation woes in the xml definition
* change test accordingly

The test data used was actually invalid, it's a base64 string of the
actual data, so fix the tests (which actually breaks it), and encode on
the server-side and decode on the client side.

REVIEW:126380
2015-12-16 13:53:54 +01:00
Martin Gräßlin
042896a755 [server] Add Display::seats() -> QVector<SeatInterface*>
Similar to OutputInterfaces we can have multiple SeatInterfaces so
expose a way to get to all SeatInterfaces.

REVIEW: 126364
2015-12-15 15:49:12 +01:00
Martin Gräßlin
9d40118f23 [server] Add support for pointer input transformation
So far we only supported mapping global to surface-local coordinates
using a 2D-offset. With this change it's possible to register a
QMatrix4x4 to describe the transformation for going from global to
surface-local coordinates in a full 3D space.

The existing 2D-offset is transformed to use the new matrix based
variant describing a translation.

REVIEW: 126271
2015-12-08 14:15:27 +01:00
Martin Gräßlin
d96319b23d [server] Minimum supported idle timeout is 5 sec
A system isn't idle by definition below 5 sec. Before it's not possible
to properly determine whether the user is still interacting with the
system or not. Thus such a short timeout is not sufficient to determine
whether the system is idle.

Furthermore allowing short timeouts like 1 msec can be used to gather
information from the system. It would allow to reconstruct the timestamp
changes on the seat very reliable, which we do not want a Client to know.

And also this can be used to get events on each key press and key release
and the time between each of the events. This can be used to gather
statistics which would in worst case allow to reconstruct what the user
is typing. Determining where a word starts and ends should be relatively
straight forward if you know the timing. With the length of the word and
the statistics of alphabetic distribution it becomes possible to
reconstruct some words. And also individual letters. With enough
statistic and some known words one can determine how long it takes to
press a certain letter. At that point the idle interface would be a
keylogger.

To prevent such attacks the timestamp is now modified to be at least
5 sec. Why 5 sec? Because it's the smallest timestamp used in the
KIdleTime example application which I do not want to break.
5 sec are long enough to destroy this possible attack.

REVIEW: 126220
2015-12-08 14:15:08 +01:00
Martin Gräßlin
8748ef5199 [autotests] Declare metatype for Qt::Edges
Seems to fail compiling with Qt 5.4, so better fix it.
2015-12-02 09:16:54 +01:00
Martin Gräßlin
fc37f1a9eb [tests] Use QCoreApplication for ShadowTest 2015-11-18 10:21:36 +01:00
Martin Gräßlin
799d11fdb7 [tests] Add a shadow test application 2015-11-18 09:58:19 +01:00
Martin Gräßlin
9558edb96d [server] Fix possible crash after deleting an output(device)interface
After deleting an OutputInterface the resources are not necessarily
destroyed, so unbind might still be called. The existing code just
casted the resource's user data which could then point to invalidated
memory.

This change verifies that we still have a Private* for the resource.
If not, it doesn't have to do any cleanup anyway.

REVIEW: 126097
2015-11-17 16:37:01 +01:00
Martin Gräßlin
a28b9ee1e3 [autotests] Delete connection in thread in TestWindowmanagement
If that fixes the ASAN error, we should do it in all tests.
2015-11-11 09:03:42 +01:00
Martin Gräßlin
d72188130f [autotests] Use QStringLiteral for TestWindowManagement::testWindowTitle 2015-11-11 08:52:37 +01:00
Martin Gräßlin
65a79d98da [autotests] Switch all tests to GUILESS_MAIN 2015-11-11 08:36:31 +01:00
Martin Gräßlin
9297ce9c5a [autotests/client] Use GUILESS_MAIN for TestWindowManagement 2015-11-11 08:31:04 +01:00
Martin Gräßlin
5fe6365faa Fix build
How did that happen? I run the autotest...
2015-11-10 15:07:44 +01:00
Martin Gräßlin
67c45c1a4b [autotests] Destroy a created ClientConnection 2015-11-10 14:51:41 +01:00
Martin Gräßlin
868282fb08 [server] Add a convenient ClientConnection::destroy
Wrapper around wl_client_destroy. In case the ClientConnection got
created through Display::createClient we need to destroy the
ClientConnection again. The exiting client will not cause it to be
destroyed.

Reviewed-By: Bhushan Shah
2015-11-10 13:31:47 +01:00
Martin Gräßlin
f19fedb0f6 [autotests] Cleanup surface handling in TestWindowManagement
For some reason two surfaces were created and the surface not cleaned
up before the connection thread exits.

This caused ASAN to complain.
2015-11-09 09:40:58 +01:00
Marco Martin
2867b84101 address last comments of review 125871 2015-11-04 17:33:36 +01:00
Sebastian Kügler
29a4f496cf Add new interfaces to mapping file
REVIEW:125942
2015-11-04 15:43:26 +01:00
Sebastian Kügler
51ad392378 Autotests for outputmanagement and outputdevices protocols
REVIEW:125942
2015-11-04 15:38:41 +01:00