xwayland: Update sprite prior to clearing the focus window

Xwayland has its own XYToWindow() handler to account for the case when
the pointer leaves an X11 surface to enter another Wayland native window
(which of course are unknown to Xwayland).

When that occurs, Xwayland will treat it as if the pointer had entered
the root window so that the X11 clients receive an appropriate leave
event.

When the pointer leaves the X11 surface, Xwayland will call
CheckMotion() to update the sprite coordinates and possibly the cursor.

However, CheckMotion() will call back into the XYToWindow() handler,
which will then pretend the window has entered the root window, and that
may cause the wrong cursor to be applied.

To avoid the issue, change the order we do things, by calling
CheckMotion() first prior to clear up the internal focus window so that
the first call to XYToWindow() will return the correct X11 window so we
get to update the cursor correctly.

Closes: https://gitlab.freedesktop.org/xorg/xserver/-/issues/1811
Signed-off-by: Olivier Fourdan <ofourdan@redhat.com>
Part-of: <https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/1915>
This commit is contained in:
Olivier Fourdan 2025-04-16 10:16:17 +02:00 committed by Marge Bot
parent 37b7ea8f8a
commit b97b459c06

View File

@ -616,21 +616,19 @@ pointer_handle_leave(void *data, struct wl_pointer *pointer,
{ {
struct xwl_seat *xwl_seat = data; struct xwl_seat *xwl_seat = data;
struct xwl_screen *xwl_screen = xwl_seat->xwl_screen; struct xwl_screen *xwl_screen = xwl_seat->xwl_screen;
Bool focus_lost = FALSE;
xwl_screen->serial = serial; xwl_screen->serial = serial;
if (xwl_screen->rootless)
xwl_seat_leave_ptr(xwl_seat, !!xwl_seat->focus_window);
/* The pointer has left a known xwindow, save it for a possible match /* The pointer has left a known xwindow, save it for a possible match
* in sprite_check_lost_focus() * in sprite_check_lost_focus()
*/ */
if (xwl_seat->focus_window) { if (xwl_seat->focus_window) {
xwl_seat->last_focus_window = xwl_seat->focus_window; xwl_seat->last_focus_window = xwl_seat->focus_window;
xwl_seat->focus_window = NULL; xwl_seat->focus_window = NULL;
focus_lost = TRUE;
} }
if (xwl_screen->rootless)
xwl_seat_leave_ptr(xwl_seat, focus_lost);
} }
static void static void