summaryrefslogtreecommitdiff
path: root/src/data-device.c
diff options
context:
space:
mode:
authorJonas Ådahl <jadahl@gmail.com>2013-10-25 23:18:05 +0200
committerKristian Høgsberg <krh@bitplanet.net>2013-10-28 14:44:06 -0700
commit1ea343e1be49160bd00d97eb776d3641c10de1b1 (patch)
treec83b9d9b61450d512ac21e3ff656a6ef20d1bb5d /src/data-device.c
parent1c6e63e880d1d4afef4dc3b009007c11ecc436ad (diff)
downloadweston-1ea343e1be49160bd00d97eb776d3641c10de1b1.tar.gz
Add cancel function to grab interfaces
A grab can potentially allocate memory and would normally end the grab itself, freeing the allocated memory in the process. However at in some situations the compositor may want to abort a grab. The grab owner still needs to free some memory and abort the grab properly. To do this a new function 'cancel' is introduced in all the grab interfaces instructing the grabs owner to abort the grab. This patch also hooks up grab cancelling to seat device releasing and when the compositor looses focus, which would potentially leak memory before. Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Diffstat (limited to 'src/data-device.c')
-rw-r--r--src/data-device.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/data-device.c b/src/data-device.c
index 3e22b513..888e6065 100644
--- a/src/data-device.c
+++ b/src/data-device.c
@@ -344,10 +344,23 @@ drag_grab_button(struct weston_pointer_grab *grab,
}
}
+static void
+drag_grab_cancel(struct weston_pointer_grab *grab)
+{
+ struct weston_drag *drag =
+ container_of(grab, struct weston_drag, grab);
+
+ if (drag->data_source)
+ wl_list_remove(&drag->data_source_listener.link);
+
+ data_device_end_drag_grab(drag);
+}
+
static const struct weston_pointer_grab_interface drag_grab_interface = {
drag_grab_focus,
drag_grab_motion,
drag_grab_button,
+ drag_grab_cancel,
};
static void