Commit graph

47 commits

Author SHA1 Message Date
Martin Gräßlin
6fe14f73d2 [server] Pass keyboard focus to child surface on pointer click
If the focused pointer and keyboard surface is the same we use pointer
clicks as a hint to which child surface should have keyboard focus.

Keyboard focus handling for sub surfaces is rather limited overall.
We just don't have a good model on how to determine which child surface
should get the keyboard focus. When passing focus to a surface there
is no way to know which of the sub-surfaces should get the focus.
Ideally the client should handle this, but that's just not the case.

The best we have is a reference through the pointer. But that's of
course also limited. Keyboard focus passed to the surface for another
reason (Alt+Tab) cannot select the proper sub-surface without interaction
from another input device.

Reviewers: #plasma

Subscribers: plasma-devel

Projects: #plasma

Differential Revision: https://phabricator.kde.org/D1330
2016-04-07 07:57:00 +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
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
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
Marco Martin
ac4ef26990 fake a movement before sending a click
this makes the touch to mouse clicks mapping for xwayland
clients be a bit more reliable in accepting and correctly managing events
2015-09-28 15:18:19 +02:00
Martin Gräßlin
71fd67cca7 [server] Move static methods into anonymous namespace 2015-09-10 09:45:31 +02:00
Martin Gräßlin
bbfdf3f72a [server] Make s_version a static member of private class
Follows a useful change added in the kwaylandScanner tool the
s_version becomes part of the Private class.

Also fixes the related generation in the tool.
2015-09-10 09:23:36 +02: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
66838ccf33 Fix compiler warnings 2015-09-02 16:20:10 +02:00
Martin Gräßlin
13bf4c9484 Implement repeat info on wl_keyboard protocol
* Raises wl_seat supported version to 4 in both server and client
* Raises wl_keyboard supported version to 4 in wl_keyboard
* wl_pointer and wl_touch are still on version 3
* Raises minimum Wayland version to 1.6
2015-09-02 16:04:14 +02:00
Marco Martin
7fd15ea066 generate fake mouseevents on touch for xwayland
on xwayland clients, send mouse press, move and release
corresponding to touchDown, move and release
this gives a very basic touchscreen support on
xwayland clients

reviewed-by: Martin Graesslin <mgraesslin@kde.org>
2015-06-20 14:21:27 -07:00
Martin Gräßlin
946b1c8d78 Fix 3e53a6283d
The most trivial changes are the one which needs to be tested!
2015-06-14 05:48:36 +02:00
Martin Gräßlin
3e53a6283d [server] Add safety checks in SeatInterface::setFocusedFooSurface
Check whether the resource for the Keyboard/Pointer/TouchInterface
is still valid before trying to use it.

