From e26964faffb55027390e431942fbbd69a52dcf43 Mon Sep 17 00:00:00 2001 From: fvogel Date: Fri, 11 Oct 2019 20:22:27 +0000 Subject: Cherrypick [fc3f78ec] Fix test-case bind-34.1 on Windows 10 --- win/tkWinPointer.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/win/tkWinPointer.c b/win/tkWinPointer.c index 896500c..14e96c8 100644 --- a/win/tkWinPointer.c +++ b/win/tkWinPointer.c @@ -364,8 +364,8 @@ void TkSetCursorPos( INPUT input; input.type = INPUT_MOUSE; - input.mi.dx = x * (65535.0 / (GetSystemMetrics(SM_CXSCREEN) - 1)); - input.mi.dy = y * (65535.0 / (GetSystemMetrics(SM_CYSCREEN) - 1)); + input.mi.dx = (LONG)(x * (65535.0 / (GetSystemMetrics(SM_CXSCREEN) - 1)) + 0.5); + input.mi.dy = (LONG)(y * (65535.0 / (GetSystemMetrics(SM_CYSCREEN) - 1)) + 0.5); input.mi.mouseData = 0; input.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE; input.mi.time = 0; -- cgit v0.12 From a855bc82aa673d34a0f518c1726681a53d128b93 Mon Sep 17 00:00:00 2001 From: fvogel Date: Fri, 11 Oct 2019 20:23:14 +0000 Subject: Cherrypick [8f767ecb] Leaf: Let's do exactly the same calculation, but then using integer arithmetics instead of float --- win/tkWinPointer.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/win/tkWinPointer.c b/win/tkWinPointer.c index 14e96c8..2b8656b 100644 --- a/win/tkWinPointer.c +++ b/win/tkWinPointer.c @@ -362,10 +362,12 @@ void TkSetCursorPos( int y) { INPUT input; + unsigned xscreen = (GetSystemMetrics(SM_CXSCREEN) - 1); + unsigned yscreen = (GetSystemMetrics(SM_CYSCREEN) - 1); input.type = INPUT_MOUSE; - input.mi.dx = (LONG)(x * (65535.0 / (GetSystemMetrics(SM_CXSCREEN) - 1)) + 0.5); - input.mi.dy = (LONG)(y * (65535.0 / (GetSystemMetrics(SM_CYSCREEN) - 1)) + 0.5); + input.mi.dx = (x * 65535 + xscreen/2) / xscreen; + input.mi.dy = (y * 65535 + yscreen/2) / yscreen; input.mi.mouseData = 0; input.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE; input.mi.time = 0; -- cgit v0.12