HumbleUI / JWM

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

Use XQueryPointer mouse position instead of XI_Motion fields #272

Closed dzaima closed 9 months ago

dzaima commented 9 months ago

Without this, on my system, the XI_Motion mouse events were always lagging one event behind (not just one frame, but from whenever was the last time the mouse moved, so the wrong mouse pointer could be kept indefinitely).

i.e., in this gif, whenever I'm moving the mouse back & forth a single pixel, the XI_Motion: logs show the previous position (i.e. moving one pixel right results in it the X coordinate decreasing).

gif

The XQueryPointer values appear to be up-to-date always, however, so this patch switches to using them instead.

This effectively reduces the mouse→display latency by at least 1 frame or 16ms (which, though not the cause for me finding this, is definitely a good benefit!)

dzaima commented 9 months ago

Added another commit of updating the mouse position on cursor re-entry into the window (and extracting the code for the mouse processing to a function).

tonsky commented 9 months ago

Thanks!