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



commit 175985c5ddef306aff6811d55c5e947688e18b3a
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 | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
---
diff --git a/src/wayland/meta-wayland-data-device.c b/src/wayland/meta-wayland-data-device.c
index b209a2076..2c535a6db 100644
--- a/src/wayland/meta-wayland-data-device.c
+++ b/src/wayland/meta-wayland-data-device.c
@@ -1090,6 +1090,20 @@ static gboolean
 keyboard_drag_grab_key (MetaWaylandKeyboardGrab *grab,
                         const ClutterEvent      *event)
 {
+  MetaWaylandDragGrab *drag_grab;
+
+  drag_grab = wl_container_of (grab, drag_grab, keyboard_grab);
+
+  if (event->key.keyval == CLUTTER_KEY_Escape)
+    {
+      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]