]> git.saurik.com Git - wxWidgets.git/commitdiff
Make wxUIActionSimulator mouse move events marginally more precise.
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 16 Jun 2011 15:13:59 +0000 (15:13 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 16 Jun 2011 15:13:59 +0000 (15:13 +0000)
Round the values instead of truncating them when converting from pixel values
to Win32 ::mouse_event() 0..65535 scale. This probably doesn't make any real
difference in practice but seems more correct and also avoids g++ warnings.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67963 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/uiaction.cpp

index eb5bfd1e34567522b04efbf19496fce891cdd85b..e8c7d94df88ed826f1ed7cf098b671e54e330b84 100644 (file)
@@ -20,6 +20,8 @@
 
 #include "wx/msw/private/keyboard.h"
 
+#include "wx/math.h"
+
 namespace
 {
 
@@ -56,11 +58,13 @@ bool wxUIActionSimulator::MouseMove(long x, long y)
 {
     // Because MOUSEEVENTF_ABSOLUTE takes measurements scaled between 0 & 65535
     // we need to scale our input too
-    int displayx, displayy, scaledx, scaledy;
+    int displayx, displayy;
     wxDisplaySize(&displayx, &displayy);
-    scaledx = ((float)x / displayx) * 65535;
-    scaledy = ((float)y / displayy) * 65535;
+
+    int scaledx = wxRound(((float)x / displayx) * 65535);
+    int scaledy = wxRound(((float)y / displayy) * 65535);
     mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, scaledx, scaledy, 0, 0);
+
     return true;
 }