Commit Graph

25 Commits

Author SHA1 Message Date
Simon Ser 5cde35923c Simplify globals implementation by removing destructors
Some globals are static and it doesn't make sense to destroy them before
the wl_display. For instance, wl_compositor should be created before the
display is started and shouldn't be destroyed.

For these globals, we can simplify the code by removing the destructor
and stop keeping track of wl_resources (these will be destroyed with the
wl_display by libwayland).
2019-11-25 09:01:46 -05:00
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
emersion 6291e84532
data-device: refactor wlr_drag 2019-02-20 18:42:29 +01:00
emersion 07e1bedb08
data-device: make old offers inert before sending selection
Fixes https://github.com/swaywm/wlroots/issues/1383
2019-02-18 16:36:23 +01:00
emersion f1d3aeff9a
data-device: fix crash when setting the same selection twice 2019-01-31 20:33:48 +01:00
emersion 909b3b16f3
data-device: add wlr_data_offer.type 2019-01-24 12:18:40 +01:00
emersion 3f82eb1853
data-device: make device inert when seat is destroyed 2019-01-24 12:18:39 +01:00
emersion c20d413f8a
data-device: fix missing listener removal 2019-01-24 12:18:00 +01:00
emersion 0040f7089f
data-device: unexport wlr_seat_client_send_selection 2019-01-24 12:15:18 +01:00
emersion 1a2727cc38
data-device: send offer on get_data_device 2019-01-24 12:12:55 +01:00
emersion 84f278eca1
data-device: remove data_source_send_offer 2019-01-24 12:12:55 +01:00
emersion 1150ff13ce
data-device: make sources inert, rename cancel to destroy 2019-01-24 12:12:55 +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 ae1dd635b1
data-device: fix dangling listener in seat_client_selection_source_destroy 2018-12-30 02:48:03 +01:00
emersion 5d26da9d15
data-device: allow multiple devices for the same seat
This commit makes it possible for a single client to have multiple data devices
for the same seat. This fixes issues with Firefox.

This mainly removes wlr_data_source.offer. We make sure we create one data
offer per device. We now make the offer inert when the source is destroyed.

Fixes the second half of https://github.com/swaywm/wlroots/issues/1041
2018-11-26 12:35:48 +01:00
emersion 2d0c5ec78e
Use _POSIX_C_SOURCE, use shm_open 2018-11-06 08:29:23 +01:00
emersion f44003f04b data-device: remove wlr_data_source.seat_client
Since the source doesn't always come from a client, this field
doesn't make sense. It is replaced by a new "finalized" field in
wlr_client_data_source. This is used to make sure set_actions is
not sent after start_drag has been sent.

A check in data_offer_choose_action has been removed: if an offer
has been sent then start_drag has been called, no need to check.

I also wanted to add a check for wl_data_source.offer, but it
turns out (1) this isn't in the spec (2) it breaks GTK+.

This is some preliminary work for Firefox on Wayland compatibility.
2018-10-07 16:01:57 +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 7cbef15206
util: add wlr_ prefix to log symbols 2018-07-09 22:49:54 +01: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
emersion 5d37b14116
data-device: make sure resources are correctly destroyed 2018-05-03 20:22:51 +01:00
emersion 1e563e7ecf
data-device: split into multiple files 2018-05-02 18:04:10 +01:00