https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8e110335e706a267cae1d…
commit 8e110335e706a267cae1d691a6ac774add6ad931
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Wed Sep 14 02:58:28 2022 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Wed Sep 14 02:58:28 2022 +0900
[USER32] Load keyboard layouts on logon correctly (#4686)
- Add IntLoadPreloadKeyboardLayouts helper function to load the layouts on log-on.
- In UpdatePerUserSystemParameters function, call CliImmInitializeHotKeys and
IntLoadPreloadKeyboardLayouts functions.
CORE-16600
---
win32ss/user/user32/include/user32p.h | 2 ++
win32ss/user/user32/misc/logon.c | 6 ++++
win32ss/user/user32/windows/input.c | 63 +++++++++++++++++++++++++++++++++++
3 files changed, 71 insertions(+)
diff --git a/win32ss/user/user32/include/user32p.h
b/win32ss/user/user32/include/user32p.h
index 78a0b6be53f..e531ad847af 100644
--- a/win32ss/user/user32/include/user32p.h
+++ b/win32ss/user/user32/include/user32p.h
@@ -130,5 +130,7 @@ HANDLE FASTCALL UserGetProp(HWND hWnd, ATOM Atom, BOOLEAN
SystemProp);
BOOL WINAPI InitializeImmEntryTable(VOID);
HRESULT User32GetImmFileName(_Out_ LPWSTR lpBuffer, _In_ size_t cchBuffer);
BOOL WINAPI UpdatePerUserImmEnabling(VOID);
+VOID APIENTRY CliImmInitializeHotKeys(DWORD dwAction, HKL hKL);
+VOID IntLoadPreloadKeyboardLayouts(VOID);
/* EOF */
diff --git a/win32ss/user/user32/misc/logon.c b/win32ss/user/user32/misc/logon.c
index bc735aa7ab4..a763e24e370 100644
--- a/win32ss/user/user32/misc/logon.c
+++ b/win32ss/user/user32/misc/logon.c
@@ -104,5 +104,11 @@ UpdatePerUserSystemParameters(DWORD dwReserved,
// Update Imm support and load Imm32.dll.
UpdatePerUserImmEnabling();
+ /* Delete all the IME hotkeys */
+ CliImmInitializeHotKeys(SETIMEHOTKEY_DELETEALL, NULL);
+
+ /* Load Preload keyboard layouts */
+ IntLoadPreloadKeyboardLayouts();
+
return NtUserUpdatePerUserSystemParameters(dwReserved, bEnable);
}
diff --git a/win32ss/user/user32/windows/input.c b/win32ss/user/user32/windows/input.c
index a018d3aeca2..87df74fc06b 100644
--- a/win32ss/user/user32/windows/input.c
+++ b/win32ss/user/user32/windows/input.c
@@ -143,6 +143,69 @@ Failure:
return FALSE;
}
+
+/* Win: LoadPreloadKeyboardLayouts */
+VOID IntLoadPreloadKeyboardLayouts(VOID)
+{
+ UINT nNumber, uFlags;
+ DWORD cbValue, dwType;
+ WCHAR szNumber[32], szValue[KL_NAMELENGTH];
+ HKEY hPreloadKey;
+ BOOL bOK = FALSE;
+ HKL hKL, hDefaultKL = NULL;
+
+ if (RegOpenKeyW(HKEY_CURRENT_USER,
+ L"Keyboard Layout\\Preload",
+ &hPreloadKey) != ERROR_SUCCESS)
+ {
+ return;
+ }
+
+ for (nNumber = 1; nNumber <= 1000; ++nNumber)
+ {
+ _ultow(nNumber, szNumber, 10);
+
+ cbValue = sizeof(szValue);
+ if (RegQueryValueExW(hPreloadKey,
+ szNumber,
+ NULL,
+ &dwType,
+ (LPBYTE)szValue,
+ &cbValue) != ERROR_SUCCESS)
+ {
+ break;
+ }
+
+ if (dwType != REG_SZ)
+ continue;
+
+ if (nNumber == 1) /* The first entry is for default keyboard layout */
+ uFlags = KLF_SUBSTITUTE_OK | KLF_ACTIVATE | KLF_RESET;
+ else
+ uFlags = KLF_SUBSTITUTE_OK | KLF_NOTELLSHELL | KLF_REPLACELANG;
+
+ hKL = LoadKeyboardLayoutW(szValue, uFlags);
+ if (hKL)
+ {
+ bOK = TRUE;
+ if (nNumber == 1) /* The first entry */
+ hDefaultKL = hKL;
+ }
+ }
+
+ RegCloseKey(hPreloadKey);
+
+ if (hDefaultKL)
+ SystemParametersInfoW(SPI_SETDEFAULTINPUTLANG, 0, &hDefaultKL, 0);
+
+ if (!bOK)
+ {
+ /* Fallback to English (US) */
+ LoadKeyboardLayoutW(L"00000409", KLF_SUBSTITUTE_OK | KLF_ACTIVATE |
KLF_RESET);
+ }
+}
+
+
BOOL APIENTRY
CliSaveImeHotKey(DWORD dwID, UINT uModifiers, UINT uVirtualKey, HKL hKL, BOOL bDelete)
{