Linux/X11 grab window when emulating touch button events

The first touch moves the mouse cursor, but X motion events
for the first touch are only sent after a XGrabPointer.
This commit is contained in:
Robin Gareus 2025-01-15 02:05:43 +01:00
parent 678ebca032
commit 91fe10165e
2 changed files with 17 additions and 1 deletions

View file

@ -10887,6 +10887,22 @@ proxy_button_event (GdkEvent *source_event,
pointer_window,
type == GDK_TOUCH_BEGIN ? GDK_BUTTON_PRESS : GDK_BUTTON_RELEASE, state,
NULL, serial);
if (event_win != NULL)
{
/* grab window to create MOTION_NOTIFY messages for first touch */
switch (type)
{
case GDK_TOUCH_BEGIN:
gdk_pointer_grab (event_win, FALSE, GDK_POINTER_MOTION_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK, NULL, NULL, time_);
break;
case GDK_TOUCH_END:
gdk_pointer_ungrab (time_);
break;
default:
g_assert (0);
break;
}
}
}
else
#endif

View file

@ -2254,7 +2254,7 @@ gdk_event_translate (GdkDisplay *display,
XIDeviceEvent *xev = (XIDeviceEvent *) xevent->xcookie.data;
#ifdef G_ENABLE_DEBUG
if (_gdk_debug_flags & GDK_DEBUG_TOUCH)
g_message ("TOUCH dev=%d src=%d | dt: %u flags: %x\n", xev->deviceid, xev->sourceid, xev->detail, xev->flags);
g_message ("TOUCH dev=%d src=%d | type: %d dt: %u flags: %x\n", xev->deviceid, xev->sourceid, xevent->xcookie.evtype, xev->detail, xev->flags);
#endif
window = gdk_window_lookup_for_display (display, xev->event);
g_object_ref (window);