Make wxUIActionSimulator mouse move events marginally more precise.
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
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user