summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2022-05-22 19:11:58 (GMT)
committerfvogel <fvogelnew1@free.fr>2022-05-22 19:11:58 (GMT)
commit4f20685c740d656a7ddbc7cf8fab107b6439ce23 (patch)
tree2c50f8c4d7ed3534f5111b1c7ab7b71fd3025707 /win
parent589e1242e98250d8d57c5b08aa56b93421278a88 (diff)
parent978bc4e840b31458763d50a2f7558086c86230c1 (diff)
downloadtk-4f20685c740d656a7ddbc7cf8fab107b6439ce23.zip
tk-4f20685c740d656a7ddbc7cf8fab107b6439ce23.tar.gz
tk-4f20685c740d656a7ddbc7cf8fab107b6439ce23.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 46dbaa2..bbffa44 100644
--- a/win/tkWinPointer.c
+++ b/win/tkWinPointer.c
@@ -377,6 +377,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;