From d5d70e40fdbe76e1c9d866b6b2f67f5b41de4bf8 Mon Sep 17 00:00:00 2001 From: fvogel Date: Sun, 8 May 2022 19:10:15 +0000 Subject: Fix [bee96b4e80]: Mouse position warping and tk busy problems on Windows. Thanks to cjmcdonald. --- win/tkWinPointer.c | 11 +++++++++++ 1 file changed, 11 insertions(+) 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; -- cgit v0.12