Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/user32/defwnd.c | 2 ++ dlls/user32/input.c | 4 ++++ dlls/user32/user_private.h | 1 + 3 files changed, 7 insertions(+)
diff --git a/dlls/user32/defwnd.c b/dlls/user32/defwnd.c index d00fc8584c6..a3d92e84aef 100644 --- a/dlls/user32/defwnd.c +++ b/dlls/user32/defwnd.c @@ -728,8 +728,10 @@ static LRESULT DEFWND_DefWinProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPa
case WM_INPUTLANGCHANGE: { + struct user_thread_info *info = get_user_thread_info(); int count = 0; HWND *win_array = WIN_ListChildren( hwnd ); + info->kbd_layout = (HKL)lParam;
if (!win_array) break; diff --git a/dlls/user32/input.c b/dlls/user32/input.c index 1f795e43545..8e5ab91baf3 100644 --- a/dlls/user32/input.c +++ b/dlls/user32/input.c @@ -1316,6 +1316,7 @@ INT WINAPI ToAsciiEx( UINT virtKey, UINT scanCode, const BYTE *lpKeyState, */ HKL WINAPI ActivateKeyboardLayout( HKL layout, UINT flags ) { + struct user_thread_info *info = get_user_thread_info(); HKL old_layout;
TRACE_(keyboard)( "layout %p, flags %x\n", layout, flags ); @@ -1330,7 +1331,10 @@ HKL WINAPI ActivateKeyboardLayout( HKL layout, UINT flags ) }
if ((old_layout = USER_Driver->pActivateKeyboardLayout( layout, flags )) != (HKL)~0) + { + if (old_layout) info->kbd_layout = layout; return old_layout; + }
return get_locale_kbd_layout(); } diff --git a/dlls/user32/user_private.h b/dlls/user32/user_private.h index 5f8059a12a0..7ac65a34db3 100644 --- a/dlls/user32/user_private.h +++ b/dlls/user32/user_private.h @@ -199,6 +199,7 @@ struct user_thread_info DWORD GetMessagePosVal; /* Value for GetMessagePos */ ULONG_PTR GetMessageExtraInfoVal; /* Value for GetMessageExtraInfo */ struct user_key_state_info *key_state; /* Cache of global key state */ + HKL kbd_layout; /* Current keyboard layout */ HWND top_window; /* Desktop window */ HWND msg_window; /* HWND_MESSAGE parent window */ struct rawinput_thread_data *rawinput; /* RawInput thread local data / buffer */
To update user32 current keyboard layout as well.
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/winemac.drv/keyboard.c | 5 +++++ dlls/winemac.drv/macdrv_main.c | 1 + 2 files changed, 6 insertions(+)
diff --git a/dlls/winemac.drv/keyboard.c b/dlls/winemac.drv/keyboard.c index 6732c5755ee..0648b00a4f1 100644 --- a/dlls/winemac.drv/keyboard.c +++ b/dlls/winemac.drv/keyboard.c @@ -1054,6 +1054,8 @@ void macdrv_keyboard_changed(const macdrv_event *event)
macdrv_compute_keyboard_layout(thread_data);
+ ActivateKeyboardLayout(thread_data->active_keyboard_layout, 0); + SendMessageW(GetActiveWindow(), WM_CANCELMODE, 0, 0); }
@@ -1169,6 +1171,9 @@ HKL CDECL macdrv_ActivateKeyboardLayout(HKL hkl, UINT flags)
TRACE("hkl %p flags %04x\n", hkl, flags);
+ if (hkl == thread_data->active_keyboard_layout) + return hkl; + EnterCriticalSection(&layout_list_section); update_layout_list();
diff --git a/dlls/winemac.drv/macdrv_main.c b/dlls/winemac.drv/macdrv_main.c index 694a46b11e6..203e993ee93 100644 --- a/dlls/winemac.drv/macdrv_main.c +++ b/dlls/winemac.drv/macdrv_main.c @@ -384,6 +384,7 @@ struct macdrv_thread_data *macdrv_init_thread_data(void) set_queue_display_fd(macdrv_get_event_queue_fd(data->queue)); TlsSetValue(thread_data_tls_index, data);
+ ActivateKeyboardLayout(data->active_keyboard_layout, 0); return data; }
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/user32/driver.c | 6 +++--- dlls/user32/input.c | 13 +++++++------ dlls/user32/user_private.h | 2 +- dlls/winemac.drv/keyboard.c | 10 +++++----- dlls/winex11.drv/keyboard.c | 13 ++++--------- 5 files changed, 20 insertions(+), 24 deletions(-)
diff --git a/dlls/user32/driver.c b/dlls/user32/driver.c index efaa04db096..daba4bb7c01 100644 --- a/dlls/user32/driver.c +++ b/dlls/user32/driver.c @@ -187,9 +187,9 @@ void USER_unload_driver(void) * These are fallbacks for entry points that are not implemented in the real driver. */
-static HKL CDECL nulldrv_ActivateKeyboardLayout( HKL layout, UINT flags ) +static BOOL CDECL nulldrv_ActivateKeyboardLayout( HKL layout, UINT flags ) { - return (HKL)~0; /* use default implementation */ + return TRUE; }
static void CDECL nulldrv_Beep(void) @@ -487,7 +487,7 @@ static USER_DRIVER null_driver = * Each entry point simply loads the real driver and chains to it. */
-static HKL CDECL loaderdrv_ActivateKeyboardLayout( HKL layout, UINT flags ) +static BOOL CDECL loaderdrv_ActivateKeyboardLayout( HKL layout, UINT flags ) { return load_driver()->pActivateKeyboardLayout( layout, flags ); } diff --git a/dlls/user32/input.c b/dlls/user32/input.c index 8e5ab91baf3..8436347b0b0 100644 --- a/dlls/user32/input.c +++ b/dlls/user32/input.c @@ -1330,13 +1330,14 @@ HKL WINAPI ActivateKeyboardLayout( HKL layout, UINT flags ) return 0; }
- if ((old_layout = USER_Driver->pActivateKeyboardLayout( layout, flags )) != (HKL)~0) - { - if (old_layout) info->kbd_layout = layout; - return old_layout; - } + if (!USER_Driver->pActivateKeyboardLayout( layout, flags )) + return 0;
- return get_locale_kbd_layout(); + old_layout = info->kbd_layout; + info->kbd_layout = layout; + + 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 7ac65a34db3..e568054165a 100644 --- a/dlls/user32/user_private.h +++ b/dlls/user32/user_private.h @@ -62,7 +62,7 @@ enum wine_internal_message
typedef struct tagUSER_DRIVER { /* keyboard functions */ - HKL (CDECL *pActivateKeyboardLayout)(HKL, UINT); + BOOL (CDECL *pActivateKeyboardLayout)(HKL, UINT); void (CDECL *pBeep)(void); INT (CDECL *pGetKeyNameText)(LONG, LPWSTR, INT); HKL (CDECL *pGetKeyboardLayout)(DWORD); diff --git a/dlls/winemac.drv/keyboard.c b/dlls/winemac.drv/keyboard.c index 0648b00a4f1..300bc84d664 100644 --- a/dlls/winemac.drv/keyboard.c +++ b/dlls/winemac.drv/keyboard.c @@ -1163,16 +1163,16 @@ void macdrv_process_text_input(UINT vkey, UINT scan, UINT repeat, const BYTE *ke /*********************************************************************** * ActivateKeyboardLayout (MACDRV.@) */ -HKL CDECL macdrv_ActivateKeyboardLayout(HKL hkl, UINT flags) +BOOL CDECL macdrv_ActivateKeyboardLayout(HKL hkl, UINT flags) { - HKL oldHkl = 0; + BOOL ret = FALSE; struct macdrv_thread_data *thread_data = macdrv_init_thread_data(); struct layout *layout;
TRACE("hkl %p flags %04x\n", hkl, flags);
if (hkl == thread_data->active_keyboard_layout) - return hkl; + return TRUE;
EnterCriticalSection(&layout_list_section); update_layout_list(); @@ -1183,7 +1183,7 @@ HKL CDECL macdrv_ActivateKeyboardLayout(HKL hkl, UINT flags) { if (macdrv_select_input_source(layout->input_source)) { - oldHkl = thread_data->active_keyboard_layout; + ret = TRUE; if (thread_data->keyboard_layout_uchr) CFRelease(thread_data->keyboard_layout_uchr);
@@ -1199,7 +1199,7 @@ HKL CDECL macdrv_ActivateKeyboardLayout(HKL hkl, UINT flags) } LeaveCriticalSection(&layout_list_section);
- return oldHkl; + return ret; }
diff --git a/dlls/winex11.drv/keyboard.c b/dlls/winex11.drv/keyboard.c index d583c8588cd..228dba0f8b2 100644 --- a/dlls/winex11.drv/keyboard.c +++ b/dlls/winex11.drv/keyboard.c @@ -1930,9 +1930,8 @@ BOOL CDECL X11DRV_UnloadKeyboardLayout(HKL hkl) /*********************************************************************** * ActivateKeyboardLayout (X11DRV.@) */ -HKL CDECL X11DRV_ActivateKeyboardLayout(HKL hkl, UINT flags) +BOOL CDECL X11DRV_ActivateKeyboardLayout(HKL hkl, UINT flags) { - HKL oldHkl = 0; struct x11drv_thread_data *thread_data = x11drv_init_thread_data();
FIXME("%p, %04x: semi-stub!\n", hkl, flags); @@ -1940,22 +1939,18 @@ HKL CDECL X11DRV_ActivateKeyboardLayout(HKL hkl, UINT flags) { SetLastError(ERROR_CALL_NOT_IMPLEMENTED); FIXME("KLF_SETFORPROCESS not supported\n"); - return 0; + return FALSE; }
if (!match_x11_keyboard_layout(hkl)) { SetLastError(ERROR_CALL_NOT_IMPLEMENTED); FIXME("setting keyboard of different locales not supported\n"); - return 0; + return FALSE; }
- oldHkl = thread_data->kbd_layout; - if (!oldHkl) oldHkl = get_locale_kbd_layout(); - thread_data->kbd_layout = hkl; - - return oldHkl; + return TRUE; }
Signed-off-by: Rémi Bernon rbernon@codeweavers.com --- dlls/user32/driver.c | 13 ------------- dlls/user32/input.c | 9 ++++++--- dlls/user32/user_private.h | 1 - dlls/winemac.drv/keyboard.c | 16 +--------------- dlls/winemac.drv/winemac.drv.spec | 1 - dlls/winex11.drv/keyboard.c | 27 ++++----------------------- dlls/winex11.drv/winex11.drv.spec | 1 - dlls/winex11.drv/x11drv.h | 1 - 8 files changed, 11 insertions(+), 58 deletions(-)
diff --git a/dlls/user32/driver.c b/dlls/user32/driver.c index daba4bb7c01..c213f6ecb10 100644 --- a/dlls/user32/driver.c +++ b/dlls/user32/driver.c @@ -108,7 +108,6 @@ static const USER_DRIVER *load_driver(void) GET_USER_FUNC(ActivateKeyboardLayout); GET_USER_FUNC(Beep); GET_USER_FUNC(GetKeyNameText); - GET_USER_FUNC(GetKeyboardLayout); GET_USER_FUNC(GetKeyboardLayoutList); GET_USER_FUNC(GetKeyboardLayoutName); GET_USER_FUNC(LoadKeyboardLayout); @@ -206,11 +205,6 @@ static INT CDECL nulldrv_GetKeyNameText( LONG lparam, LPWSTR buffer, INT size ) return -1; /* use default implementation */ }
-static HKL CDECL nulldrv_GetKeyboardLayout( DWORD thread_id ) -{ - return (HKL)~0; /* use default implementation */ -} - static BOOL CDECL nulldrv_GetKeyboardLayoutName( LPWSTR name ) { return FALSE; @@ -427,7 +421,6 @@ static USER_DRIVER null_driver = nulldrv_ActivateKeyboardLayout, nulldrv_Beep, nulldrv_GetKeyNameText, - nulldrv_GetKeyboardLayout, nulldrv_GetKeyboardLayoutList, nulldrv_GetKeyboardLayoutName, nulldrv_LoadKeyboardLayout, @@ -502,11 +495,6 @@ static INT CDECL loaderdrv_GetKeyNameText( LONG lparam, LPWSTR buffer, INT size return load_driver()->pGetKeyNameText( lparam, buffer, size ); }
-static HKL CDECL loaderdrv_GetKeyboardLayout( DWORD thread_id ) -{ - return load_driver()->pGetKeyboardLayout( thread_id ); -} - static UINT CDECL loaderdrv_GetKeyboardLayoutList( INT size, HKL *layouts ) { return load_driver()->pGetKeyboardLayoutList( size, layouts ); @@ -642,7 +630,6 @@ static USER_DRIVER lazy_load_driver = loaderdrv_ActivateKeyboardLayout, loaderdrv_Beep, loaderdrv_GetKeyNameText, - loaderdrv_GetKeyboardLayout, loaderdrv_GetKeyboardLayoutList, loaderdrv_GetKeyboardLayoutName, loaderdrv_LoadKeyboardLayout, diff --git a/dlls/user32/input.c b/dlls/user32/input.c index 8436347b0b0..bebdc3e012b 100644 --- a/dlls/user32/input.c +++ b/dlls/user32/input.c @@ -1083,11 +1083,14 @@ UINT WINAPI GetKBCodePage(void) */ HKL WINAPI GetKeyboardLayout(DWORD thread_id) { - HKL layout; + struct user_thread_info *thread = get_user_thread_info(); + HKL layout = thread->kbd_layout;
- if ((layout = USER_Driver->pGetKeyboardLayout( thread_id )) != (HKL)~0) return layout; + if (thread_id && thread_id != GetCurrentThreadId()) + FIXME( "couldn't return keyboard layout for thread %04x\n", thread_id );
- return get_locale_kbd_layout(); + if (!layout) return get_locale_kbd_layout(); + return layout; }
/**************************************************************************** diff --git a/dlls/user32/user_private.h b/dlls/user32/user_private.h index e568054165a..48aea824351 100644 --- a/dlls/user32/user_private.h +++ b/dlls/user32/user_private.h @@ -65,7 +65,6 @@ typedef struct tagUSER_DRIVER { BOOL (CDECL *pActivateKeyboardLayout)(HKL, UINT); void (CDECL *pBeep)(void); INT (CDECL *pGetKeyNameText)(LONG, LPWSTR, INT); - HKL (CDECL *pGetKeyboardLayout)(DWORD); UINT (CDECL *pGetKeyboardLayoutList)(INT, HKL *); BOOL (CDECL *pGetKeyboardLayoutName)(LPWSTR); HKL (CDECL *pLoadKeyboardLayout)(LPCWSTR, UINT); diff --git a/dlls/winemac.drv/keyboard.c b/dlls/winemac.drv/keyboard.c index 300bc84d664..bdf01e115a0 100644 --- a/dlls/winemac.drv/keyboard.c +++ b/dlls/winemac.drv/keyboard.c @@ -395,8 +395,6 @@ static const struct { { VK_VOLUME_UP | 0x100, "Volume Up" }, };
-HKL CDECL macdrv_GetKeyboardLayout(DWORD); - static BOOL char_matches_string(WCHAR wchar, UniChar *string, BOOL ignore_diacritics) { BOOL ret; @@ -1298,18 +1296,6 @@ INT CDECL macdrv_GetKeyNameText(LONG lparam, LPWSTR buffer, INT size) }
-/*********************************************************************** - * GetKeyboardLayout (MACDRV.@) - */ -HKL CDECL macdrv_GetKeyboardLayout(DWORD thread_id) -{ - if (thread_id && thread_id != GetCurrentThreadId()) - FIXME("couldn't return keyboard layout for thread %04x\n", thread_id); - - return macdrv_init_thread_data()->active_keyboard_layout; -} - - /*********************************************************************** * GetKeyboardLayoutList (MACDRV.@) */ @@ -1349,7 +1335,7 @@ BOOL CDECL macdrv_GetKeyboardLayoutName(LPWSTR name) static const WCHAR formatW[] = {'%','0','8','x',0}; DWORD layout;
- layout = HandleToUlong(macdrv_GetKeyboardLayout(0)); + layout = HandleToUlong(GetKeyboardLayout(0)); if (HIWORD(layout) == LOWORD(layout)) layout = LOWORD(layout); sprintfW(name, formatW, layout); TRACE("returning %s\n", debugstr_w(name)); diff --git a/dlls/winemac.drv/winemac.drv.spec b/dlls/winemac.drv/winemac.drv.spec index 39cf33370b4..18efd03319c 100644 --- a/dlls/winemac.drv/winemac.drv.spec +++ b/dlls/winemac.drv/winemac.drv.spec @@ -14,7 +14,6 @@ @ cdecl DestroyWindow(long) macdrv_DestroyWindow @ cdecl EnumDisplaySettingsEx(ptr long ptr long) macdrv_EnumDisplaySettingsEx @ cdecl GetCursorPos(ptr) macdrv_GetCursorPos -@ cdecl GetKeyboardLayout(long) macdrv_GetKeyboardLayout @ cdecl GetKeyboardLayoutList(long ptr) macdrv_GetKeyboardLayoutList @ cdecl GetKeyboardLayoutName(ptr) macdrv_GetKeyboardLayoutName @ cdecl GetKeyNameText(long ptr long) macdrv_GetKeyNameText diff --git a/dlls/winex11.drv/keyboard.c b/dlls/winex11.drv/keyboard.c index 228dba0f8b2..ce10f6ee1a3 100644 --- a/dlls/winex11.drv/keyboard.c +++ b/dlls/winex11.drv/keyboard.c @@ -1889,23 +1889,6 @@ static BOOL match_x11_keyboard_layout(HKL hkl) }
-/*********************************************************************** - * GetKeyboardLayout (X11DRV.@) - */ -HKL CDECL X11DRV_GetKeyboardLayout(DWORD dwThreadid) -{ - if (!dwThreadid || dwThreadid == GetCurrentThreadId()) - { - struct x11drv_thread_data *thread_data = x11drv_thread_data(); - if (thread_data && thread_data->kbd_layout) return thread_data->kbd_layout; - } - else - FIXME("couldn't return keyboard layout for thread %04x\n", dwThreadid); - - return get_locale_kbd_layout(); -} - - /*********************************************************************** * LoadKeyboardLayout (X11DRV.@) */ @@ -1932,9 +1915,8 @@ BOOL CDECL X11DRV_UnloadKeyboardLayout(HKL hkl) */ BOOL CDECL X11DRV_ActivateKeyboardLayout(HKL hkl, UINT flags) { - struct x11drv_thread_data *thread_data = x11drv_init_thread_data(); - FIXME("%p, %04x: semi-stub!\n", hkl, flags); + if (flags & KLF_SETFORPROCESS) { SetLastError(ERROR_CALL_NOT_IMPLEMENTED); @@ -1949,7 +1931,6 @@ BOOL CDECL X11DRV_ActivateKeyboardLayout(HKL hkl, UINT flags) return FALSE; }
- thread_data->kbd_layout = hkl; return TRUE; }
@@ -1967,7 +1948,7 @@ BOOL X11DRV_MappingNotify( HWND dummy, XEvent *event ) hwnd = GetFocus(); if (!hwnd) hwnd = GetActiveWindow(); PostMessageW(hwnd, WM_INPUTLANGCHANGEREQUEST, - 0 /*FIXME*/, (LPARAM)X11DRV_GetKeyboardLayout(0)); + 0 /*FIXME*/, (LPARAM)GetKeyboardLayout(0)); return TRUE; }
@@ -2215,7 +2196,7 @@ INT CDECL X11DRV_GetKeyNameText(LONG lParam, LPWSTR lpBuffer, INT nSize) scanCode = lParam >> 16; scanCode &= 0x1ff; /* keep "extended-key" flag with code */
- vkey = X11DRV_MapVirtualKeyEx(scanCode, MAPVK_VSC_TO_VK_EX, X11DRV_GetKeyboardLayout(0)); + vkey = X11DRV_MapVirtualKeyEx(scanCode, MAPVK_VSC_TO_VK_EX, GetKeyboardLayout(0));
/* handle "don't care" bit (0x02000000) */ if (!(lParam & 0x02000000)) { @@ -2238,7 +2219,7 @@ INT CDECL X11DRV_GetKeyNameText(LONG lParam, LPWSTR lpBuffer, INT nSize) } }
- ansi = X11DRV_MapVirtualKeyEx(vkey, MAPVK_VK_TO_CHAR, X11DRV_GetKeyboardLayout(0)); + ansi = X11DRV_MapVirtualKeyEx(vkey, MAPVK_VK_TO_CHAR, GetKeyboardLayout(0)); TRACE("scan 0x%04x, vkey 0x%04X, ANSI 0x%04x\n", scanCode, vkey, ansi);
/* first get the name of the "regular" keys which is the Upper case diff --git a/dlls/winex11.drv/winex11.drv.spec b/dlls/winex11.drv/winex11.drv.spec index c0e24d8fe82..809105f3b4f 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 GetKeyboardLayout(long) X11DRV_GetKeyboardLayout @ cdecl GetKeyboardLayoutName(ptr) X11DRV_GetKeyboardLayoutName @ cdecl LoadKeyboardLayout(wstr long) X11DRV_LoadKeyboardLayout @ cdecl MapVirtualKeyEx(long long long) X11DRV_MapVirtualKeyEx diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h index 2362dfd9563..c23cd512eb9 100644 --- a/dlls/winex11.drv/x11drv.h +++ b/dlls/winex11.drv/x11drv.h @@ -337,7 +337,6 @@ struct x11drv_thread_data Window clip_window; /* window used for cursor clipping */ HWND clip_hwnd; /* message window stored in desktop while clipping is active */ DWORD clip_reset; /* time when clipping was last reset */ - HKL kbd_layout; /* active keyboard layout */ enum { xi_unavailable = -1, xi_unknown, xi_disabled, xi_enabled } xi2_state; /* XInput2 state */ void *xi2_devices; /* list of XInput2 devices (valid when state is enabled) */ int xi2_device_count;