Rémi Bernon : user32: Cache current keyboard layout name.
Alexandre Julliard
julliard at winehq.org
Fri May 7 15:42:04 CDT 2021
Module: wine
Branch: master
Commit: 30460460e52731ef2979c4b528cb4fdc86dacac7
URL: https://source.winehq.org/git/wine.git/?a=commit;h=30460460e52731ef2979c4b528cb4fdc86dacac7
Author: Rémi Bernon <rbernon at codeweavers.com>
Date: Fri May 7 10:29:43 2021 +0200
user32: Cache current keyboard layout name.
To avoid iterating the registry every time GetKeyboardLayoutNameW is
called.
Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/user32/input.c | 10 ++++++++++
dlls/user32/user_private.h | 1 +
2 files changed, 11 insertions(+)
diff --git a/dlls/user32/input.c b/dlls/user32/input.c
index adeb4f66804..1b2360ea083 100644
--- a/dlls/user32/input.c
+++ b/dlls/user32/input.c
@@ -1129,6 +1129,7 @@ BOOL WINAPI GetKeyboardLayoutNameA(LPSTR pszKLID)
*/
BOOL WINAPI GetKeyboardLayoutNameW( WCHAR *name )
{
+ struct user_thread_info *info = get_user_thread_info();
WCHAR klid[KL_NAMELENGTH], value[5];
DWORD value_size, tmp, i = 0;
HKEY hkey;
@@ -1142,6 +1143,12 @@ BOOL WINAPI GetKeyboardLayoutNameW( WCHAR *name )
return FALSE;
}
+ if (info->kbd_layout_id)
+ {
+ swprintf( name, KL_NAMELENGTH, L"%08X", info->kbd_layout_id );
+ return TRUE;
+ }
+
layout = GetKeyboardLayout( 0 );
tmp = HandleToUlong( layout );
if (HIWORD( tmp ) == LOWORD( tmp )) tmp = LOWORD( tmp );
@@ -1166,6 +1173,8 @@ BOOL WINAPI GetKeyboardLayoutNameW( WCHAR *name )
RegCloseKey( hkey );
}
+ info->kbd_layout_id = wcstoul( name, NULL, 16 );
+
TRACE_(keyboard)( "ret %s\n", debugstr_w( name ) );
return TRUE;
}
@@ -1394,6 +1403,7 @@ HKL WINAPI ActivateKeyboardLayout( HKL layout, UINT flags )
old_layout = info->kbd_layout;
info->kbd_layout = layout;
+ if (old_layout != layout) info->kbd_layout_id = 0;
if (!old_layout) return get_locale_kbd_layout();
return old_layout;
diff --git a/dlls/user32/user_private.h b/dlls/user32/user_private.h
index 1c7ac3355bc..1bc41888891 100644
--- a/dlls/user32/user_private.h
+++ b/dlls/user32/user_private.h
@@ -198,6 +198,7 @@ struct user_thread_info
ULONG_PTR GetMessageExtraInfoVal; /* Value for GetMessageExtraInfo */
struct user_key_state_info *key_state; /* Cache of global key state */
HKL kbd_layout; /* Current keyboard layout */
+ DWORD kbd_layout_id; /* Current keyboard layout ID */
HWND top_window; /* Desktop window */
HWND msg_window; /* HWND_MESSAGE parent window */
struct rawinput_thread_data *rawinput; /* RawInput thread local data / buffer */
More information about the wine-cvs
mailing list