From 5c779bfa0a5a06e32da05fc1f87ccea731f5efeb Mon Sep 17 00:00:00 2001 From: Aric Stewart Date: Wed, 17 Dec 2008 10:13:27 -0600 Subject: [PATCH] user32: Remove the driver call for GetKeyboardLayoutList and instead populate from the registry. --- dlls/user32/driver.c | 13 ------- dlls/user32/input.c | 56 ++++++++++++++++++++++++++++++- dlls/user32/user_private.h | 1 - dlls/winex11.drv/keyboard.c | 36 -------------------- dlls/winex11.drv/winex11.drv.spec | 1 - 5 files changed, 55 insertions(+), 52 deletions(-) diff --git a/dlls/user32/driver.c b/dlls/user32/driver.c index ed3375fd5d3..2f20b416528 100644 --- a/dlls/user32/driver.c +++ b/dlls/user32/driver.c @@ -77,7 +77,6 @@ static const USER_DRIVER *load_driver(void) GET_USER_FUNC(GetAsyncKeyState); GET_USER_FUNC(GetKeyNameText); GET_USER_FUNC(GetKeyboardLayout); - GET_USER_FUNC(GetKeyboardLayoutList); GET_USER_FUNC(GetKeyboardLayoutName); GET_USER_FUNC(LoadKeyboardLayout); GET_USER_FUNC(MapVirtualKeyEx); @@ -177,11 +176,6 @@ static HKL nulldrv_GetKeyboardLayout( DWORD layout ) return 0; } -static UINT nulldrv_GetKeyboardLayoutList( INT count, HKL *layouts ) -{ - return 0; -} - static BOOL nulldrv_GetKeyboardLayoutName( LPWSTR name ) { return FALSE; @@ -436,7 +430,6 @@ static USER_DRIVER null_driver = nulldrv_GetAsyncKeyState, nulldrv_GetKeyNameText, nulldrv_GetKeyboardLayout, - nulldrv_GetKeyboardLayoutList, nulldrv_GetKeyboardLayoutName, nulldrv_LoadKeyboardLayout, nulldrv_MapVirtualKeyEx, @@ -524,11 +517,6 @@ static HKL loaderdrv_GetKeyboardLayout( DWORD layout ) return load_driver()->pGetKeyboardLayout( layout ); } -static UINT loaderdrv_GetKeyboardLayoutList( INT count, HKL *layouts ) -{ - return load_driver()->pGetKeyboardLayoutList( count, layouts ); -} - static BOOL loaderdrv_GetKeyboardLayoutName( LPWSTR name ) { return load_driver()->pGetKeyboardLayoutName( name ); @@ -783,7 +771,6 @@ static USER_DRIVER lazy_load_driver = loaderdrv_GetAsyncKeyState, loaderdrv_GetKeyNameText, loaderdrv_GetKeyboardLayout, - loaderdrv_GetKeyboardLayoutList, loaderdrv_GetKeyboardLayoutName, loaderdrv_LoadKeyboardLayout, loaderdrv_MapVirtualKeyEx, diff --git a/dlls/user32/input.c b/dlls/user32/input.c index 625ecdcbae6..2b11c7d4196 100644 --- a/dlls/user32/input.c +++ b/dlls/user32/input.c @@ -45,6 +45,7 @@ #include "user_private.h" #include "wine/server.h" #include "wine/debug.h" +#include "wine/unicode.h" WINE_DEFAULT_DEBUG_CHANNEL(win); WINE_DECLARE_DEBUG_CHANNEL(keyboard); @@ -800,9 +801,62 @@ BOOL WINAPI BlockInput(BOOL fBlockIt) */ UINT WINAPI GetKeyboardLayoutList(INT nBuff, 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}; + TRACE_(keyboard)("(%d,%p)\n",nBuff,layouts); - return USER_Driver->pGetKeyboardLayoutList(nBuff, layouts); + baselayout = GetUserDefaultLCID(); + langid = PRIMARYLANGID(LANGIDFROMLCID(baselayout)); + if (langid == LANG_CHINESE || langid == LANG_JAPANESE || langid == LANG_KOREAN) + baselayout |= 0xe001 << 16; /* IME */ + 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)strtoulW(szKeyName,NULL,16); + if (baselayout != 0 && layout == (HKL)baselayout) + baselayout = 0; /* found in the registry do not add again */ + if (nBuff && layouts) + { + if (count >= nBuff ) break; + layouts[count] = layout; + } + count ++; + } + } while (rc == ERROR_SUCCESS); + RegCloseKey(hKeyKeyboard); + } + + /* make sure our base layout is on the list */ + if (baselayout != 0) + { + if (nBuff && layouts) + { + if (count < nBuff) + { + layouts[count] = (HKL)baselayout; + count++; + } + } + else + count++; + } + + return count; } diff --git a/dlls/user32/user_private.h b/dlls/user32/user_private.h index 744a1412c4a..f25f258f495 100644 --- a/dlls/user32/user_private.h +++ b/dlls/user32/user_private.h @@ -109,7 +109,6 @@ typedef struct tagUSER_DRIVER { SHORT (*pGetAsyncKeyState)(INT); INT (*pGetKeyNameText)(LONG, LPWSTR, INT); HKL (*pGetKeyboardLayout)(DWORD); - UINT (*pGetKeyboardLayoutList)(INT, HKL *); BOOL (*pGetKeyboardLayoutName)(LPWSTR); HKL (*pLoadKeyboardLayout)(LPCWSTR, UINT); UINT (*pMapVirtualKeyEx)(UINT, UINT, HKL); diff --git a/dlls/winex11.drv/keyboard.c b/dlls/winex11.drv/keyboard.c index 562b323be7a..fcde245b118 100644 --- a/dlls/winex11.drv/keyboard.c +++ b/dlls/winex11.drv/keyboard.c @@ -1902,42 +1902,6 @@ SHORT X11DRV_GetAsyncKeyState(INT key) } -/*********************************************************************** - * GetKeyboardLayoutList (X11DRV.@) - */ -UINT X11DRV_GetKeyboardLayoutList(INT size, HKL *hkl) -{ - INT i; - - TRACE("%d, %p\n", size, hkl); - - if (!size) - { - size = 4096; /* hope we will never have that many */ - hkl = NULL; - } - - for (i = 0; main_key_tab[i].comment && (i < size); i++) - { - if (hkl) - { - ULONG_PTR layout = main_key_tab[i].lcid; - LANGID langid; - - /* see comment for GetKeyboardLayout */ - langid = PRIMARYLANGID(LANGIDFROMLCID(layout)); - if (langid == LANG_CHINESE || langid == LANG_JAPANESE || langid == LANG_KOREAN) - layout |= 0xe001 << 16; /* FIXME */ - else - layout |= layout << 16; - - hkl[i] = (HKL)layout; - } - } - return i; -} - - /*********************************************************************** * GetKeyboardLayout (X11DRV.@) */ diff --git a/dlls/winex11.drv/winex11.drv.spec b/dlls/winex11.drv/winex11.drv.spec index 585d130933b..fdd32b3a90a 100644 --- a/dlls/winex11.drv/winex11.drv.spec +++ b/dlls/winex11.drv/winex11.drv.spec @@ -69,7 +69,6 @@ @ cdecl GetAsyncKeyState(long) X11DRV_GetAsyncKeyState @ cdecl GetKeyNameText(long ptr long) X11DRV_GetKeyNameText @ cdecl GetKeyboardLayout(long) X11DRV_GetKeyboardLayout -@ cdecl GetKeyboardLayoutList(long ptr) X11DRV_GetKeyboardLayoutList @ cdecl GetKeyboardLayoutName(ptr) X11DRV_GetKeyboardLayoutName @ cdecl LoadKeyboardLayout(wstr long) X11DRV_LoadKeyboardLayout @ cdecl MapVirtualKeyEx(long long long) X11DRV_MapVirtualKeyEx