Fix T84645 cursor moves when clicking selector.

The absolute position desktop mapping has been corrected. The correct
mapping is 0-65535 inclusive. Additionally, division by the virtual
desktop width and height needed to be subtracted by 1 as width and
height are one more than the final pixel index.
This commit is contained in:
Nicholas Rishel 2021-01-13 14:07:03 -08:00
parent de60dc84e2
commit 957de39191
Notes: blender-bot 2023-02-14 01:21:16 +01:00
Referenced by issue #84770, Add Object Tool missing
Referenced by issue #84743, The mouse cursor is moved upward as the mouse wheel is scrolled with the CTRL held down.
Referenced by issue #84645, Mouse pointer moves when clicking selector
1 changed files with 5 additions and 5 deletions

View File

@ -541,11 +541,11 @@ GHOST_TSuccess GHOST_SystemWin32::setCursorPosition(GHOST_TInt32 x, GHOST_TInt32
input.type = INPUT_MOUSE;
input.mi.mouseData = 0;
input.mi.time = ::GetTickCount();
/* Map from virtual screen to 0-65536. */
input.mi.dx = (x - GetSystemMetrics(SM_XVIRTUALSCREEN)) * 65536 /
GetSystemMetrics(SM_CXVIRTUALSCREEN);
input.mi.dy = (y - GetSystemMetrics(SM_YVIRTUALSCREEN)) * 65536 /
GetSystemMetrics(SM_CYVIRTUALSCREEN);
/* Map from virtual screen to 0-65535 inclusive. */
input.mi.dx = (x - GetSystemMetrics(SM_XVIRTUALSCREEN)) * 65535 /
(GetSystemMetrics(SM_CXVIRTUALSCREEN) - 1);
input.mi.dy = (y - GetSystemMetrics(SM_YVIRTUALSCREEN)) * 65535 /
(GetSystemMetrics(SM_CYVIRTUALSCREEN) - 1);
input.mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_VIRTUALDESK;
SendInput(1, &input, sizeof(input));