From 5be5b4c8ebd30ba0623599a1acae5b5c1d1a40a3 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 17 Jan 2025 15:50:24 +0100 Subject: X11: only grab mouse devices with xi --- src/Overlay.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/Overlay.cpp') diff --git a/src/Overlay.cpp b/src/Overlay.cpp index 0d74637..c38ba36 100644 --- a/src/Overlay.cpp +++ b/src/Overlay.cpp @@ -667,7 +667,15 @@ namespace gsr { XcursorImageDestroy(cursor_image); } - void Overlay::xi_grab_all_devices() { + static bool device_is_mouse(const XIDeviceInfo *dev) { + for(int i = 0; i < dev->num_classes; ++i) { + if(dev->classes[i]->type == XIMasterPointer || dev->classes[i]->type == XISlavePointer) + return true; + } + return false; + } + + void Overlay::xi_grab_all_mouse_devices() { if(!xi_display) return; @@ -687,6 +695,9 @@ namespace gsr { for (int i = 0; i < num_devices; ++i) { const XIDeviceInfo *dev = &info[i]; + if(!device_is_mouse(dev)) + continue; + XIEventMask xi_masks; xi_masks.deviceid = dev->deviceid; xi_masks.mask_len = sizeof(mask); @@ -989,7 +1000,7 @@ namespace gsr { // We want to grab all devices to prevent any other application below the UI from receiving events. // Owlboy seems to use xi events and XGrabPointer doesn't prevent owlboy from receiving events. - xi_grab_all_devices(); + xi_grab_all_mouse_devices(); // if(gsr_info.system_info.display_server == DisplayServer::WAYLAND) { // set_focused_window(display, window->get_system_handle()); -- cgit v1.2.3