[mutter/wip/carlosg/cancel-pointer-gestures-on-unfocus: 2/2] wayland: Cancel active pointer gestures with wl_pointer.leave




commit 8562a294982535b170a780fe64fe9a5e0f317389
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri Sep 23 15:56:08 2022 +0200

    wayland: Cancel active pointer gestures with wl_pointer.leave
    
    There may be an active pointer gesture at the time of a focus change, in
    which case we should cancel it. Add the plumbing so that happens, by
    looking at the active MetaWaylandPointerClient gesture.
    
    Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5199

 src/wayland/meta-wayland-pointer.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
---
diff --git a/src/wayland/meta-wayland-pointer.c b/src/wayland/meta-wayland-pointer.c
index 94e76677b6..d000ccfd86 100644
--- a/src/wayland/meta-wayland-pointer.c
+++ b/src/wayland/meta-wayland-pointer.c
@@ -176,6 +176,30 @@ meta_wayland_pointer_client_is_empty (MetaWaylandPointerClient *pointer_client)
           wl_list_empty (&pointer_client->relative_pointer_resources));
 }
 
+static void
+meta_wayland_pointer_client_maybe_cancel_gesture (MetaWaylandPointer       *pointer,
+                                                  MetaWaylandPointerClient *pointer_client,
+                                                  uint32_t                  serial)
+{
+  switch (pointer_client->active_touchpad_gesture)
+    {
+    case CLUTTER_TOUCHPAD_SWIPE:
+      meta_wayland_pointer_gesture_swipe_cancel (pointer, serial);
+      break;
+
+    case CLUTTER_TOUCHPAD_PINCH:
+      meta_wayland_pointer_gesture_pinch_cancel (pointer, serial);
+      break;
+
+    case CLUTTER_TOUCHPAD_HOLD:
+      meta_wayland_pointer_gesture_hold_cancel (pointer, serial);
+      break;
+
+    default:
+      break;
+    }
+}
+
 MetaWaylandPointerClient *
 meta_wayland_pointer_get_pointer_client (MetaWaylandPointer *pointer,
                                          struct wl_client   *client)
@@ -1014,6 +1038,10 @@ meta_wayland_pointer_set_focus (MetaWaylandPointer *pointer,
 
       if (pointer->focus_client)
         {
+          meta_wayland_pointer_client_maybe_cancel_gesture (pointer,
+                                                            pointer->focus_client,
+                                                            serial);
+
           meta_wayland_pointer_broadcast_leave (pointer,
                                                 serial,
                                                 pointer->focus_surface);


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