Tk Source Code

View Ticket
Login
2026-10-19
09:49 • Closed ticket [3f1ad1ff]: Windows: pointer warp sometimes lands one pixel short plus 8 other changes artifact: ef893bcb user: jan.nijtmans
09:48
Fix [3f1ad1ff50]: Windows: pointer warp could land one pixel short of the requested position check-in: 846fd91b user: jan.nijtmans tags: core-8-6-branch
09:37
Fix [3f1ad1ff50]: Windows: pointer warp could land one pixel short of the requested position. Don't bother reserving a stub entry for TkpChangeFocus2 check-in: 5ded3328 user: jan.nijtmans tags: core-9-0-branch
09:14
Fix [3f1ad1ff50]: Windows: pointer warp could land one pixel short of the requested position check-in: 36a85716 user: jan.nijtmans tags: trunk, main
2026-10-02
13:33 • New ticket [3f1ad1ff] Windows: pointer warp sometimes lands one pixel short. artifact: bf3d955a user: serhiy.storchaka
13:17
Fix [3f1ad1ff50]: Windows: pointer warp could land one pixel short of the requested position.

TkSetCursorPos() converted the position to the normalized coordinates of SendInput() with rounding to nearest, but Windows converts them back with rounding down, so some positions mapped to the previous pixel (e.g. x = 20 on a 3840 pixels wide screen; test bind-34.2 failed). Round up instead, so that the pointer lands on the requested pixel for any screen width. closed check-in: 4d5305ce user: serhiy.storchaka tags: win-warp-rounding


Ticket UUID: 3f1ad1ff5013c8b798d36c03da5f58d1129d758b
Title: Windows: pointer warp sometimes lands one pixel short
Type: Bug Version: 8.6.18, 9.0.5, 9.1.0
Submitter: serhiy.storchaka Created on: 2026-10-02 13:33:08
Subsystem: 68. Win Window Operations Assigned To: jan.nijtmans
Priority: 5 Medium Severity: Minor
Status: Closed Last Modified: 2026-10-19 09:49:04
Resolution: Fixed Closed By: jan.nijtmans
    Closed on: 2026-10-19 09:49:04
Description:

event generate ... -warp 1 sometimes moves the pointer one pixel short of the requested position on Windows:

event generate {} <Motion> -warp 1 -x 100 -y 1
update idletasks
winfo pointerxy .

On a 800x600 screen this returns 100 0 instead of 100 1. On a 3840x2160 screen, warping to 20 20 gives 19 20, and test bind-34.2 fails.

TkSetCursorPos() converts the position to the normalized coordinates of SendInput() with rounding to nearest, but Windows converts them back with rounding down, so some positions map to the previous pixel. This happens on most screen sizes, e.g. for 7 x values on a 1920 pixels wide screen and for 28 on a 3840 pixels wide screen.

Proposed fix in branch win-warp-rounding: round up instead.

User Comments: jan.nijtmans added on 2026-10-19 09:49:04:

Now merged to [36a85716|trunk], core-9-0-branch and core-8-6-branch