Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- 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
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/user32/input.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/dlls/user32/input.c b/dlls/user32/input.c index 70eca90b425..c447cb4b407 100644 --- a/dlls/user32/input.c +++ b/dlls/user32/input.c @@ -1110,7 +1110,9 @@ BOOL WINAPI GetKeyboardLayoutNameA(LPSTR pszKLID) */ BOOL WINAPI GetKeyboardLayoutNameW( WCHAR *name ) { - DWORD tmp; + WCHAR klid[KL_NAMELENGTH], value[5]; + DWORD value_size, tmp, i = 0; + HKEY hkey; HKL layout;
TRACE_(keyboard)( "name %p\n", name ); @@ -1126,6 +1128,25 @@ BOOL WINAPI GetKeyboardLayoutNameW( WCHAR *name ) if (HIWORD( tmp ) == LOWORD( tmp )) tmp = LOWORD( tmp ); swprintf( name, KL_NAMELENGTH, L"%08X", tmp );
+ if (!RegOpenKeyW( HKEY_LOCAL_MACHINE, L"System\CurrentControlSet\Control\Keyboard Layouts", &hkey )) + { + while (!RegEnumKeyW( hkey, i++, klid, ARRAY_SIZE(klid) )) + { + value_size = sizeof(value); + if (!RegGetValueW( hkey, klid, L"Layout Id", RRF_RT_REG_SZ, NULL, (void *)&value, &value_size )) + tmp = 0xf000 | (wcstoul( value, NULL, 16 ) & 0xfff); + else + tmp = wcstoul( klid, NULL, 16 ); + + if (HIWORD( layout ) == tmp) + { + lstrcpynW( name, klid, KL_NAMELENGTH ); + break; + } + } + RegCloseKey( hkey ); + } + TRACE_(keyboard)( "ret %s\n", debugstr_w( name ) ); return TRUE; }
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=89976
Your paranoid android.
=== debiant2 (32 bit report) ===
user32: menu.c:2337: Test failed: test 27
=== debiant2 (32 bit WoW report) ===
user32: msg: Timeout
=== debiant2 (64 bit WoW report) ===
user32: msg.c:8477: Test failed: WmParentPaintNc: 0: the msg 0x000f was expected, but got msg 0x0021 instead msg.c:8477: Test failed: WmParentPaintNc: 1: the msg 0x000f was expected, but got msg 0x0021 instead msg.c:8477: Test failed: WmParentPaintNc: 2: the msg 0x0085 was expected, but got msg 0x0021 instead msg.c:8477: Test failed: WmParentPaintNc: 6: the msg sequence is not complete: expected 0000 - actual 000f
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- 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 );
To match VkKeyScanW and pass corresponding tests.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/user32/input.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/dlls/user32/input.c b/dlls/user32/input.c index 2ee1df729a5..adeb4f66804 100644 --- a/dlls/user32/input.c +++ b/dlls/user32/input.c @@ -1323,8 +1323,11 @@ INT WINAPI ToUnicodeEx( UINT virt, UINT scan, const BYTE *state, case VK_OEM_4: buffer[0] = 0x1b; break; case VK_OEM_5: buffer[0] = 0x1c; break; case VK_OEM_6: buffer[0] = 0x1d; break; - case VK_SUBTRACT: buffer[0] = 0x1e; break; + case '6': buffer[0] = shift ? 0x1e : 0; break; + case VK_OEM_MINUS: buffer[0] = shift ? 0x1f : 0; break; + case VK_BACK: buffer[0] = 0x7f; break; case VK_RETURN: buffer[0] = shift ? 0 : '\n'; break; + case '2': buffer[0] = shift ? 0xffff : 0xf000; break; case VK_SPACE: buffer[0] = ' '; break; default: if (virt >= 'A' && virt <= 'Z') buffer[0] = virt - 'A' + 1; @@ -1335,6 +1338,7 @@ INT WINAPI ToUnicodeEx( UINT virt, UINT scan, const BYTE *state, else buffer[0] = 0; buffer[1] = 0; len = wcslen( buffer ); + if (buffer[0] == 0xffff) buffer[0] = 0; lstrcpynW( str, buffer, size );
TRACE_(keyboard)( "ret %d, str %s.\n", len, debugstr_w(str) );
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=89978
Your paranoid android.
=== debiant2 (64 bit WoW report) ===
user32: menu.c:2337: Test failed: test 27
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/user32/driver.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/dlls/user32/driver.c b/dlls/user32/driver.c index 0d0133fe9f5..36438fa44c8 100644 --- a/dlls/user32/driver.c +++ b/dlls/user32/driver.c @@ -249,17 +249,17 @@ static void CDECL nulldrv_SetCursor( HCURSOR cursor )
static BOOL CDECL nulldrv_GetCursorPos( LPPOINT pt ) { - return FALSE; + return TRUE; }
static BOOL CDECL nulldrv_SetCursorPos( INT x, INT y ) { - return FALSE; + return TRUE; }
static BOOL CDECL nulldrv_ClipCursor( LPCRECT clip ) { - return FALSE; + return TRUE; }
static void CDECL nulldrv_UpdateClipboard(void)