From d4e5b0dd1c2fbdc49bc5196918a489972349dc93 Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Mon, 27 Jul 2015 20:06:02 +0100 Subject: [PATCH] Handle the VK_PACKET virtual key code. This is generated in response to the SendInput() Windows API call, if that in turn is passed an KEYBDINPUT structure with KEYEVENTF_UNICODE set. That method of input generation is used by programs such as 'WinCompose' to send an arbitrary Unicode character as if it had been typed at the keyboard, even if the keyboard doesn't actually provide a key for it. Like VK_PROCESSKEY, this key code is an exception to our usual policy of manually translating keystrokes: we handle it by calling TranslateMessage, to get back the Unicode character it contains as a WM_CHAR message. (If that Unicode character in turn is outside the BMP, it may come back as a pair of WM_CHARs in succession containing UTF-16 surrogates; if so, that's OK, because the new Unicode WM_CHAR handler can cope.) (cherry picked from commit 65f3500906c38ee3cf66cc75a015058e5bc6e56d) --- windows/window.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/windows/window.c b/windows/window.c index 5bacdce5..2bbdc263 100644 --- a/windows/window.c +++ b/windows/window.c @@ -76,6 +76,11 @@ #define WHEEL_DELTA 120 #endif +/* VK_PACKET, used to send Unicode characters in WM_KEYDOWNs */ +#ifndef VK_PACKET +#define VK_PACKET 0xE7 +#endif + static Mouse_Button translate_button(Mouse_Button button); static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam, @@ -3086,7 +3091,8 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT message, unsigned char buf[20]; int len; - if (wParam == VK_PROCESSKEY) { /* IME PROCESS key */ + if (wParam == VK_PROCESSKEY || /* IME PROCESS key */ + wParam == VK_PACKET) { /* 'this key is a Unicode char' */ if (message == WM_KEYDOWN) { MSG m; m.hwnd = hwnd; -- 2.45.2