Commit Graph

92 Commits

Author SHA1 Message Date
Simon Ser ca45f4490c Remove all wayland-server.h includes
The documentation for wayland-server.h says:

> Use of this header file is discouraged. Prefer including
> wayland-server-core.h instead, which does not include the server protocol
> header and as such only defines the library PI, excluding the deprecated API
> below.

Replacing wayland-server.h with wayland-server-core.h allows us to drop the
WL_HIDE_DEPRECATED declaration.
2019-07-27 15:49:32 -04:00
Manuel Stoeckl ded441ffd5 wlr_seat: Fix edge cases with serial validation 2019-06-30 15:01:05 -04:00
Manuel Stoeckl edb30a6828 Implement serial validation for selection requests
This change tracks, for each wlr_seat_client, the most recent serial
numbers which were sent to the client. When the client makes a
selection request, wlroots now verifies that the serial number
associated with the selection request was actually provided to that
specific client. This ensures that the client that was most
recently interacted with always has priority for its copy selection
requests, and that no other clients can incorrectly use a larger serial
value and "steal" the role of having the copy selection.

Also, the code used to determine when a given selection is superseded
by a newer request uses < instead of <= to allow clients to make
multiple selection requests with the same serial number and have the
last one hold.

To limit memory use, a ring buffer is used to store runs of sequential
serial numbers, and all serial numbers earlier than the start of the
ring buffer are assumed to be valid. Faking very old serials is
unlikely to be disruptive.

Assuming all clients are correctly written, the only additional
constraint which this patch should impose is that serial numbers
are now bound to seats: clients may not receive a serial number
from an input event on one seat and then use that to request
copy-selection on another seat.
2019-06-30 15:01:05 -04:00
Ashkan Kiani 06a13203dd Use a set to track pointer button state.
In addition to `button_count`, we keep track of the current buttons
pressed just as in `wlr_keyboard`.

Add `set_add` and `set_remove` to assist with this. These functions can
only be used with values greater than 0 (such as the button/key masks
for keyboards and pointers).

Partially addresses:
- https://github.com/swaywm/wlroots/issues/1716
- https://github.com/swaywm/wlroots/issues/1593
2019-06-16 00:59:53 +03:00
emersion 2fde5c95d8 seat: use wlr_button_state enum instead of uint32_t 2019-03-01 12:36:03 -07:00
emersion 6291e84532
data-device: refactor wlr_drag 2019-02-20 18:42:29 +01:00
emersion d6de329d98
seat: don't send motion if pointer hasn't moved 2019-01-30 15:24:17 +01:00
emersion 5de26ad8ed
pointer: add a frame event
Frame events group logically connected pointer events. It makes sense to make
the backend responsible for sending frame events, since once the events are
split (ie. once the frame events are stripped) it's not easy to figure out
which events belongs to which frame again.

This is also how Weston handles frame events.

Fixes https://github.com/swaywm/wlroots/issues/1468
2019-01-26 11:04:05 +01:00
emersion a1f9d7ad9e
data-device: keep track of wlr_data_offer in wlr_seat lists 2019-01-24 12:18:41 +01:00
emersion 4cb0697e57 data-device, primary-selection: add request_set_selection
This makes compositors able to block and/or customize set_selection requests
coming from clients. For instance, it's possible for a compositor to disable
rich selection content (by removing all MIME types except text/plain). This
commit implements the design proposed in [1].

Two new events are added to wlr_seat: request_set_selection and
request_set_primary_selection. Compositors need to listen to these events and
either destroy the source or effectively set the selection.

Fixes https://github.com/swaywm/wlroots/issues/1138

[1]: https://github.com/swaywm/wlroots/issues/1367#issuecomment-442403454
2019-01-24 11:38:23 +01:00
emersion 06467d2e12
primary-selection: add a serial argument
The serial needs to be bumped when X11 clients set the selection, otherwise
some Wayland clients (e.g. GTK) will overwrite it when they gain focus.
2019-01-21 19:23:40 +01:00
emersion 9f0720c03a
primary-selection: introduce wlr_primary_selection_source
This is a common interface that can be used for all primary selection
protocols, as discussed in [1]. A new function wlr_seat_set_primary_selection
is added to set the primary selection for all protocols.

The seat now owns again the source, and resets the selection to NULL when
destroyed.

[1]: https://github.com/swaywm/wlroots/issues/1367#issuecomment-442403454
2018-11-29 19:40:28 +01:00
emersion cbe42d1006
gtk-primary-selection: remove offer struct
We don't need it, we can use the device instead.
2018-11-27 19:45:39 +01:00
emersion f001f98cef
gtk-primary-selection: refactor everything, untie from seat
This commits completely refactors wlr_gtk_primary_selection. The goal is to
remove gtk-primary-selection state from the seat and better handle inert
resources where it makes sense.

wlr_seat_client.primary_selection_devices has been removed and replaced by
wlr_gtk_primary_selection_device. This allows us to make offers inert when the
current selection is replaced.

wlr_seat_set_primary_selection has been removed because it relied on wlr_seat
instead of wlr_gtk_primary_selection_device_manager. A new function,
wlr_gtk_primary_selection_device_manager_set_selection (candidate for the
longest function name in wlroots) has been added. It doesn't take a serial
anymore as serial checking only makes sense for set_selection requests coming
from Wayland clients (serial checking is now done in the Wayland interface
implementation).

Since wlr_gtk_primary_selection_device_manager is now required to set the
selection, a new function wlr_xwayland_set_gtk_primary_selection_device_manager
(candidate number two for longest function name) has been added.

Devices are now made inert when the seat goes away.

