From 80342a0c10c73342e52b3b6ff4998c8e72281211 Mon Sep 17 00:00:00 2001 From: Eric Pouech Date: Thu, 23 May 2024 12:42:40 +0200 Subject: [PATCH] conhost: Support IME input in window mode. Signed-off-by: Eric Pouech --- programs/conhost/conhost.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/programs/conhost/conhost.c b/programs/conhost/conhost.c index 4272e8b12f5..7610cb69c72 100644 --- a/programs/conhost/conhost.c +++ b/programs/conhost/conhost.c @@ -2841,6 +2841,12 @@ static NTSTATUS process_console_ioctls( struct console *console ) } } +static BOOL is_key_message( const MSG *msg ) +{ + return msg->message == WM_KEYDOWN || msg->message == WM_SYSKEYDOWN || + msg->message == WM_KEYUP || msg->message == WM_SYSKEYUP; +} + static int main_loop( struct console *console, HANDLE signal ) { HANDLE signal_event = NULL; @@ -2875,10 +2881,15 @@ static int main_loop( struct console *console, HANDLE signal ) if (res == WAIT_OBJECT_0 + wait_cnt) { MSG msg; + while (PeekMessageW( &msg, 0, 0, 0, PM_REMOVE )) { + BOOL translated = FALSE; if (msg.message == WM_QUIT) return 0; - DispatchMessageW(&msg); + if (is_key_message( &msg ) && msg.wParam == VK_PROCESSKEY) + translated = TranslateMessage( &msg ); + if (!translated || msg.hwnd != console->win) + DispatchMessageW( &msg ); } continue; }