[PATCH wayland 10/10] Check clients holds implicit button grab in start_drag

Daniel Stone daniel at fooishbar.org
Mon Jul 23 11:54:47 PDT 2012


Resolve a long-standing FIXME.

Added a set of wl_data_transfer errors using an arbitrary base to
distinguish from generic errors (e.g. invalid object).

Signed-off-by: Daniel Stone <daniel at fooishbar.org>
---
 src/data-transfer.c |   11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/data-transfer.c b/src/data-transfer.c
index 9033d33..ae6ce04 100644
--- a/src/data-transfer.c
+++ b/src/data-transfer.c
@@ -344,8 +344,15 @@ data_device_start_drag(struct wl_client *client, struct wl_resource *resource,
 	struct wl_data_source *source = NULL;
 	struct wl_drag_offer *drag;
 
-	/* FIXME: Check that client has implicit grab on the origin
-	 * surface that matches the given serial. */
+	if (!seat->pointer || !seat->pointer->grab->focus ||
+	    seat->pointer->grab->focus->resource.client != client ||
+	    seat->pointer->grab_serial != serial) {
+		wl_resource_post_error(resource,
+				       WL_DATA_TRANSFER_ERROR_INVALID_SERIAL,
+				       "serial provided for drag start does "
+				       "not refer to a current button press");
+		return;
+	}
 
 	if (source_resource)
 		source = source_resource->data;
-- 
1.7.10.4



More information about the wayland-devel mailing list