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 <ofourdan@redhat.com>
Closes: https://gitlab.freedesktop.org/xorg/xserver/issues/962
Reviewed-by: Carlos Garnacho <carlosg@gnome.org>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
Olivier Fourdan 2020-03-24 16:33:16 +01:00
parent 5929b789f9
commit 1345f804a8

View File

@ -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;