This was hitting crashes in wayland during the wl_foo_send_enter
calls.
2015-06-14 00:52:55 +02:00
Martin Gräßlin
b47c6566a8 [server] Send keymap if we have one when creating a keyboard 2015-05-28 10:15:42 +02:00
Martin Gräßlin
41f5d246f6 Fix unused variable warnings
Thanks CI system for reporting them.
2015-03-25 13:46:29 +01:00
Martin Gräßlin
49b926e249 [server] Add support for touch events in SeatInterface 2015-03-25 13:31:38 +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
0e0933cbb1 Split SeatInterface::Private into own header file
We need to include the Private in the DataDeviceManager, thus it
needs to be in an own header.
2014-11-27 09:52:11 +01:00
Martin Gräßlin
8f2f94798d Cleanup SeatInterface after refactoring 2014-11-26 15:42:33 +01:00
Martin Gräßlin
7baf5896be Merge SeatInterface::Private::pointerForSurface and ::keyboardForSurface
templated helper method.
2014-11-26 15:34:46 +01:00
Martin Gräßlin
6504e067bc KeyboardInterface inherits Resource 2014-11-26 15:28:47 +01:00
Martin Gräßlin
99598167d7 Refactor KeyboardInterface
The KeyboardInterface gets created per wl_resource. For this all
more global information (e.g. key states) is moved into the
SeatInterface.
2014-11-26 15:00:44 +01:00
Martin Gräßlin
c6281ac64e Move pointer position into the Pointer struct in SeatInterface::Private 2014-11-26 11:57:10 +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
961aaae8f1 [server] Add a SeatInterface::focusedPointer
This method is supposed to return the PointerInterface for the current
focused surface. At the moment it just creates the one global
PointerInterface. The existing SeatInterface::pointer method got
removed as that is actually wrong usage.
2014-11-25 16:04:07 +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
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
Martin Gräßlin
80d0fb1e94 [server] Move KeyboardInterface into dedicated .h and .cpp 2014-11-25 13:39:24 +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
2eb75bdac9 Global::Private can create the wl_global
Version and interface get passed to the ctor allowing Global::Private
to implement ::create instead of providing a pure virtual method.
Also the static bind method is added to the Global::Private which
delegates into a pure virtual method.
2014-11-13 18:43:18 +01:00
Martin Gräßlin
22197da94b Add a base class for all server interfaces of a wl_global
New base class KWayland::Server::Global which all Interface classes
for a wl_global inherit. Furthermore there is a shared base class
for all the Private classes of that type.
2014-11-13 15:10:35 +01:00
Martin Gräßlin
dd50148187 [server] Interface method returning wl_resource* is called ::resource
Simplifies using the library as all Interfaces have the same methods.
Note: there are interfaces not providing the wl_resource* method.
2014-11-13 13:05:01 +01:00
Martin Gräßlin
ce7a6edaea Overloads taking Qt::MouseButton added to Server::SeatInterface
Qt::MouseButton is mapped to the linux buttons. The mapping does
not match the mapping used in QtWayland module [1] as that seems
to be incorrect to me. E.g. Qt::BackButton is not mapped to BTN_BACK.

[1] qtwayland/src/client/qwaylandinputdevice.cpp
2014-11-10 14:51:09 +01:00
Martin Gräßlin
435c88f1e0 Add static SeatInterface *SeatInterface::get(wl_resource*)
No auto-test for it as we don't track the created resources which
makes testing difficult. Implicit testing will be added through
DataDeviceInterface.
2014-11-05 15:29:18 +01:00
Martin Gräßlin
c2f89128d5 Add d-pointer to Server::KeyboardInterface 2014-09-18 17:14:50 +02:00
Martin Gräßlin
8eb325ee69 Add d-pointer to Server::PointerInterface 2014-09-18 16:58:23 +02:00
Martin Gräßlin
4b3f8ccc8d Add d-pointer to Server::SeatInterface 2014-09-18 16:35:28 +02:00
Martin Gräßlin
a8c7c16c94 Use namespace KWayland::Server instead of KWin::WaylandServer
It's no longer part of KWin.
2014-09-17 16:10:38 +02:00
Martin Gräßlin
3c87cea7a8 Change to LGPLv2+
I'm the only copyright holder of the code in this repository, thus
I can change from GPL to LGPL!
2014-09-17 15:57:56 +02:00
Martin Gräßlin
b51fb1f8b9 [kwin_wayland] define WL_SEAT_NAME_SINCE_VERSION if not defined
Apparently not yet in wayland server library on build.kde.org.
2014-09-02 11:11:26 +02:00
Martin Gräßlin
9d780deeb2 [kwin_wayland] Add SeatInterface to server module
So far the Seat interface is provided together with pointer and
keyboard. As always touch is not yet implemented. The pointer interface
is still lacking the set cursor callback. Keyboard on the other hand is
complete.

Both Keyboard and Pointer have the concept of a focused surface and only
to the bound interface belonging to the same client as the focused
surface events are sent.

The change comes with a set of new auto tests also verifying the client
side which wasn't possible before as we couldn't fake events.
2014-09-02 10:55:33 +02:00