[mutter/wip/carlosg/cancel-dnd-on-esc: 18/18] wayland: Implement dnd cancel on pressing Esc key



commit 403466c0dbfdeaf070251edb4b88c8a8a5cf0e86
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Jan 28 14:05:15 2020 +0100

    wayland: Implement dnd cancel on pressing Esc key
    
    When this key is pressed the DnD operation should be cancelled,
    and the "pop DnD icon back" animation to happen.
    
    Closes: https://gitlab.gnome.org/GNOME/mutter/issues/1020

 src/wayland/meta-wayland-data-device.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
---
diff --git a/src/wayland/meta-wayland-data-device.c b/src/wayland/meta-wayland-data-device.c
index cd11d618e..7e0a254b4 100644
--- a/src/wayland/meta-wayland-data-device.c
+++ b/src/wayland/meta-wayland-data-device.c
@@ -1094,6 +1094,19 @@ static gboolean
 keyboard_drag_grab_key (MetaWaylandKeyboardGrab *grab,
                         const ClutterEvent      *event)
 {
+  if (event->key.keyval == CLUTTER_KEY_Escape)
+    {
+      MetaWaylandDragGrab *drag_grab;
+
+      drag_grab = wl_container_of (grab, drag_grab, keyboard_grab);
+      meta_wayland_data_source_cancel (drag_grab->drag_data_source);
+      meta_dnd_actor_drag_finish (META_DND_ACTOR (drag_grab->feedback_actor), FALSE);
+      drag_grab->feedback_actor = NULL;
+      data_device_end_drag_grab (drag_grab);
+
+      return TRUE;
+    }
+
   return FALSE;
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]