mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-07 05:55:58 +01:00
gtk-primary-selection: basic serial validation
This commit is contained in:
parent
3699496256
commit
8c573bc7c6
2 changed files with 10 additions and 1 deletions
|
@ -36,6 +36,7 @@ struct wlr_gtk_primary_selection_device {
|
||||||
struct wl_list resources; // wl_resource_get_link
|
struct wl_list resources; // wl_resource_get_link
|
||||||
|
|
||||||
struct wl_list offers; // wl_resource_get_link
|
struct wl_list offers; // wl_resource_get_link
|
||||||
|
uint32_t selection_serial;
|
||||||
|
|
||||||
struct wl_listener seat_destroy;
|
struct wl_listener seat_destroy;
|
||||||
struct wl_listener seat_focus_change;
|
struct wl_listener seat_focus_change;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#define _POSIX_C_SOURCE 200809L
|
#define _POSIX_C_SOURCE 200809L
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <inttypes.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
@ -202,7 +203,14 @@ static void device_handle_set_selection(struct wl_client *client,
|
||||||
source = &client_source->source;
|
source = &client_source->source;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: serial checking
|
// 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);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue