mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2025-10-31 22:25:21 -04:00
Merge pull request #1485 from emersion/data-device-serial
primary-selection: add a serial argument
This commit is contained in:
commit
365a75139c
9 changed files with 32 additions and 19 deletions
|
|
@ -163,7 +163,8 @@ void wlr_seat_destroy(struct wlr_seat *seat) {
|
|||
seat->selection_source = NULL;
|
||||
}
|
||||
|
||||
wlr_seat_set_primary_selection(seat, NULL);
|
||||
wlr_seat_set_primary_selection(seat, NULL,
|
||||
wl_display_next_serial(seat->display));
|
||||
|
||||
struct wlr_seat_client *client, *tmp;
|
||||
wl_list_for_each_safe(client, tmp, &seat->clients, link) {
|
||||
|
|
|
|||
|
|
@ -208,16 +208,7 @@ static void device_handle_set_selection(struct wl_client *client,
|
|||
source = &client_source->source;
|
||||
}
|
||||
|
||||
// TODO: improve serial validation
|
||||
if (device->seat->primary_selection_source != NULL &&
|
||||
device->selection_serial - serial < UINT32_MAX / 2) {
|
||||
wlr_log(WLR_DEBUG, "Rejecting set_selection request, invalid serial "
|
||||
"(%"PRIu32" <= %"PRIu32")", serial, device->selection_serial);
|
||||
return;
|
||||
}
|
||||
device->selection_serial = serial;
|
||||
|
||||
wlr_seat_set_primary_selection(device->seat, source);
|
||||
wlr_seat_set_primary_selection(device->seat, source, serial);
|
||||
}
|
||||
|
||||
static void device_handle_destroy(struct wl_client *client,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <wlr/types/wlr_primary_selection.h>
|
||||
#include <wlr/util/log.h>
|
||||
#include "util/signal.h"
|
||||
|
||||
void wlr_primary_selection_source_init(
|
||||
|
|
@ -50,7 +51,14 @@ static void seat_handle_primary_selection_source_destroy(
|
|||
}
|
||||
|
||||
void wlr_seat_set_primary_selection(struct wlr_seat *seat,
|
||||
struct wlr_primary_selection_source *source) {
|
||||
struct wlr_primary_selection_source *source, uint32_t serial) {
|
||||
if (seat->primary_selection_source != NULL &&
|
||||
seat->primary_selection_serial - serial < UINT32_MAX / 2) {
|
||||
wlr_log(WLR_DEBUG, "Rejecting set_selection request, invalid serial "
|
||||
"(%"PRIu32" <= %"PRIu32")", serial, seat->primary_selection_serial);
|
||||
return;
|
||||
}
|
||||
|
||||
if (seat->primary_selection_source != NULL) {
|
||||
wl_list_remove(&seat->primary_selection_source_destroy.link);
|
||||
wlr_primary_selection_source_destroy(seat->primary_selection_source);
|
||||
|
|
@ -58,6 +66,8 @@ void wlr_seat_set_primary_selection(struct wlr_seat *seat,
|
|||
}
|
||||
|
||||
seat->primary_selection_source = source;
|
||||
seat->primary_selection_serial = serial;
|
||||
|
||||
if (source != NULL) {
|
||||
seat->primary_selection_source_destroy.notify =
|
||||
seat_handle_primary_selection_source_destroy;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue