Commit graph

22 commits

Author SHA1 Message Date
Martin Flöser
e087a3666b Fix regression caused by backward compatibility support in data source
We should only enforce the check whether a data source has set the
actions for drag on drop on a selection if it's at least version 3. For
backward compatibility we used to set a default action which would
ensure that a version <3 and >3 client can interact with each other. But
due to that the action was set to a default value which breaks any
selection. Sorry about that.

This change ensures the backward compatibility behavior does not break
selection.

As the regression causes all clients to quit it is a severe regression
which requires fast action. Due to that I'm doing a maintainer push
without review. I encourage everyone to do a post commit review.

Sorry for not noticing the regression before. The backward compatibility
was the last thing I added in that patch set and apparently I did not
run all tests again.
2017-12-26 21:55:11 +01:00
Martin Flöser
42432a14fc Add support for version 3 of data device manager interface
Summary:
The main difference compared to version 2 is additional drag and drop
actions. The source and destination can negotiate whether the data
should be copied or moved or the user should be asked for either or.
This seems to be important for GTK, but is not yet implemented in Qt.

The main motivation for adding support is that it is required by SDL to
launch on Wayland.

BUG: 386993

Test Plan: Extended test case, sdl apps now start

Reviewers: #frameworks, #plasma, #kwin

Subscribers: plasma-devel

Tags: #plasma_on_wayland, #frameworks

Differential Revision: https://phabricator.kde.org/D9136
2017-12-26 20:41:43 +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
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
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
ab98448fec [server] Standardize the destructor request handling for Resources
Summary:
This change standardizes the behavior regarding the destructor request.

The destructor should destroy the resource and nothing else. The
Wayland library invokes the static unbind method once the resource is
destroyed. The implementation provided by Resource::Private::unbind
triggers a delete later on the Resource. So there is no need to trigger
a deleteLater from the destructor request callback.

This change adds a generic implementation to Resource::Private which is
now used by all inheriting classes replacing the custom implementations.

Test Plan:
For a few Resources the test is extended to ensure that the Resource
gets deleted on server side.

Reviewers: #plasma

Subscribers: plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D1679
2016-05-30 08:16:07 +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
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
dd5c39d2a6 Implement release for wl_data_device
Callback added to server and client calls release instead of destroy.
2015-09-09 09:34:51 +02:00
Martin Gräßlin
963651632e Add safety checks to DataDeviceInterface
It's possible that the Resource got already unbound when calling
into clear selection, etc.
2014-11-27 14:02:54 +01:00
Martin Gräßlin
78486bb506 Handle DataDeviceInterface selection in SeatInterface
The selection is supposed to be sent to the DataDeviceInterface just
before getting keyboard focus. In order to do that the SeatInterface
keeps track of the DataDeviceInterface which is the current selection
and the DataDeviceInterface of the focused keyboard client.

SeatInterface friends DataDeviceManagerInterface so that the latter
can register each created DataDevice for the SeatInterface.
2014-11-27 13:38:24 +01:00
Martin Gräßlin
ff806d1657 Move focused pointer surface API to SeatInterface
There can only be one focused surface per Seat, thus the information
should be hold in the seat.

This only adjusts the API, the actual data is still hold in the
PointerInterface. This still needs adjustment.
2014-11-25 15:54:28 +01:00
Martin Gräßlin
e6b91f5628 [server] Move PointerInterface into own .h and .cpp 2014-11-25 13:53:16 +01:00
Martin Gräßlin
68ce470231 Add a parentResource to Resource 2014-11-20 16:40:14 +01:00
Martin Gräßlin
c71cf3999c Resource holds a ClientConnection instead of a wl_client 2014-11-19 16:53:56 +01:00
Martin Gräßlin
8685a0e972 Create wl_resource in Resource::Private instead of subclasses
Required information is passed through the ctor of Private.
::create is still virtual as ShellSurfaceInterface is retrieving
client information. This can be fixed once we have a better wl_client
encapsulation class.
2014-11-14 15:33:21 +01:00
Martin Gräßlin
cee32f902a Move static unbind method from derived classes to Resource::Private
All classes had exactly the same implementation, so it's a good idea
to share the implementation.
2014-11-14 11:01:54 +01:00
Martin Gräßlin
0fb42d102e Move q-ptr to Resource::Private
In the derived classes a q_func() is added which casts the q-ptr
back to the Resource derived class.
2014-11-14 10:55:06 +01:00
Martin Gräßlin
de62216357 Add cast from wl_resource to Private to Resource::Private
Replaces the custom implementation in each of the derived classes.
2014-11-14 10:20:43 +01:00
Martin Gräßlin
53a4455c47 [server] Introduce a base class Resource
The Resource base class is supposed to be used by all interface
classes which get created for a wl_resource.

Most interface classes are adjusted, but there are some exceptions:
* BufferInterface: is different as the wl_resource is already created
* PointerInterface and KeyboardInterface: those two need changes, the
  implementation differs from all other interface implementations.
2014-11-14 09:45:02 +01:00
Martin Gräßlin
7763cd94a7 Add wl_data_offer on Client and Server side
Only selection part is implemented, drag'n'drop still needs to be
implemented.

Unit test is not properly testing whether the data can be transferred.
This needs some better architecture to have multiple processes which
perform the source and target part.
2014-11-06 16:56:50 +01:00
Martin Gräßlin
421cfaafc3 Add implementation for wl_data_device in Server and Client
On the client side anything related to wl_data_offer is not yet
implemented.
2014-11-06 10:02:49 +01:00