mirror of
https://gitlab.freedesktop.org/wayland/wayland.git
synced 2025-11-04 13:29:51 -05:00
data-device: Record the serial number for the current selection
And reject setting a selection that's older than our current selection.
This commit is contained in:
parent
74aec06625
commit
a9f951b003
2 changed files with 10 additions and 3 deletions
|
|
@ -347,10 +347,14 @@ destroy_selection_data_source(struct wl_listener *listener, void *data)
|
||||||
|
|
||||||
WL_EXPORT void
|
WL_EXPORT void
|
||||||
wl_input_device_set_selection(struct wl_input_device *device,
|
wl_input_device_set_selection(struct wl_input_device *device,
|
||||||
struct wl_data_source *source)
|
struct wl_data_source *source, uint32_t serial)
|
||||||
{
|
{
|
||||||
struct wl_resource *data_device, *focus, *offer;
|
struct wl_resource *data_device, *focus, *offer;
|
||||||
|
|
||||||
|
if (device->selection_data_source &&
|
||||||
|
device->selection_serial - serial < UINT32_MAX / 2)
|
||||||
|
return;
|
||||||
|
|
||||||
if (device->selection_data_source) {
|
if (device->selection_data_source) {
|
||||||
device->selection_data_source->cancel(device->selection_data_source);
|
device->selection_data_source->cancel(device->selection_data_source);
|
||||||
wl_list_remove(&device->selection_data_source_listener.link);
|
wl_list_remove(&device->selection_data_source_listener.link);
|
||||||
|
|
@ -358,6 +362,7 @@ wl_input_device_set_selection(struct wl_input_device *device,
|
||||||
}
|
}
|
||||||
|
|
||||||
device->selection_data_source = source;
|
device->selection_data_source = source;
|
||||||
|
device->selection_serial = serial;
|
||||||
|
|
||||||
focus = device->keyboard_focus_resource;
|
focus = device->keyboard_focus_resource;
|
||||||
if (focus) {
|
if (focus) {
|
||||||
|
|
@ -387,7 +392,8 @@ data_device_set_selection(struct wl_client *client,
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* FIXME: Store serial and check against incoming serial here. */
|
/* FIXME: Store serial and check against incoming serial here. */
|
||||||
wl_input_device_set_selection(resource->data, source_resource->data);
|
wl_input_device_set_selection(resource->data, source_resource->data,
|
||||||
|
serial);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct wl_data_device_interface data_device_interface = {
|
static const struct wl_data_device_interface data_device_interface = {
|
||||||
|
|
|
||||||
|
|
@ -266,6 +266,7 @@ struct wl_input_device {
|
||||||
struct wl_listener drag_icon_listener;
|
struct wl_listener drag_icon_listener;
|
||||||
struct wl_signal drag_icon_signal;
|
struct wl_signal drag_icon_signal;
|
||||||
|
|
||||||
|
uint32_t selection_serial;
|
||||||
struct wl_data_source *selection_data_source;
|
struct wl_data_source *selection_data_source;
|
||||||
struct wl_listener selection_data_source_listener;
|
struct wl_listener selection_data_source_listener;
|
||||||
struct wl_signal selection_signal;
|
struct wl_signal selection_signal;
|
||||||
|
|
@ -343,7 +344,7 @@ wl_input_device_end_pointer_grab(struct wl_input_device *device);
|
||||||
|
|
||||||
void
|
void
|
||||||
wl_input_device_set_selection(struct wl_input_device *device,
|
wl_input_device_set_selection(struct wl_input_device *device,
|
||||||
struct wl_data_source *source);
|
struct wl_data_source *source, uint32_t serial);
|
||||||
|
|
||||||
|
|
||||||
void *
|
void *
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue