HumbleUI / JWM

Cross-platform window management and OS integration library for Java
Apache License 2.0
571 stars 46 forks source link

X11: EventMouseMove is not reported if mouse buttons are not held #146

Closed tonsky closed 2 years ago

dzaima commented 2 years ago

Commenting out XISetMask(mask, XI_Motion); in WindowManagerX11.cc fixes this. Of course that breaks case XI_Motion: in _processXEvent and thus scrolling, but at least the culprit is found.

dzaima commented 2 years ago

Seems that XI_Motion disabling MotionNotify is just A Thing (1, 2).

The simple thing is to just do the same thing on XI_Motion that's on MotionNotify (only one is active at a time, and scrolling and mouse movement get separate XI_Motion events):

diff --git a/linux/cc/WindowManagerX11.cc b/linux/cc/WindowManagerX11.cc
index b73114f..afd7b88 100644
--- a/linux/cc/WindowManagerX11.cc
+++ b/linux/cc/WindowManagerX11.cc
@@ -332,6 +332,21 @@ void WindowManagerX11::_processXEvent(XEvent& ev) {
                                 )
                             );
                             myWindow->dispatch(eventMouseScroll.get()); 
+                        } else {
+                            unsigned mask;
+                            ::Window unused1;
+                            int unused2;
+                            XQueryPointer(display, myWindow->_x11Window, &unused1, &unused1, &unused2, &unused2, &unused2, &unused2, &mask);
+                            jwm::JNILocal<jobject> eventMove(
+                                app.getJniEnv(),
+                                EventMouseMove::make(app.getJniEnv(),
+                                    deviceEvent->event_x,
+                                    deviceEvent->event_y,
+                                    jwm::MouseButtonX11::fromNativeMask(mask),
+                                    jwm::KeyX11::getModifiers()
+                                )
+                            );
+                            myWindow->dispatch(eventMove.get());
                         }

                         break;
tonsky commented 2 years ago

Thanks! Could you make it a PR?