Tk Source Code

Check-in [04cfb8ed]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix [a9bd2ab98b]: Keyboard input on Windows depends on the input language rather than on the keyboard layout

GetTranslatedKey() retrieved the WM_CHAR messages of a Unicode window with GetMessageA(), so Windows converted the characters to the code page of the keyboard layout, and TkpGetString() decoded them with a code page guessed from the input language (at startup) or from WM_INPUTLANGCHANGE. When the two differ, e.g. an English input language with a Hungarian or Ukrainian layout, the typed characters were mangled (o with double acute became o with tilde) until the input language was switched.

Now the WM_CHAR messages are retrieved as Unicode and the characters are stored as UTF-8 in the key event, for WM_KEYDOWN as well as for WM_CHAR messages, and the code page machinery is removed.

Downloads: See separate download page
Timelines: family | ancestors | descendants | both | win-unicode-keyinput
Files: files | file ages | folders
SHA3-256: 04cfb8ed11c5d93361a53aad7e040b589a99f5d1c1165cb2433a56bfc372deb9
User & Date: serhiy.storchaka 2026-09-17 20:24:23.469
Context
2026-09-22
06:08
Add tests for [a9bd2ab98b], with a testsendinput command which injects keyboard input with SendInput() and switches the keyboard layout closed check-in: f904b5db user: serhiy.storchaka tags: win-unicode-keyinput
2026-09-18
17:42
Fix [f492c3de04]: MS-Win: characters entered via an IME or the touch keyboard get the keysym of a function key

The WM_KEYDOWN message with VK_PACKET was re-posted with the character as the virtual key code, so the KeyPress event had e.g. keysym F3 for "r". Now no events are generated for the VK_PACKET key itself; the WM_CHAR message produced by TranslateMessage() generates the key events. check-in: f173717b user: serhiy.storchaka tags: win-vk-packet

2026-09-17
20:24
Fix [a9bd2ab98b]: Keyboard input on Windows depends on the input language rather than on the keyboard layout

GetTranslatedKey() retrieved the WM_CHAR messages of a Unicode window with GetMessageA(), so Windows converted the characters to the code page of the keyboard layout, and TkpGetString() decoded them with a code page guessed from the input language (at startup) or from WM_INPUTLANGCHANGE. When the two differ, e.g. an English input language with a Hungarian or Ukrainian layout, the typed characters were mangled (o with double acute became o with tilde) until the input language was switched.

Now the WM_CHAR messages are retrieved as Unicode and the characters are stored as UTF-8 in the key event, for WM_KEYDOWN as well as for WM_CHAR messages, and the code page machinery is removed. check-in: 04cfb8ed user: serhiy.storchaka tags: win-unicode-keyinput

14:49
Follow-up to [3cb7c4ac72]: don't clamp the result of Tk_GetUserInactiveTime() on Windows check-in: d2b7156d user: jan.nijtmans tags: trunk, main
Changes
Unified Diff Side-by-Side Diff Patch
Changes to generic/tkInt.h.
Changes to win/tkWinInt.h.
Changes to win/tkWinKey.c.
Changes to win/tkWinX.c.