Tk Source Code

View Ticket
Login
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