Commit graph

22 commits

Author SHA1 Message Date
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
f4f2725132 [server] Improve the handling when clients disconnect
Summary:
So far the server component performed manual cleanup in some cases
when a client disconnects. But this is not needed: the Wayland library
calls the static unbind methods which do cleanup. If we cleanup ourselves
this can result in double deletes in the worst case, so let's only use
the Wayland functionality.

Adjusted:
* RegionInterface
* SurfaceInterface
* ShellSurfaceInterface (doesn't take a parent anymore)
* DpmsInterface
* QtSurfaceExtensionInterface
* KeyboardInterface
* PointerInterface
* TouchInterface
* DataOfferInterface
* PlasmaShellSurfaceInterface

For each adjusted case a test case is added to verify that the cleanup
works. Exceptions are DpmsInterface as the actual Resource is not exposed
at all in the Server component and DataOfferInterface as that is server
side created.

Reviewers: #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D1640
2016-05-19 16:21:27 +02:00
Martin Gräßlin
031abb9722 [server] Split PoointerInterface::Private into dedicated header 2016-04-06 11:27:42 +02:00
Martin Gräßlin
84a1d5eadc [server] Support sub-surfaces from PointerInterface
Summary:
The idea behind this change is to make the existance of sub-surfaces
an implementation detail for pointer events. The user of the library
does not need to care about on which sub-surface the pointer is on.
It only needs to care about the main surface and passes the focus to
the main surface.

Internally the PointerInterface takes care of sending the enter to
the sub-surface at the current pointer position. Also whenever the
pointer position changes, the PointerInterface evaluates whether it
triggered a change for the focused sub-surface and sends enter/leave
events accordingly. If the focused sub-surface does not change, it
sends motion events as normally, but of course under consideration
of the sub-surface position.

Overall this means that from pointer usage perspective a user of the
library doesn't need to care about the fact that there are sub-surfaces
at all. The library does the correct thing for it.

Reviewers: #plasma

Subscribers: plasma-devel

Projects: #plasma

Differential Revision: https://phabricator.kde.org/D1329
2016-04-06 09:58:30 +02: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
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
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
5e3bb70612 Fix doxygen generation
Doxygen doesn't like our callback listener at all. We need to hide
it from doxygen, otherwise docu doesn't get generated.
2015-09-09 16:39:50 +02:00
Martin Gräßlin
0d000d0046 [server] Drop incorrect assert from PointerInterface::setFocusedSurface
It's totally fine to have d->resource to be null - there are checks for
it in the method.
2015-06-04 01:36:34 +02:00
Martin Gräßlin
35a854e991 [server] Only send surface leave if resources are still valid
If a resource is null, because e.g. the surface got already destroyed,
wayland will create an error while marshalling arguments causing
the connected client to in worst case abort.
2015-05-26 09:26:19 +02:00
Martin Gräßlin
d28f95f603 [server] Better split flushing events and dispatch events
Running real world applications (Xwayland) showed that it doesn't like
at all that we do a dispatch when we are going to flush. This caused
in a very reliable manner a "Connection closed" error in XWayland, taking
down the client and in return the (xwayland-enabled) server.
2015-04-21 08:56:19 +02:00
Martin Gräßlin
7b1e1bac9b [server] Guard sending events to PointerInterface
After unbind the PointerInterface is not yet deleted, but resource
is null, thus we need to protect the calls.
2015-04-20 09:09:23 +02:00
Martin Gräßlin
4a1888fd43 Add support for setting cursor on the Pointer
Methods on client side added and proper handling on server side.
2015-02-27 17:36:43 +01:00
Martin Gräßlin
91fa946e30 Fix crash in PointerInterface after PointerInterface got destroyed
Connection to lambda was not bound to this.
2014-11-27 13:59:31 +01:00
Martin Gräßlin
bafb03bd3a Drop global position from PointerInterface
No longer needed, not even as a convenience wrapper.
2014-11-26 11:54:53 +01:00
Martin Gräßlin
d425515a99 Move pointer button handling from PointerInterface to SeatInterface
The button state is a seat-global state and not a per pointer state.
All pressed/released and axis events are moved to the SeatInterface
and just invoke the related method on the focused surface pointer.
2014-11-26 11:50:52 +01:00
Martin Gräßlin
a7463f6f32 Turn PointerInterface into a Resource 2014-11-26 11:03:32 +01:00
Martin Gräßlin
ef1a0a0e64 Create one PointerInterface for each pointer wl_resource
Makes PointerInterface more like other Interface classes wrapping
wl_resource. The most important change is the handling of the
focused surface. This is now kept in the SeatInterface and can also
be set if there is no PointerInterface for the client yet.

The unit tests had to be adjusted and some are also disabled as the
button events are not yet moved into SeatInterface.
2014-11-26 10:34:23 +01:00
Martin Gräßlin
41fbb0a6ee [server] Keep timestamp in SeatInterface instead of PointerInterface 2014-11-25 15:29:01 +01:00
Martin Gräßlin
12477a66fc [server] Move pointer position from PointerInterface to SeatInterface
PointerInterface should only wrap a Resource. In order to do so all
global state needs to move into the Global.
2014-11-25 14:24:52 +01:00
Martin Gräßlin
8f9a9fedb1 [server] Drop Display* from PointerInterface and KeyboardInterface
We can get it through the Global passed to PointerInterface and
KeyboardInterface. No need to pass it further around.
2014-11-25 13:58:25 +01:00
Martin Gräßlin
e6b91f5628 [server] Move PointerInterface into own .h and .cpp 2014-11-25 13:53:16 +01:00