Rémi Bernon : user32: Set keyboard layout preload key on init.

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


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

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

user32: Set keyboard layout preload key on init.

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

---

 dlls/user32/input.c         | 19 +++++++++++++++++++
 dlls/user32/user_main.c     |  1 +
 dlls/user32/user_private.h  |  2 ++
 dlls/winex11.drv/keyboard.c | 39 ---------------------------------------
 4 files changed, 22 insertions(+), 39 deletions(-)

diff --git a/dlls/user32/input.c b/dlls/user32/input.c
index c447cb4b407..2ee1df729a5 100644
--- a/dlls/user32/input.c
+++ b/dlls/user32/input.c
@@ -114,6 +114,25 @@ static HKL get_locale_kbd_layout(void)
 }
 
 
+/**********************************************************************
+ *		keyboard_init
+ */
+void keyboard_init(void)
+{
+    WCHAR layout[KL_NAMELENGTH];
+    HKEY hkey;
+
+    if (RegCreateKeyExW( HKEY_CURRENT_USER, L"Keyboard Layout\\Preload", 0, NULL, 0,
+                         KEY_ALL_ACCESS, NULL, &hkey, NULL ))
+        return;
+
+    if (GetKeyboardLayoutNameW( layout ))
+        RegSetValueExW( hkey, L"1", 0, REG_SZ, (const BYTE *)layout, sizeof(layout) );
+
+    RegCloseKey( hkey );
+}
+
+
 /**********************************************************************
  *		set_capture_window
  */
diff --git a/dlls/user32/user_main.c b/dlls/user32/user_main.c
index c4c4853c213..303f19accfc 100644
--- a/dlls/user32/user_main.c
+++ b/dlls/user32/user_main.c
@@ -331,6 +331,7 @@ static BOOL process_attach(void)
     /* Setup palette function pointers */
     palette_init();
 
+    keyboard_init();
     return TRUE;
 }
 
diff --git a/dlls/user32/user_private.h b/dlls/user32/user_private.h
index c31281b43e5..1c7ac3355bc 100644
--- a/dlls/user32/user_private.h
+++ b/dlls/user32/user_private.h
@@ -242,6 +242,8 @@ struct hardware_msg_data;
 extern BOOL rawinput_from_hardware_message(RAWINPUT *rawinput, const struct hardware_msg_data *msg_data);
 extern struct rawinput_thread_data *rawinput_thread_data(void);
 
+extern void keyboard_init(void) DECLSPEC_HIDDEN;
+
 extern void CLIPBOARD_ReleaseOwner( HWND hwnd ) DECLSPEC_HIDDEN;
 extern BOOL FOCUS_MouseActivate( HWND hwnd ) DECLSPEC_HIDDEN;
 extern BOOL set_capture_window( HWND hwnd, UINT gui_flags, HWND *prev_ret ) DECLSPEC_HIDDEN;
diff --git a/dlls/winex11.drv/keyboard.c b/dlls/winex11.drv/keyboard.c
index d189f95a7d1..7cf2d84ac3c 100644
--- a/dlls/winex11.drv/keyboard.c
+++ b/dlls/winex11.drv/keyboard.c
@@ -1563,43 +1563,6 @@ static HKL get_locale_kbd_layout(void)
     return (HKL)layout;
 }
 
-/***********************************************************************
- *     GetKeyboardLayoutName (X11DRV.@)
- */
-static 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)
-{
-    static const WCHAR preload[] =
-        {'K','e','y','b','o','a','r','d',' ','L','a','y','o','u','t','\\','P','r','e','l','o','a','d',0};
-    static const WCHAR one[] = {'1',0};
-
-    HKEY hkey;
-    WCHAR layout[KL_NAMELENGTH];
-
-    if (RegCreateKeyExW(HKEY_CURRENT_USER, preload, 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hkey, NULL))
-        return;
-
-    if (!RegQueryValueExW(hkey, one, NULL, NULL, NULL, NULL))
-    {
-        RegCloseKey(hkey);
-        return;
-    }
-    if (X11DRV_GetKeyboardLayoutName(layout))
-        RegSetValueExW(hkey, one, 0, REG_SZ, (const BYTE *)layout, sizeof(layout));
-
-    RegCloseKey(hkey);
-}
 
 /**********************************************************************
  *		X11DRV_InitKeyboard
@@ -1634,8 +1597,6 @@ void X11DRV_InitKeyboard( Display *display )
     };
     int vkey_range;
 
-    set_kbd_layout_preload_key();
-
     EnterCriticalSection( &kbd_section );
     XDisplayKeycodes(display, &min_keycode, &max_keycode);
     if (key_mapping) XFree( key_mapping );




More information about the wine-cvs mailing list