Updated loader-KeyboardLayouts patchset

This commit is contained in:
Alistair Leslie-Hughes 2019-07-10 08:37:16 +10:00
parent f07181375b
commit accf189516
2 changed files with 119 additions and 1 deletions

View File

@ -0,0 +1,116 @@
From 9d2559409ee8860dd21dd86aedb9442389ba41fe Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Tue, 9 Jul 2019 14:13:28 +1000
Subject: [PATCH] user32: Improve GetKeyboardLayoutList
This function returns the current list of *installed* Keyboard layouts
not the complete list from the registry.
---
dlls/user32/driver.c | 27 ---------------------------
dlls/user32/tests/input.c | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 35 insertions(+), 27 deletions(-)
diff --git a/dlls/user32/driver.c b/dlls/user32/driver.c
index 921ea2c962..953eec47de 100644
--- a/dlls/user32/driver.c
+++ b/dlls/user32/driver.c
@@ -213,12 +213,9 @@ static SHORT CDECL nulldrv_GetAsyncKeyState( INT key )
static UINT CDECL nulldrv_GetKeyboardLayoutList( INT size, HKL *layouts )
{
- HKEY hKeyKeyboard;
- DWORD rc;
INT count = 0;
ULONG_PTR baselayout;
LANGID langid;
- static const WCHAR szKeyboardReg[] = {'S','y','s','t','e','m','\\','C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\','C','o','n','t','r','o','l','\\','K','e','y','b','o','a','r','d',' ','L','a','y','o','u','t','s',0};
baselayout = GetUserDefaultLCID();
langid = PRIMARYLANGID(LANGIDFROMLCID(baselayout));
@@ -227,30 +224,6 @@ static UINT CDECL nulldrv_GetKeyboardLayoutList( INT size, HKL *layouts )
else
baselayout |= baselayout << 16;
- /* Enumerate the Registry */
- rc = RegOpenKeyW(HKEY_LOCAL_MACHINE,szKeyboardReg,&hKeyKeyboard);
- if (rc == ERROR_SUCCESS)
- {
- do {
- WCHAR szKeyName[9];
- HKL layout;
- rc = RegEnumKeyW(hKeyKeyboard, count, szKeyName, 9);
- if (rc == ERROR_SUCCESS)
- {
- layout = (HKL)(ULONG_PTR)strtoulW(szKeyName,NULL,16);
- if (baselayout != 0 && layout == (HKL)baselayout)
- baselayout = 0; /* found in the registry do not add again */
- if (size && layouts)
- {
- if (count >= size ) break;
- layouts[count] = layout;
- }
- count ++;
- }
- } while (rc == ERROR_SUCCESS);
- RegCloseKey(hKeyKeyboard);
- }
-
/* make sure our base layout is on the list */
if (baselayout != 0)
{
diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c
index d0dc4a8bcf..4a99d8d4e9 100644
--- a/dlls/user32/tests/input.c
+++ b/dlls/user32/tests/input.c
@@ -2862,6 +2862,40 @@ static void test_GetPointerType(void)
ok(type == PT_MOUSE, " type %d\n", type );
}
+static void test_GetKeyboardLayoutList(void)
+{
+ int cnt, cnt2;
+ HKL *layouts;
+ ULONG_PTR baselayout;
+ LANGID langid;
+
+ baselayout = GetUserDefaultLCID();
+ langid = PRIMARYLANGID(LANGIDFROMLCID(baselayout));
+ if (langid == LANG_CHINESE || langid == LANG_JAPANESE || langid == LANG_KOREAN)
+ baselayout = MAKELONG( baselayout, 0xe001 ); /* IME */
+ else
+ baselayout |= baselayout << 16;
+
+ cnt = GetKeyboardLayoutList(0, NULL);
+ /* Most users will not have more than a few keyboard layouts installed at a time. */
+ ok(cnt > 0 && cnt < 10, "Layout count %d\n", cnt);
+ if (cnt > 0)
+ {
+ layouts = HeapAlloc(GetProcessHeap(), 0, sizeof(*layouts) * cnt );
+
+ cnt2 = GetKeyboardLayoutList(cnt, layouts);
+ ok(cnt == cnt2, "wrong value %d!=%d\n", cnt, cnt2);
+ for(cnt = 0; cnt < cnt2; cnt++)
+ {
+ if(layouts[cnt] == (HKL)baselayout)
+ break;
+ }
+ ok(cnt < cnt2, "Didnt find current keyboard\n");
+
+ HeapFree(GetProcessHeap(), 0, layouts);
+ }
+}
+
START_TEST(input)
{
POINT pos;
@@ -2885,6 +2919,7 @@ START_TEST(input)
test_GetKeyState();
test_OemKeyScan();
test_GetRawInputData();
+ test_GetKeyboardLayoutList();
if(pGetMouseMovePointsEx)
test_GetMouseMovePointsEx();
--
2.17.1

View File

@ -4351,12 +4351,14 @@ fi
# | * [#47439] loader: Add Keyboard Layouts registry enteries.
# |
# | Modified files:
# | * loader/wine.inf.in
# | * dlls/user32/driver.c, dlls/user32/tests/input.c, loader/wine.inf.in
# |
if test "$enable_loader_KeyboardLayouts" -eq 1; then
patch_apply loader-KeyboardLayouts/0001-loader-Add-Keyboard-Layouts-registry-enteries.patch
patch_apply loader-KeyboardLayouts/0002-user32-Improve-GetKeyboardLayoutList.patch
(
printf '%s\n' '+ { "Alistair Leslie-Hughes", "loader: Add Keyboard Layouts registry enteries.", 1 },';
printf '%s\n' '+ { "Alistair Leslie-Hughes", "user32: Improve GetKeyboardLayoutList.", 1 },';
) >> "$patchlist"
fi