summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2022-05-08 19:10:15 (GMT)
committerfvogel <fvogelnew1@free.fr>2022-05-08 19:10:15 (GMT)
commitd5d70e40fdbe76e1c9d866b6b2f67f5b41de4bf8 (patch)
treea87ac10d5d83b8f32e0c9a15a8d5544076793fd6 /win
parent818335dd361fb6a08f3c162346143814a5afaf80 (diff)
downloadtk-d5d70e40fdbe76e1c9d866b6b2f67f5b41de4bf8.zip
tk-d5d70e40fdbe76e1c9d866b6b2f67f5b41de4bf8.tar.gz
tk-d5d70e40fdbe76e1c9d866b6b2f67f5b41de4bf8.tar.bz2
Fix [bee96b4e80]: Mouse position warping and tk busy problems on Windows. Thanks to cjmcdonald.
Diffstat (limited to 'win')
-rw-r--r--win/tkWinPointer.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/win/tkWinPointer.c b/win/tkWinPointer.c
index 8f42dcd..0ce9b37 100644
--- a/win/tkWinPointer.c
+++ b/win/tkWinPointer.c
@@ -360,6 +360,17 @@ void TkSetCursorPos(
int xscreen = (int)(GetSystemMetrics(SM_CXSCREEN) - 1);
int yscreen = (int)(GetSystemMetrics(SM_CYSCREEN) - 1);
+ /*
+ * A multi-screen system may have different logical pixels/inch, with
+ * Windows applying behind-the-scenes scaling on secondary screens.
+ * Don't try and emulate that, instead fall back to SetCursor if the
+ * requested position is off the primary screen.
+ */
+ if ( x < 0 || x > xscreen || y < 0 || y > yscreen ) {
+ SetCursorPos(x, y);
+ return;
+ }
+
input.type = INPUT_MOUSE;
input.mi.dx = (x * 65535 + xscreen/2) / xscreen;
input.mi.dy = (y * 65535 + yscreen/2) / yscreen;