From: Alistair Leslie-Hughes leslie_alistair@hotmail.com
This function returns only those keyboards currently configured by the user, whereas the "Keyboard Layouts" key contains all keyboards that can be configured.
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/win32u/input.c | 44 +++----------------------------------------- 1 file changed, 3 insertions(+), 41 deletions(-)
diff --git a/dlls/win32u/input.c b/dlls/win32u/input.c index addff0e5fb3..70b4d7e4fb5 100644 --- a/dlls/win32u/input.c +++ b/dlls/win32u/input.c @@ -929,54 +929,16 @@ HKL WINAPI NtUserActivateKeyboardLayout( HKL layout, UINT flags ) */ UINT WINAPI NtUserGetKeyboardLayoutList( INT size, HKL *layouts ) { - char buffer[4096]; - KEY_NODE_INFORMATION *key_info = (KEY_NODE_INFORMATION *)buffer; - KEY_VALUE_PARTIAL_INFORMATION *value_info = (KEY_VALUE_PARTIAL_INFORMATION *)buffer; - DWORD count, tmp, i = 0; - HKEY hkey, subkey; - HKL layout; + DWORD count;
TRACE_(keyboard)( "size %d, layouts %p.\n", size, layouts );
if ((count = user_driver->pGetKeyboardLayoutList( size, layouts )) != ~0) return count;
- layout = get_locale_kbd_layout(); - count = 0; - - count++; if (size && layouts) - { - layouts[count - 1] = layout; - if (count == size) return count; - } + layouts[0] = get_locale_kbd_layout();
- if ((hkey = reg_open_key( NULL, keyboard_layouts_keyW, sizeof(keyboard_layouts_keyW) ))) - { - while (!NtEnumerateKey( hkey, i++, KeyNodeInformation, key_info, - sizeof(buffer) - sizeof(WCHAR), &tmp )) - { - if (!(subkey = reg_open_key( hkey, key_info->Name, key_info->NameLength ))) continue; - key_info->Name[key_info->NameLength / sizeof(WCHAR)] = 0; - tmp = wcstoul( key_info->Name, NULL, 16 ); - if (query_reg_ascii_value( subkey, "Layout Id", value_info, sizeof(buffer) ) && - value_info->Type == REG_SZ) - tmp = MAKELONG( LOWORD( tmp ), - 0xf000 | (wcstoul( (const WCHAR *)value_info->Data, NULL, 16 ) & 0xfff) ); - NtClose( subkey ); - - if (layout == UlongToHandle( tmp )) continue; - - count++; - if (size && layouts) - { - layouts[count - 1] = UlongToHandle( tmp ); - if (count == size) break; - } - } - NtClose( hkey ); - } - - return count; + return 1; }
/****************************************************************************
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47439 Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/win32u/sysparams.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-)
diff --git a/dlls/win32u/sysparams.c b/dlls/win32u/sysparams.c index c542de61451..81b64d1abf7 100644 --- a/dlls/win32u/sysparams.c +++ b/dlls/win32u/sysparams.c @@ -3117,11 +3117,12 @@ static union sysparam_all_entry * const default_entries[] =
void sysparams_init(void) { - DWORD i, dispos, dpi_scaling; WCHAR layout[KL_NAMELENGTH]; + char layoutA[KL_NAMELENGTH]; pthread_mutexattr_t attr; - HKEY hkey; + HKEY layout_key, hkey; + unsigned int hkl;
static const WCHAR software_wineW[] = {'S','o','f','t','w','a','r','e','\','W','i','n','e'}; static const WCHAR temporary_system_parametersW[] = @@ -3130,17 +3131,31 @@ void sysparams_init(void) static const WCHAR oneW[] = {'1',0}; static const WCHAR kl_preloadW[] = {'K','e','y','b','o','a','r','d',' ','L','a','y','o','u','t','\','P','r','e','l','o','a','d'}; + static const WCHAR keyboard_layoutsW[] = {'K','e','y','b','o','a','r','d',' ','L','a','y','o','u','t','s'};
pthread_mutexattr_init( &attr ); pthread_mutexattr_settype( &attr, PTHREAD_MUTEX_RECURSIVE ); pthread_mutex_init( &user_mutex, &attr ); pthread_mutexattr_destroy( &attr );
+ hkl = (ULONG_PTR)NtUserGetKeyboardLayout( 0 ); + if (HIWORD( hkl ) == LOWORD( hkl )) hkl = LOWORD( hkl ); + sprintf( layoutA, "%08X", hkl ); + asciiz_to_unicode( layout, layoutA ); + if ((hkey = reg_create_key( hkcu_key, kl_preloadW, sizeof(kl_preloadW), 0, NULL ))) { - if (NtUserGetKeyboardLayoutName( layout )) - set_reg_value( hkey, oneW, REG_SZ, (const BYTE *)layout, - (lstrlenW(layout) + 1) * sizeof(WCHAR) ); + set_reg_value( hkey, oneW, REG_SZ, (const BYTE *)layout, + (wcslen(layout) + 1) * sizeof(WCHAR) ); + NtClose( hkey ); + } + + if (!control_key) control_key = reg_create_key( NULL, control_keyW, sizeof(control_keyW), 0, NULL ); + + if ((hkey = reg_create_key( control_key, keyboard_layoutsW, sizeof(keyboard_layoutsW), 0, NULL ))) + { + if ((layout_key = reg_create_key( hkey, layout, wcslen( layout ) * sizeof(WCHAR), 0, NULL ))) + NtClose( layout_key ); NtClose( hkey ); }