[PATCH 1/4] user32: Factor GetKeyboardLayoutNameW implementations.
Rémi Bernon
rbernon at codeweavers.com
Tue May 4 03:32:04 CDT 2021
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---
dlls/user32/driver.c | 13 -------------
dlls/user32/input.c | 20 ++++++++++++++++----
dlls/user32/user_private.h | 1 -
dlls/winemac.drv/keyboard.c | 15 ---------------
dlls/winemac.drv/winemac.drv.spec | 1 -
dlls/winex11.drv/keyboard.c | 16 +---------------
dlls/winex11.drv/winex11.drv.spec | 1 -
7 files changed, 17 insertions(+), 50 deletions(-)
diff --git a/dlls/user32/driver.c b/dlls/user32/driver.c
index efaa04db096..51149f1cbb1 100644
--- a/dlls/user32/driver.c
+++ b/dlls/user32/driver.c
@@ -110,7 +110,6 @@ static const USER_DRIVER *load_driver(void)
GET_USER_FUNC(GetKeyNameText);
GET_USER_FUNC(GetKeyboardLayout);
GET_USER_FUNC(GetKeyboardLayoutList);
- GET_USER_FUNC(GetKeyboardLayoutName);
GET_USER_FUNC(LoadKeyboardLayout);
GET_USER_FUNC(MapVirtualKeyEx);
GET_USER_FUNC(RegisterHotKey);
@@ -211,11 +210,6 @@ static HKL CDECL nulldrv_GetKeyboardLayout( DWORD thread_id )
return (HKL)~0; /* use default implementation */
}
-static BOOL CDECL nulldrv_GetKeyboardLayoutName( LPWSTR name )
-{
- return FALSE;
-}
-
static HKL CDECL nulldrv_LoadKeyboardLayout( LPCWSTR name, UINT flags )
{
return 0;
@@ -429,7 +423,6 @@ static USER_DRIVER null_driver =
nulldrv_GetKeyNameText,
nulldrv_GetKeyboardLayout,
nulldrv_GetKeyboardLayoutList,
- nulldrv_GetKeyboardLayoutName,
nulldrv_LoadKeyboardLayout,
nulldrv_MapVirtualKeyEx,
nulldrv_RegisterHotKey,
@@ -512,11 +505,6 @@ static UINT CDECL loaderdrv_GetKeyboardLayoutList( INT size, HKL *layouts )
return load_driver()->pGetKeyboardLayoutList( size, layouts );
}
-static BOOL CDECL loaderdrv_GetKeyboardLayoutName( LPWSTR name )
-{
- return load_driver()->pGetKeyboardLayoutName( name );
-}
-
static HKL CDECL loaderdrv_LoadKeyboardLayout( LPCWSTR name, UINT flags )
{
return load_driver()->pLoadKeyboardLayout( name, flags );
@@ -644,7 +632,6 @@ static USER_DRIVER lazy_load_driver =
loaderdrv_GetKeyNameText,
loaderdrv_GetKeyboardLayout,
loaderdrv_GetKeyboardLayoutList,
- loaderdrv_GetKeyboardLayoutName,
loaderdrv_LoadKeyboardLayout,
loaderdrv_MapVirtualKeyEx,
loaderdrv_RegisterHotKey,
diff --git a/dlls/user32/input.c b/dlls/user32/input.c
index 1f795e43545..bf9f5be80a3 100644
--- a/dlls/user32/input.c
+++ b/dlls/user32/input.c
@@ -1105,14 +1105,26 @@ BOOL WINAPI GetKeyboardLayoutNameA(LPSTR pszKLID)
/****************************************************************************
* GetKeyboardLayoutNameW (USER32.@)
*/
-BOOL WINAPI GetKeyboardLayoutNameW(LPWSTR pwszKLID)
+BOOL WINAPI GetKeyboardLayoutNameW( WCHAR *name )
{
- if (!pwszKLID)
+ DWORD tmp;
+ HKL layout;
+
+ TRACE_(keyboard)( "name %p\n", name );
+
+ if (!name)
{
- SetLastError(ERROR_NOACCESS);
+ SetLastError( ERROR_NOACCESS );
return FALSE;
}
- return USER_Driver->pGetKeyboardLayoutName(pwszKLID);
+
+ layout = GetKeyboardLayout( 0 );
+ tmp = HandleToUlong( layout );
+ if (HIWORD( tmp ) == LOWORD( tmp )) tmp = LOWORD( tmp );
+ swprintf( name, KL_NAMELENGTH, L"%08X", tmp );
+
+ TRACE_(keyboard)( "ret %s\n", debugstr_w( name ) );
+ return TRUE;
}
/****************************************************************************
diff --git a/dlls/user32/user_private.h b/dlls/user32/user_private.h
index 5f8059a12a0..de88a3128d7 100644
--- a/dlls/user32/user_private.h
+++ b/dlls/user32/user_private.h
@@ -67,7 +67,6 @@ typedef struct tagUSER_DRIVER {
INT (CDECL *pGetKeyNameText)(LONG, LPWSTR, INT);
HKL (CDECL *pGetKeyboardLayout)(DWORD);
UINT (CDECL *pGetKeyboardLayoutList)(INT, HKL *);
- BOOL (CDECL *pGetKeyboardLayoutName)(LPWSTR);
HKL (CDECL *pLoadKeyboardLayout)(LPCWSTR, UINT);
UINT (CDECL *pMapVirtualKeyEx)(UINT, UINT, HKL);
BOOL (CDECL *pRegisterHotKey)(HWND, UINT, UINT);
diff --git a/dlls/winemac.drv/keyboard.c b/dlls/winemac.drv/keyboard.c
index 6732c5755ee..99367643b8f 100644
--- a/dlls/winemac.drv/keyboard.c
+++ b/dlls/winemac.drv/keyboard.c
@@ -1336,21 +1336,6 @@ UINT CDECL macdrv_GetKeyboardLayoutList(INT size, HKL *list)
return count;
}
-/***********************************************************************
- * GetKeyboardLayoutName (MACDRV.@)
- */
-BOOL CDECL macdrv_GetKeyboardLayoutName(LPWSTR name)
-{
- static const WCHAR formatW[] = {'%','0','8','x',0};
- DWORD layout;
-
- layout = HandleToUlong(macdrv_GetKeyboardLayout(0));
- if (HIWORD(layout) == LOWORD(layout)) layout = LOWORD(layout);
- sprintfW(name, formatW, layout);
- TRACE("returning %s\n", debugstr_w(name));
- return TRUE;
-}
-
/***********************************************************************
* MapVirtualKeyEx (MACDRV.@)
diff --git a/dlls/winemac.drv/winemac.drv.spec b/dlls/winemac.drv/winemac.drv.spec
index 39cf33370b4..45a62255b86 100644
--- a/dlls/winemac.drv/winemac.drv.spec
+++ b/dlls/winemac.drv/winemac.drv.spec
@@ -16,7 +16,6 @@
@ cdecl GetCursorPos(ptr) macdrv_GetCursorPos
@ cdecl GetKeyboardLayout(long) macdrv_GetKeyboardLayout
@ cdecl GetKeyboardLayoutList(long ptr) macdrv_GetKeyboardLayoutList
-@ cdecl GetKeyboardLayoutName(ptr) macdrv_GetKeyboardLayoutName
@ cdecl GetKeyNameText(long ptr long) macdrv_GetKeyNameText
@ cdecl MapVirtualKeyEx(long long long) macdrv_MapVirtualKeyEx
@ cdecl MsgWaitForMultipleObjectsEx(long ptr long long long) macdrv_MsgWaitForMultipleObjectsEx
diff --git a/dlls/winex11.drv/keyboard.c b/dlls/winex11.drv/keyboard.c
index d583c8588cd..cfae93498c5 100644
--- a/dlls/winex11.drv/keyboard.c
+++ b/dlls/winex11.drv/keyboard.c
@@ -1563,20 +1563,6 @@ static HKL get_locale_kbd_layout(void)
return (HKL)layout;
}
-/***********************************************************************
- * GetKeyboardLayoutName (X11DRV.@)
- */
-BOOL CDECL X11DRV_GetKeyboardLayoutName(LPWSTR name)
-{
- static const WCHAR formatW[] = {'%','0','8','x',0};
- DWORD layout;
-
- layout = HandleToUlong( get_locale_kbd_layout() );
- if (HIWORD(layout) == LOWORD(layout)) layout = LOWORD(layout);
- sprintfW(name, formatW, layout);
- TRACE("returning %s\n", debugstr_w(name));
- return TRUE;
-}
static void set_kbd_layout_preload_key(void)
{
@@ -1595,7 +1581,7 @@ static void set_kbd_layout_preload_key(void)
RegCloseKey(hkey);
return;
}
- if (X11DRV_GetKeyboardLayoutName(layout))
+ if (GetKeyboardLayoutNameW( layout ))
RegSetValueExW(hkey, one, 0, REG_SZ, (const BYTE *)layout, sizeof(layout));
RegCloseKey(hkey);
diff --git a/dlls/winex11.drv/winex11.drv.spec b/dlls/winex11.drv/winex11.drv.spec
index c0e24d8fe82..bde1d146ba1 100644
--- a/dlls/winex11.drv/winex11.drv.spec
+++ b/dlls/winex11.drv/winex11.drv.spec
@@ -8,7 +8,6 @@
@ cdecl Beep() X11DRV_Beep
@ cdecl GetKeyNameText(long ptr long) X11DRV_GetKeyNameText
@ cdecl GetKeyboardLayout(long) X11DRV_GetKeyboardLayout
-@ cdecl GetKeyboardLayoutName(ptr) X11DRV_GetKeyboardLayoutName
@ cdecl LoadKeyboardLayout(wstr long) X11DRV_LoadKeyboardLayout
@ cdecl MapVirtualKeyEx(long long long) X11DRV_MapVirtualKeyEx
@ cdecl ToUnicodeEx(long long ptr ptr long long long) X11DRV_ToUnicodeEx
--
2.31.0
More information about the wine-devel
mailing list