summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2021-02-07 20:14:58 (GMT)
committerfvogel <fvogelnew1@free.fr>2021-02-07 20:14:58 (GMT)
commite4eda36f6f16ed6cb0876dc2180f27b2aecb3245 (patch)
tree7e35377dfdf7d0407f350a769fa90e67377b06c2 /win
parentf31f7c15c932ef82b7ea1ce4df7b3a1436118d62 (diff)
downloadtk-e4eda36f6f16ed6cb0876dc2180f27b2aecb3245.zip
tk-e4eda36f6f16ed6cb0876dc2180f27b2aecb3245.tar.gz
tk-e4eda36f6f16ed6cb0876dc2180f27b2aecb3245.tar.bz2
Marking textTag-18.1 as knownBug in [c62fb2ba] wasn't so satisfying to me, so I have backported the fix from core-8-6-branch.
Diffstat (limited to 'win')
-rw-r--r--win/tkWinPointer.c40
1 files changed, 39 insertions, 1 deletions
diff --git a/win/tkWinPointer.c b/win/tkWinPointer.c
index dcddb8f..380de80 100644
--- a/win/tkWinPointer.c
+++ b/win/tkWinPointer.c
@@ -344,6 +344,44 @@ XQueryPointer(
*----------------------------------------------------------------------
*/
+ /*
+ * TkSetCursorPos is a helper function replacing SetCursorPos since this
+ * latter Windows function appears to have been broken by Microsoft
+ * since Win10 Falls Creator Update - See ticket [69b48f427e] along with
+ * several other Internet reports about this breakage.
+ */
+
+void TkSetCursorPos(
+ int x,
+ int y)
+{
+ INPUT input;
+ int xscreen = (int)(GetSystemMetrics(SM_CXSCREEN) - 1);
+ int yscreen = (int)(GetSystemMetrics(SM_CYSCREEN) - 1);
+
+ input.type = INPUT_MOUSE;
+ input.mi.dx = (x * 65535 + xscreen / 2) / xscreen;
+ input.mi.dy = (y * 65535 + yscreen / 2) / yscreen;
+
+ /*
+ * Horrible workaround here. There is a bug on Win 10: when warping to
+ * pixel (x = 0, y = 0) the SendInput() below just does not move the
+ * mouse pointer. However, as soon as dx or dy is non zero it moves as
+ * expected. Given the scaling factor of 65535 (see above),
+ * (dx = 1 , dy = 0) still means pixel (x = 0, y = 0).
+ * See ticket [69b48f427e].
+ */
+ if (input.mi.dx == 0 && input.mi.dy == 0) {
+ input.mi.dx = 1;
+ }
+
+ input.mi.mouseData = 0;
+ input.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE;
+ input.mi.time = 0;
+ input.mi.dwExtraInfo = 0;
+ SendInput(1, &input, sizeof(input));
+}
+
int
XWarpPointer(
Display *display,
@@ -359,7 +397,7 @@ XWarpPointer(
RECT r;
GetWindowRect(Tk_GetHWND(dest_w), &r);
- SetCursorPos(r.left+dest_x, r.top+dest_y);
+ TkSetCursorPos(r.left+dest_x, r.top+dest_y);
return Success;
}