Wrecked Games
September 05, 2010, 03:32:36 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: We're just that awesome.
 
   Home   Help Search Members Login Register  
Pages: [1]
  Print  
Author Topic: [PATCH] Linux: fix broken relative mouse movement distances  (Read 159 times)
mfranz
Newbie
*
Posts: 5


View Profile
« on: July 20, 2010, 04:33:36 PM »

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!

Code:
--- 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 )
Logged
pjcast
Administrator
Veteran
*****
Posts: 2544



View Profile WWW
« Reply #1 on: July 25, 2010, 05:35:03 PM »

Added this patch to svn. As with the other, will test this more tomorrow. There are also some Windows mouse handling patches to look into.

As for a release, I'm shooting for August 9th'ish - I will be on vacation then and have some time to prepare.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!