From 2469ce2c317ba8c8ab0f49feeb3fecad15cca19e Mon Sep 17 00:00:00 2001 From: Katayama Hirofumi MZ Date: Mon, 26 Sep 2022 08:07:50 +0900 Subject: [PATCH] [NTUSER][KBSWITCH] Realize Alt+Shift keyboard switch (retry) (#4721) Alt+Shift is a useful key combination to switch the current keyboard layout. CORE-11737 - Add ID_NEXTLAYOUT command to kbswitch. - Send command ID_NEXTLAYOUT to kbswitch on Alt+Shift key combination in WM_SYSKEYDOWN handling of IntDefWindowProc function. - Make IntFindWindow a non-static function. --- base/applications/kbswitch/kbswitch.c | 6 ++++++ base/applications/kbswitch/resource.h | 1 + win32ss/user/ntuser/defwnd.c | 18 ++++++++++++++++++ win32ss/user/ntuser/window.c | 2 +- win32ss/user/ntuser/window.h | 2 ++ 5 files changed, 28 insertions(+), 1 deletion(-) diff --git a/base/applications/kbswitch/kbswitch.c b/base/applications/kbswitch/kbswitch.c index d1b39320561..187661e7d1b 100644 --- a/base/applications/kbswitch/kbswitch.c +++ b/base/applications/kbswitch/kbswitch.c @@ -546,6 +546,12 @@ WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) break; } + case ID_NEXTLAYOUT: + { + ActivateLayout(hwnd, GetNextLayout()); + break; + } + default: { ActivateLayout(hwnd, LOWORD(wParam)); diff --git a/base/applications/kbswitch/resource.h b/base/applications/kbswitch/resource.h index b7410bd20e0..ef71d848be4 100644 --- a/base/applications/kbswitch/resource.h +++ b/base/applications/kbswitch/resource.h @@ -9,3 +9,4 @@ /* Menu items */ #define ID_EXIT 10001 #define ID_PREFERENCES 10002 +#define ID_NEXTLAYOUT 10003 diff --git a/win32ss/user/ntuser/defwnd.c b/win32ss/user/ntuser/defwnd.c index 846a131cfb3..9d2021a70eb 100644 --- a/win32ss/user/ntuser/defwnd.c +++ b/win32ss/user/ntuser/defwnd.c @@ -945,6 +945,24 @@ IntDefWindowProc( wParamTmp = UserGetKeyState(VK_SHIFT) & 0x8000 ? SC_PREVWINDOW : SC_NEXTWINDOW; co_IntSendMessage( Active, WM_SYSCOMMAND, wParamTmp, wParam ); } + else if (wParam == VK_SHIFT) // Alt+Shift + { + RTL_ATOM ClassAtom = 0; + UNICODE_STRING ustrClass, ustrWindow; + HWND hwndSwitch; + + RtlInitUnicodeString(&ustrClass, L"kbswitcher"); + RtlInitUnicodeString(&ustrWindow, L""); + + IntGetAtomFromStringOrAtom(&ustrClass, &ClassAtom); + + hwndSwitch = IntFindWindow(UserGetDesktopWindow(), NULL, ClassAtom, &ustrWindow); + if (hwndSwitch) + { +#define ID_NEXTLAYOUT 10003 + UserPostMessage(hwndSwitch, WM_COMMAND, ID_NEXTLAYOUT, 0); + } + } } else if( wParam == VK_F10 ) { diff --git a/win32ss/user/ntuser/window.c b/win32ss/user/ntuser/window.c index a2b9e24b6d8..c880ddcc173 100644 --- a/win32ss/user/ntuser/window.c +++ b/win32ss/user/ntuser/window.c @@ -3040,7 +3040,7 @@ CLEANUP: } -static HWND FASTCALL +HWND FASTCALL IntFindWindow(PWND Parent, PWND ChildAfter, RTL_ATOM ClassAtom, diff --git a/win32ss/user/ntuser/window.h b/win32ss/user/ntuser/window.h index b68c1657c5d..0efbd4987a3 100644 --- a/win32ss/user/ntuser/window.h +++ b/win32ss/user/ntuser/window.h @@ -98,6 +98,8 @@ extern PWINDOWLIST gpwlCache; PWINDOWLIST FASTCALL IntBuildHwndList(PWND pwnd, DWORD dwFlags, PTHREADINFO pti); VOID FASTCALL IntFreeHwndList(PWINDOWLIST pwlTarget); +HWND FASTCALL IntFindWindow(PWND Parent, PWND ChildAfter, RTL_ATOM ClassAtom, + PUNICODE_STRING WindowName); /* Undocumented dwFlags for IntBuildHwndList */ #define IACE_LIST 0x0002