aboutsummaryrefslogtreecommitdiff
path: root/xwayland
diff options
context:
space:
mode:
authorManuel Stoeckl <code@mstoeckl.com>2019-06-27 15:43:58 -0400
committerDrew DeVault <sir@cmpwn.com>2019-06-30 15:01:05 -0400
commitedb30a68283889aeef4ce357609273652cdbb86c (patch)
treeb239e88bfc5bc5de21a102d871660134afd1f616 /xwayland
parentfb739b829305a60f99abb6b847b45aeb9c6cbf77 (diff)
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.
Diffstat (limited to 'xwayland')
-rw-r--r--xwayland/selection/incoming.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/xwayland/selection/incoming.c b/xwayland/selection/incoming.c
index 290af0bf..ceca1190 100644
--- a/xwayland/selection/incoming.c
+++ b/xwayland/selection/incoming.c
@@ -349,7 +349,7 @@ static void xwm_selection_get_targets(struct wlr_xwm_selection *selection) {
bool ok = source_get_targets(selection, &source->base.mime_types,
&source->mime_types_atoms);
if (ok) {
- wlr_seat_request_set_selection(xwm->seat, &source->base,
+ wlr_seat_request_set_selection(xwm->seat, NULL, &source->base,
wl_display_next_serial(xwm->xwayland->wl_display));
} else {
wlr_data_source_destroy(&source->base);
@@ -424,10 +424,10 @@ int xwm_handle_xfixes_selection_notify(struct wlr_xwm *xwm,
// A real X client selection went away, not our
// proxy selection
if (selection == &xwm->clipboard_selection) {
- wlr_seat_request_set_selection(xwm->seat, NULL,
+ wlr_seat_request_set_selection(xwm->seat, NULL, NULL,
wl_display_next_serial(xwm->xwayland->wl_display));
} else if (selection == &xwm->primary_selection) {
- wlr_seat_request_set_primary_selection(xwm->seat, NULL,
+ wlr_seat_request_set_primary_selection(xwm->seat, NULL, NULL,
wl_display_next_serial(xwm->xwayland->wl_display));
} else if (selection == &xwm->dnd_selection) {
// TODO: DND