From a9f951b003e024d1cfaaf79751749c65388c5937 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Fri, 13 Apr 2012 12:48:38 -0400 Subject: [PATCH] data-device: Record the serial number for the current selection And reject setting a selection that's older than our current selection. --- src/data-device.c | 10 ++++++++-- src/wayland-server.h | 3 ++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/data-device.c b/src/data-device.c index b760aa64..e850f6e5 100644 --- a/src/data-device.c +++ b/src/data-device.c @@ -347,10 +347,14 @@ destroy_selection_data_source(struct wl_listener *listener, void *data) WL_EXPORT void 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; + if (device->selection_data_source && + device->selection_serial - serial < UINT32_MAX / 2) + return; + if (device->selection_data_source) { device->selection_data_source->cancel(device->selection_data_source); 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_serial = serial; focus = device->keyboard_focus_resource; if (focus) { @@ -387,7 +392,8 @@ data_device_set_selection(struct wl_client *client, return; /* 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 = { diff --git a/src/wayland-server.h b/src/wayland-server.h index bda3f1bf..7dcdb1a3 100644 --- a/src/wayland-server.h +++ b/src/wayland-server.h @@ -266,6 +266,7 @@ struct wl_input_device { struct wl_listener drag_icon_listener; struct wl_signal drag_icon_signal; + uint32_t selection_serial; struct wl_data_source *selection_data_source; struct wl_listener selection_data_source_listener; struct wl_signal selection_signal; @@ -343,7 +344,7 @@ wl_input_device_end_pointer_grab(struct wl_input_device *device); void wl_input_device_set_selection(struct wl_input_device *device, - struct wl_data_source *source); + struct wl_data_source *source, uint32_t serial); void *