From 2d31b06c67901db77b34a9207b8b6313d8720279 Mon Sep 17 00:00:00 2001 From: Katayama Hirofumi MZ Date: Fri, 5 May 2023 17:00:05 +0900 Subject: [PATCH] [NTUSER] Remember old KL for Chinese IMEs (#5266) The Chinese user uses Ctrl+Space key combination to switch between the IME keyboard and the non-IME keyboard. To enable Ctrl+Space, the system has to remember the previous keyboard layout. In IntImmActivateLayout function, remember the previous keyboard layout (hklPrev) to switch back for Chinese IMEs. CORE-18950 --- win32ss/user/ntuser/kbdlayout.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/win32ss/user/ntuser/kbdlayout.c b/win32ss/user/ntuser/kbdlayout.c index f3971cf5c67..ef66cad9ddc 100644 --- a/win32ss/user/ntuser/kbdlayout.c +++ b/win32ss/user/ntuser/kbdlayout.c @@ -650,14 +650,21 @@ IntImmActivateLayout( co_IntSendMessage(hImeWnd, WM_IME_SYSTEM, IMS_ACTIVATELAYOUT, (LPARAM)pKL->hkl); UserDerefObjectCo(pImeWnd); } - else if (pti->spDefaultImc) + else { - /* IME Activation is needed */ - pti->pClientInfo->CI_flags |= CI_IMMACTIVATE; + /* Remember old keyboard layout to switch back for Chinese IMEs */ + pti->hklPrev = pti->KeyboardLayout->hkl; + + if (pti->spDefaultImc) + { + /* IME Activation is needed */ + pti->pClientInfo->CI_flags |= CI_IMMACTIVATE; + } } UserAssignmentLock((PVOID*)&(pti->KeyboardLayout), pKL); pti->pClientInfo->hKL = pKL->hkl; + pti->pClientInfo->CodePage = pKL->CodePage; } static VOID co_IntSetKeyboardLayoutForProcess(PPROCESSINFO ppi, PKL pKL)