[mutter] wayland/pointer-constraints: Disable or remove when grab is cancelled



commit 7ae4b28bda49b26aa6b30731b6780eb7d3413470
Author: Jonas Ådahl <jadahl gmail com>
Date:   Wed Sep 21 16:32:55 2016 +0800

    wayland/pointer-constraints: Disable or remove when grab is cancelled
    
    When the grab is cancelled, for example because of an Alt-tab, VT
    switch etc, disable or remove (depending on the constraint type) the
    constraint. This avoids a re-entry issue when the focus is returned and
    the focus listener tries to re-enable a disabled constraint.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=771859

 src/wayland/meta-wayland-pointer-constraints.c |   52 ++++++++++++++++++------
 1 files changed, 39 insertions(+), 13 deletions(-)
---
diff --git a/src/wayland/meta-wayland-pointer-constraints.c b/src/wayland/meta-wayland-pointer-constraints.c
index 5cf74fc..8e7d5af 100644
--- a/src/wayland/meta-wayland-pointer-constraints.c
+++ b/src/wayland/meta-wayland-pointer-constraints.c
@@ -519,6 +519,24 @@ meta_wayland_pointer_constraint_remove (MetaWaylandPointerConstraint *constraint
   meta_wayland_pointer_constraint_destroy (constraint);
 }
 
+static void
+meta_wayland_pointer_constraint_deactivate (MetaWaylandPointerConstraint *constraint)
+{
+  switch (constraint->lifetime)
+    {
+    case ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_ONESHOT:
+      meta_wayland_pointer_constraint_remove (constraint);
+      break;
+
+    case ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_PERSISTENT:
+      meta_wayland_pointer_constraint_disable (constraint);
+      break;
+
+    default:
+      g_assert_not_reached ();
+    }
+}
+
 void
 meta_wayland_pointer_constraint_maybe_remove_for_seat (MetaWaylandSeat *seat,
                                                        MetaWindow      *window)
@@ -539,19 +557,7 @@ meta_wayland_pointer_constraint_maybe_remove_for_seat (MetaWaylandSeat *seat,
       pointer->focus_surface == window->surface)
     return;
 
-  switch (constraint->lifetime)
-    {
-    case ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_ONESHOT:
-      meta_wayland_pointer_constraint_remove (constraint);
-      break;
-
-    case ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_PERSISTENT:
-      meta_wayland_pointer_constraint_disable (constraint);
-      break;
-
-    default:
-      g_assert_not_reached ();
-    }
+  meta_wayland_pointer_constraint_deactivate (constraint);
 }
 
 static void
@@ -938,10 +944,20 @@ locked_pointer_grab_pointer_button (MetaWaylandPointerGrab *grab,
   meta_wayland_pointer_send_button (grab->pointer, event);
 }
 
+static void
+locked_pointer_grab_pointer_cancel (MetaWaylandPointerGrab *grab)
+{
+  MetaWaylandPointerConstraint *constraint =
+    wl_container_of (grab, constraint, grab);
+
+  meta_wayland_pointer_constraint_deactivate (constraint);
+}
+
 static const MetaWaylandPointerGrabInterface locked_pointer_grab_interface = {
   locked_pointer_grab_pointer_focus,
   locked_pointer_grab_pointer_motion,
   locked_pointer_grab_pointer_button,
+  locked_pointer_grab_pointer_cancel,
 };
 
 static void
@@ -999,10 +1015,20 @@ confined_pointer_grab_pointer_button (MetaWaylandPointerGrab *grab,
   meta_wayland_pointer_send_button (grab->pointer, event);
 }
 
+static void
+confined_pointer_grab_pointer_cancel (MetaWaylandPointerGrab *grab)
+{
+  MetaWaylandPointerConstraint *constraint =
+    wl_container_of (grab, constraint, grab);
+
+  meta_wayland_pointer_constraint_deactivate (constraint);
+}
+
 static const MetaWaylandPointerGrabInterface confined_pointer_grab_interface = {
   confined_pointer_grab_pointer_focus,
   confined_pointer_grab_pointer_motion,
   confined_pointer_grab_pointer_button,
+  confined_pointer_grab_pointer_cancel,
 };
 
 static void


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