From 1345f804a88efc11c58f8388983d34445d3e5928 Mon Sep 17 00:00:00 2001 From: Olivier Fourdan Date: Tue, 24 Mar 2020 16:33:16 +0100 Subject: [PATCH] xwayland: confine motion events to the confined window When an X11 client has an active grab on the pointer, all events are reported relative to the window with the grab. For Xwayland, if an X11 client has a grab with a pointer confinement active, while pointer focus is on another window, motion events should not be reported to the client with the grab, because that sets the X11 client appart, the events would be reported when the pointer is on any X11 window but not on Wayland native surfaces. Therefore, if the pointer is confined on a window and that window differs from the actual pointer focus window, just pretend we lost pointer focus to another window. Signed-off-by: Olivier Fourdan Closes: https://gitlab.freedesktop.org/xorg/xserver/issues/962 Reviewed-by: Carlos Garnacho Reviewed-by: Peter Hutterer --- hw/xwayland/xwayland-input.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/hw/xwayland/xwayland-input.c b/hw/xwayland/xwayland-input.c index 9b3a24430..0ee84f6e3 100644 --- a/hw/xwayland/xwayland-input.c +++ b/hw/xwayland/xwayland-input.c @@ -2544,8 +2544,15 @@ sprite_check_lost_focus(SpritePtr sprite, WindowPtr window) * devices so we can find out the xwl_seat, but those don't actually own * their sprite, so the match doesn't mean a lot. */ - if (master->lastSlave == xwl_seat->pointer && - xwl_seat->focus_window == NULL && + if (master->lastSlave != xwl_seat->pointer) + return FALSE; + + if (xwl_seat->focus_window != NULL && + xwl_seat->cursor_confinement_window != NULL && + xwl_seat->focus_window != xwl_seat->cursor_confinement_window) + return TRUE; + + if (xwl_seat->focus_window == NULL && xwl_seat->last_xwindow != NullWindow && IsParent(xwl_seat->last_xwindow, window)) return TRUE;