summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristian Høgsberg <krh@bitplanet.net>2012-04-13 12:48:38 -0400
committerKristian Høgsberg <krh@bitplanet.net>2012-04-13 12:48:38 -0400
commita9f951b003e024d1cfaaf79751749c65388c5937 (patch)
treec5d6c977440b89d0b992c9b5fd5b9b7e962628f6
parentdata-device: Clear drag focus when we end the drag-and-drop (diff)
downloadwayland-a9f951b003e024d1cfaaf79751749c65388c5937.tar
wayland-a9f951b003e024d1cfaaf79751749c65388c5937.tar.gz
wayland-a9f951b003e024d1cfaaf79751749c65388c5937.tar.bz2
wayland-a9f951b003e024d1cfaaf79751749c65388c5937.tar.lz
wayland-a9f951b003e024d1cfaaf79751749c65388c5937.tar.xz
wayland-a9f951b003e024d1cfaaf79751749c65388c5937.tar.zst
wayland-a9f951b003e024d1cfaaf79751749c65388c5937.zip
data-device: Record the serial number for the current selection
And reject setting a selection that's older than our current selection.
-rw-r--r--src/data-device.c10
-rw-r--r--src/wayland-server.h3
2 files changed, 10 insertions, 3 deletions
diff --git a/src/data-device.c b/src/data-device.c
index b760aa6..e850f6e 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 bda3f1b..7dcdb1a 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 *