From d22db60a2b5a73ce4008185655d6a0eb0c8e32f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Wed, 21 Sep 2016 16:32:55 +0800 Subject: 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 file changed, 39 insertions(+), 13 deletions(-) diff --git a/src/wayland/meta-wayland-pointer-constraints.c b/src/wayland/meta-wayland-pointer-constraints.c index 5cf74fcd4..8e7d5af1f 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 -- cgit v1.2.1