Commit 30460460 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

user32: Cache current keyboard layout name.

To avoid iterating the registry every time GetKeyboardLayoutNameW is called. Signed-off-by: 's avatarRémi Bernon <rbernon@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent b943a69c
......@@ -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;
......
......@@ -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 */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment