From 5bcaa7c80b7640e2da6135cdff83eba77c202407 Mon Sep 17 00:00:00 2001 From: Sebastian Keller Date: Sat, 19 Oct 2024 20:41:02 +0200 Subject: [PATCH] wayland/pointer-constraints: Warp pointer after destroying resource e994fbf02 moved warping the pointer to before the destruction of the resource to prevent dereferencing the constraint after destruction. This however meant that the constraint was still active when the motion event caused by the warp is handled, which would constrain the pointer back again to its original position. This moves the warping of the pointer back to after the destruction of the resource and instead just retrieves the seat earlier while the constraint is still valid. Fixes: e994fbf02 ("wayland/pointer-constraints: Warp pointer before destroying resource") Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/3696 Part-of: (cherry picked from commit cb34fafd5727db5684d32b462368c34adf89cca3) --- src/wayland/meta-wayland-pointer-constraints.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/wayland/meta-wayland-pointer-constraints.c b/src/wayland/meta-wayland-pointer-constraints.c index 2c2e41246..08f96b2ed 100644 --- a/src/wayland/meta-wayland-pointer-constraints.c +++ b/src/wayland/meta-wayland-pointer-constraints.c @@ -938,6 +938,7 @@ locked_pointer_destroy (struct wl_client *client, { MetaWaylandPointerConstraint *constraint = wl_resource_get_user_data (resource); + ClutterSeat *seat; gboolean warp_pointer = FALSE; int warp_x, warp_y; @@ -957,12 +958,12 @@ locked_pointer_destroy (struct wl_client *client, warp_pointer = TRUE; warp_x = (int) x; warp_y = (int) y; + seat = constraint->seat->clutter_seat; } + wl_resource_destroy (resource); if (warp_pointer) - clutter_seat_warp_pointer (constraint->seat->clutter_seat, warp_x, warp_y); - - wl_resource_destroy (resource); + clutter_seat_warp_pointer (seat, warp_x, warp_y); } static void