Rémi Bernon : user32: Factor GetKeyboardLayoutNameW implementations.

Alexandre Julliard julliard at winehq.org
Thu May 6 14:56:20 CDT 2021


Module: wine
Branch: master
Commit: c4e6d16271f7b05f5d7c88544b049daaa5c7a3b1
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=c4e6d16271f7b05f5d7c88544b049daaa5c7a3b1

Author: Rémi Bernon <rbernon at codeweavers.com>
Date:   Thu May  6 12:03:12 2021 +0200

user32: Factor GetKeyboardLayoutNameW implementations.

Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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       |  2 +-
 dlls/winex11.drv/winex11.drv.spec |  1 -
 7 files changed, 17 insertions(+), 36 deletions(-)

diff --git a/dlls/user32/driver.c b/dlls/user32/driver.c
index c213f6ecb10..0d0133fe9f5 100644
--- a/dlls/user32/driver.c
+++ b/dlls/user32/driver.c
@@ -109,7 +109,6 @@ static const USER_DRIVER *load_driver(void)
         GET_USER_FUNC(Beep);
         GET_USER_FUNC(GetKeyNameText);
         GET_USER_FUNC(GetKeyboardLayoutList);
-        GET_USER_FUNC(GetKeyboardLayoutName);
         GET_USER_FUNC(LoadKeyboardLayout);
         GET_USER_FUNC(MapVirtualKeyEx);
         GET_USER_FUNC(RegisterHotKey);
@@ -205,11 +204,6 @@ static INT CDECL nulldrv_GetKeyNameText( LONG lparam, LPWSTR buffer, INT size )
     return -1; /* use default implementation */
 }
 
-static BOOL CDECL nulldrv_GetKeyboardLayoutName( LPWSTR name )
-{
-    return FALSE;
-}
-
 static HKL CDECL nulldrv_LoadKeyboardLayout( LPCWSTR name, UINT flags )
 {
     return 0;
@@ -422,7 +416,6 @@ static USER_DRIVER null_driver =
     nulldrv_Beep,
     nulldrv_GetKeyNameText,
     nulldrv_GetKeyboardLayoutList,
-    nulldrv_GetKeyboardLayoutName,
     nulldrv_LoadKeyboardLayout,
     nulldrv_MapVirtualKeyEx,
     nulldrv_RegisterHotKey,
@@ -500,11 +493,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 );
@@ -631,7 +619,6 @@ static USER_DRIVER lazy_load_driver =
     loaderdrv_Beep,
     loaderdrv_GetKeyNameText,
     loaderdrv_GetKeyboardLayoutList,
-    loaderdrv_GetKeyboardLayoutName,
     loaderdrv_LoadKeyboardLayout,
     loaderdrv_MapVirtualKeyEx,
     loaderdrv_RegisterHotKey,
diff --git a/dlls/user32/input.c b/dlls/user32/input.c
index bebdc3e012b..70eca90b425 100644
--- a/dlls/user32/input.c
+++ b/dlls/user32/input.c
@@ -1108,14 +1108,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 48aea824351..c31281b43e5 100644
--- a/dlls/user32/user_private.h
+++ b/dlls/user32/user_private.h
@@ -66,7 +66,6 @@ typedef struct tagUSER_DRIVER {
     void   (CDECL *pBeep)(void);
     INT    (CDECL *pGetKeyNameText)(LONG, LPWSTR, INT);
     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 bdf01e115a0..f4b955cd46a 100644
--- a/dlls/winemac.drv/keyboard.c
+++ b/dlls/winemac.drv/keyboard.c
@@ -1327,21 +1327,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(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 18efd03319c..14667011213 100644
--- a/dlls/winemac.drv/winemac.drv.spec
+++ b/dlls/winemac.drv/winemac.drv.spec
@@ -15,7 +15,6 @@
 @ cdecl EnumDisplaySettingsEx(ptr long ptr long) macdrv_EnumDisplaySettingsEx
 @ cdecl GetCursorPos(ptr) macdrv_GetCursorPos
 @ 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 ce10f6ee1a3..d189f95a7d1 100644
--- a/dlls/winex11.drv/keyboard.c
+++ b/dlls/winex11.drv/keyboard.c
@@ -1566,7 +1566,7 @@ static HKL get_locale_kbd_layout(void)
 /***********************************************************************
  *     GetKeyboardLayoutName (X11DRV.@)
  */
-BOOL CDECL X11DRV_GetKeyboardLayoutName(LPWSTR name)
+static BOOL CDECL X11DRV_GetKeyboardLayoutName(LPWSTR name)
 {
     static const WCHAR formatW[] = {'%','0','8','x',0};
     DWORD layout;
diff --git a/dlls/winex11.drv/winex11.drv.spec b/dlls/winex11.drv/winex11.drv.spec
index 809105f3b4f..eb5f7cecc6c 100644
--- a/dlls/winex11.drv/winex11.drv.spec
+++ b/dlls/winex11.drv/winex11.drv.spec
@@ -7,7 +7,6 @@
 @ cdecl ActivateKeyboardLayout(long long) X11DRV_ActivateKeyboardLayout
 @ cdecl Beep() X11DRV_Beep
 @ cdecl GetKeyNameText(long ptr long) X11DRV_GetKeyNameText
-@ 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




More information about the wine-cvs mailing list