diff --git a/glfw/x11_init.c b/glfw/x11_init.c index 69de72413..aeddebcb9 100644 --- a/glfw/x11_init.c +++ b/glfw/x11_init.c @@ -160,6 +160,7 @@ read_xi_scroll_devices(void) { if (!devices) return; for (int i = 0; i < deviceCount; i++) { XIDeviceInfo* device = &devices[i]; + if (device->use == XIMasterPointer) _glfw.x11.xi.master_pointer_id = device->deviceid; if (device->use != XISlavePointer || !device->enabled) continue; Atom actual_type; int actual_format; diff --git a/glfw/x11_platform.h b/glfw/x11_platform.h index d1a6e2172..5f523fceb 100644 --- a/glfw/x11_platform.h +++ b/glfw/x11_platform.h @@ -425,6 +425,7 @@ typedef struct _GLFWlibraryX11 PFN_XIGetProperty GetProperty; XIScrollDevice scroll_devices[16]; unsigned num_scroll_devices; + int master_pointer_id; Atom LIBINPUT_SCROLL_METHOD_ENABLED; } xi; diff --git a/glfw/x11_window.c b/glfw/x11_window.c index 2736b160c..dd040674f 100644 --- a/glfw/x11_window.c +++ b/glfw/x11_window.c @@ -1407,10 +1407,12 @@ static void processEvent(XEvent *event) else if (event->xcookie.evtype == XI_Motion) { XIDeviceEvent* de = (XIDeviceEvent*)event->xcookie.data; - // Find the window for this event - _GLFWwindow* window = NULL; - if (XFindContext(_glfw.x11.display, de->event, _glfw.x11.context, (XPointer*)&window) == 0) - handle_xi_motion_event(window, de); + if (de->deviceid != _glfw.x11.xi.master_pointer_id) { + // Find the window for this event + _GLFWwindow* window = NULL; + if (XFindContext(_glfw.x11.display, de->event, _glfw.x11.context, (XPointer*)&window) == 0) + handle_xi_motion_event(window, de); + } } // Handle XI_HierarchyChanged for device hotplug else if (event->xcookie.evtype == XI_HierarchyChanged)