Merge branch 'master' into 'master'

xwayland: prevent X11 get enter event when pointer is over Wayland client

Closes #1818

See merge request xorg/xserver!2112
This commit is contained in:
Tsic 2025-12-19 12:38:01 +08:00
commit 240d47a772
2 changed files with 10 additions and 3 deletions

View file

@ -527,6 +527,7 @@ pointer_handle_enter(void *data, struct wl_pointer *pointer,
int sx, sy;
int dx, dy;
ScreenPtr pScreen = xwl_screen->screen;
xwl_seat->pointer_enter_count++;
ValuatorMask mask;
DeviceEvent enter;
@ -621,6 +622,9 @@ pointer_handle_leave(void *data, struct wl_pointer *pointer,
Bool focus_lost = FALSE;
xwl_screen->serial = serial;
BUG_WARN(xwl_seat->pointer_enter_count == 0);
if (xwl_seat->pointer_enter_count > 0)
xwl_seat->pointer_enter_count--;
/* The pointer has left a known xwindow, save it for a possible match
* in sprite_check_lost_focus()
@ -3226,6 +3230,7 @@ sprite_check_lost_focus(SpritePtr sprite, WindowPtr window)
{
DeviceIntPtr device, master;
struct xwl_seat *xwl_seat;
Bool pointer_crossing;
for (device = inputInfo.devices; device; device = device->next) {
/* Ignore non-wayland devices */
@ -3241,16 +3246,17 @@ sprite_check_lost_focus(SpritePtr sprite, WindowPtr window)
if (!xwl_seat)
return FALSE;
pointer_crossing = (xwl_seat->pointer_enter_count > 0);
master = GetMaster(device, POINTER_OR_FLOAT);
if (!master || !master->lastSlave)
return FALSE;
return !pointer_crossing;
/* We do want the last active slave, we only check on slave xwayland
* 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 != get_pointer_device(xwl_seat))
return FALSE;
return !pointer_crossing;
/* If we left the surface with a button down, it means the wayland compositor
* has grabbed the pointer so we will not get button release events from the
@ -3272,7 +3278,7 @@ sprite_check_lost_focus(SpritePtr sprite, WindowPtr window)
IsParent(xwl_seat->last_focus_window->toplevel, window)))
return TRUE;
return FALSE;
return !pointer_crossing;
}
static WindowPtr

View file

@ -76,6 +76,7 @@ struct xwl_seat {
struct xwl_window *tablet_focus_window;
uint32_t id;
uint32_t pointer_enter_serial;
uint8_t pointer_enter_count;
struct xorg_list link;
CursorPtr x_cursor;
OsTimerPtr x_cursor_timer;