From 7f6fd02d06f99d8b3f8597bebbc4a52a3c7a6f09 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Sat, 31 Jul 2021 15:23:31 +1000 Subject: [PATCH] [client] x11: Add event handling for ungrabed mouse press/release The imgui overlay requires input even if the display is not captured and operating in raw mode. XInput2 correctly only sends XI_Press/ReleaseButton events if the device has not been captured, as such it's safe to handle both raw and non raw buttons events at the same time. --- client/displayservers/X11/x11.c | 36 ++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/client/displayservers/X11/x11.c b/client/displayservers/X11/x11.c index 088bc395..3a6f1d0d 100644 --- a/client/displayservers/X11/x11.c +++ b/client/displayservers/X11/x11.c @@ -382,13 +382,15 @@ static bool x11Init(const LG_DSInitParams params) eventmask.mask_len = sizeof(mask); eventmask.mask = mask; - XISetMask(mask, XI_FocusIn ); - XISetMask(mask, XI_FocusOut ); - XISetMask(mask, XI_Enter ); - XISetMask(mask, XI_Leave ); - XISetMask(mask, XI_Motion ); - XISetMask(mask, XI_KeyPress ); - XISetMask(mask, XI_KeyRelease); + XISetMask(mask, XI_FocusIn ); + XISetMask(mask, XI_FocusOut ); + XISetMask(mask, XI_Enter ); + XISetMask(mask, XI_Leave ); + XISetMask(mask, XI_Motion ); + XISetMask(mask, XI_KeyPress ); + XISetMask(mask, XI_KeyRelease ); + XISetMask(mask, XI_ButtonPress ); + XISetMask(mask, XI_ButtonRelease); if (XISelectEvents(x11.display, x11.window, &eventmask, 1) != Success) { @@ -802,6 +804,26 @@ static void x11GenericEvent(XGenericEventCookie *cookie) return; } + case XI_ButtonPress: + { + if (!x11.focused || !x11.entered) + return; + + XIDeviceEvent *device = cookie->data; + app_handleButtonPress(device->detail); + return; + } + + case XI_ButtonRelease: + { + if (!x11.focused || !x11.entered) + return; + + XIDeviceEvent *device = cookie->data; + app_handleButtonRelease(device->detail); + return; + } + case XI_RawButtonPress: { if (!x11.focused || !x11.entered)