Relative mouse distances are currently unreliable, because the code doesn't consider that the "while (XPending(display) > 0)" loop handles several XMotionEvents in one go. After such a set the
abs values are correct, but the
rel values only contain the relative distances of the
last event! So all the relative distances don't add up to the absolute coordinates and are, thus, completely useless. Any application using them anyway faces the following problems: (a) The mouse seems to move much slower than it actually does, because events are effectively dropped in the
rel value. (b) The window loses X11 focus at a time when the mouse still
appears to be in the window. This creates the illusion of invisible barriers in the window, which can't easily be overcome.
The following patch fixes it. Please apply and consider making a new release. This is quite a serious bug!
--- LinuxMouse.cpp (revision 13)
+++ LinuxMouse.cpp (working copy)
@@ -172,15 +172,17 @@
}
//Compute this frames Relative X & Y motion
- mState.X.rel = event.xmotion.x - oldXMouseX;
- mState.Y.rel = event.xmotion.y - oldXMouseY;
+ int dx = event.xmotion.x - oldXMouseX;
+ int dy = event.xmotion.y - oldXMouseY;
//Store old values for next time to compute relative motion
oldXMouseX = event.xmotion.x;
oldXMouseY = event.xmotion.y;
- mState.X.abs += mState.X.rel;
- mState.Y.abs += mState.Y.rel;
+ mState.X.abs += dx;
+ mState.Y.abs += dy;
+ mState.X.rel += dx;
+ mState.Y.rel += dy;
//Check to see if we are grabbing the mouse to the window (requires clipping and warping)
if( grabMouse )