X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8ea82c09ff6ffa9f41abc117ddc4eba495cedfb5..ad653fa23069c5d9378247084f03c9a718c3ad62:/src/msw/uiaction.cpp?ds=inline diff --git a/src/msw/uiaction.cpp b/src/msw/uiaction.cpp index 56ea8fa3a9..bc5bde1ad1 100644 --- a/src/msw/uiaction.cpp +++ b/src/msw/uiaction.cpp @@ -65,8 +65,10 @@ bool wxUIActionSimulator::MouseMove(long x, long y) int displayx, displayy; wxDisplaySize(&displayx, &displayy); - int scaledx = wxRound(((float)x / displayx) * 65535); - int scaledy = wxRound(((float)y / displayy) * 65535); + // Casts are safe because x and y are supposed to be less than the display + // size, so there is no danger of overflow. + DWORD scaledx = static_cast(ceil(x * 65535.0 / (displayx-1))); + DWORD scaledy = static_cast(ceil(y * 65535.0 / (displayy-1))); mouse_event(MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE, scaledx, scaledy, 0, 0); return true;