Future work includes removing the last primary selection bits from the seat,
mainly wlr_seat.primary_selection_source and wlr_seat.events.primary_selection,
replacing those with new fields in wlr_gtk_primary_selection_device. Or maybe
we could keep those in the seat and replace them with a re-usable interface
(for future zwp_primary_selection_v1 support). We need to think how we'll sync
these three protocols (GTK, X11 and wayland-protocols).

See https://github.com/swaywm/wlroots/issues/1388
2018-11-27 18:57:26 +01:00
emersion 811a4d997b
Rename wlr_primary_selection to wlr_gtk_primary_selection 2018-11-23 11:58:56 +01:00
emersion fadbdcd13c seat: remove unused keyboard focus_change event 2018-09-27 12:21:30 +02:00
Las d446c53fe1 Make (wlr_)seat_client_from_pointer_resource public 2018-09-18 10:14:33 +02:00
Las 252bcce2f3 Add focus change event for seats 2018-09-18 10:14:33 +02:00
Drew DeVault 211ae764fd Initial pass on API stability guarantees
This introduces -DWLR_USE_UNSTABLE and adds information regarding the
stability status to all headers. I started with a conservative set of
headers to mark as stable:

- types/wlr_matrix.h
- util/edges.h
- util/log.h
- util/region.h
- xcursor.h
2018-07-29 19:20:34 -04:00
Markus Ongyerth 9a6f77fc2c tablet-v2: fix merge commits and test again
There were a few issues after rebase, that the merge algorithm didn't
throw at my face:

wlr_output did a check on the actual role, not a string anymore, so that
had to go to allow tablet-v2 to set cursor surfaces.
A few L_DEBUG/L_ERRORs were still around
There was a user-after-free in tablet-group free()ing, probably after
insufficient testing from a previous feedback pass
2018-07-14 10:29:22 +02:00
Drew DeVault c0b4217fce
Merge pull request #1116 from emersion/surface-role
surface: replace wlr_surface_set_role_committed with wlr_surface_role
2018-07-11 15:27:42 -07:00
emersion deeca53e33
Rename wl_resources to resource, wl_global to global 2018-07-08 19:21:31 +01:00
emersion 33db4263a0
surface: replace wlr_surface_set_role_committed with wlr_surface_role 2018-07-07 22:45:16 +01:00
Dominique Martinet 51b9883ea0 seat: allow clients to bind to seat multiple times
This lets clients bind to a seat multiple times by re-using the existing
wlr_seat_client whenever a duplicate request happens.
Previously, an independant wlr_seat_client would be created and only
events from one would be processed.

Fixes #1023.
2018-06-04 22:31:36 +09:00
emersion db84379242
Send axis source event 2018-05-12 13:53:21 +01:00
emersion 0b58579564
Add support for discrete axis values 2018-05-12 13:34:58 +01:00
emersion 2cff6dbd63
seat: split into multiple files 2018-05-03 10:30:47 +01:00
Drew DeVault 6710de9878 Merge branch 'master' into xwayland-dnd 2018-04-05 15:04:49 -04:00
Drew DeVault 56deff41b6 Implement input inhibit in rootston 2018-04-03 15:09:53 -04:00
emersion 743466d475
data-device: add seat.drag_source 2018-03-29 11:33:40 -04:00
emersion 0d7a81ccdf
xwayland: send DND_ENTER 2018-03-28 12:59:11 -04:00
emersion 392d54a35d
Wrap wl_resource_get_user_data into safer helper functions
This ensures we're not incorrectly casting a resource.

Fixes #628
2018-02-13 23:48:46 +01:00
emersion c2e1474010
Reformat all #include directives 2018-02-12 21:29:23 +01:00
emersion 4d282c8590
rootston: damage tracking for drag icons 2018-01-23 13:37:58 +01:00
Tony Crisci b40a5f084a keyboard grab enter with modifiers 2018-01-06 11:06:09 -05:00
Tony Crisci 0ef2df21f2 compositor modifier hook 2018-01-05 07:00:50 -05:00
emersion 38ed3b4245
seat: rename selection_source to selection_data_source, remove unused data_device 2017-12-30 09:58:04 +01:00
Dominique Martinet 58488ec5ce wlr_seat: add destroy signal 2017-12-29 17:55:03 +01:00
Tony Crisci 815d71a3aa validate grab serial for shell events 2017-12-27 08:04:01 -05:00
emersion a95d09d561
Add missing gtk-primary-selection interfaces 2017-12-22 22:22:29 +01:00
emersion 8af6fbd7a0
Support multiple resources per seat client for data_device 2017-12-16 14:22:59 +01:00
emersion 4f0443a344
Support multiple resources per seat client for pointer, keyboard, touch 2017-12-16 13:53:39 +01:00
emersion c67a5824b8
Merge branch 'master' into display-destroy 2017-12-11 16:14:03 +01:00
emersion a3c0f97810
Make keyboard repeat info configurable 2017-12-08 17:03:05 +01:00
emersion 983ea3033f
Listen to display destroy in seat 2017-12-07 01:02:07 +01:00
Tony Crisci af23192ede wlr-seat: remove client bound and unbound signal 2017-11-19 11:13:59 -05:00
Tony Crisci 3b74db467b data-device: wlr-drag-icon 2017-11-19 09:33:55 -05:00
Tony Crisci fb18e345a6 wlr-seat: return serial from touch down interface 2017-11-16 17:44:10 -05:00
Tony Crisci 12758a00a2 rootston: touch to focus 2017-11-15 08:34:48 -05:00
Tony Crisci ac4841ba37 put dnd icon in the right place 2017-11-15 08:34:48 -05:00