diff options
author | fvogel <fvogelnew1@free.fr> | 2022-05-22 19:11:47 (GMT) |
---|---|---|
committer | fvogel <fvogelnew1@free.fr> | 2022-05-22 19:11:47 (GMT) |
commit | 978bc4e840b31458763d50a2f7558086c86230c1 (patch) | |
tree | 561f769c5e28766391d5f8bcc8968d763d5fe549 | |
parent | 0687fef515207f04fc3b520afaeb26a752c3e017 (diff) | |
parent | d5d70e40fdbe76e1c9d866b6b2f67f5b41de4bf8 (diff) | |
download | tk-978bc4e840b31458763d50a2f7558086c86230c1.zip tk-978bc4e840b31458763d50a2f7558086c86230c1.tar.gz tk-978bc4e840b31458763d50a2f7558086c86230c1.tar.bz2 |
Fix [bee96b4e80]: Mouse position warping and tk busy problems on Windows. Thanks to cjmcdonald.
-rw-r--r-- | win/tkWinPointer.c | 11 |
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; |