https://git.reactos.org/?p=reactos.git;a=commitdiff;h=b4f73f040f1c329b4fdc2…
commit b4f73f040f1c329b4fdc2c46efd600c2f538a411
Author: Katayama Hirofumi MZ <katayama.hirofumi.mz(a)gmail.com>
AuthorDate: Wed Aug 24 07:31:46 2022 +0900
Commit: GitHub <noreply(a)github.com>
CommitDate: Wed Aug 24 07:31:46 2022 +0900
[KBSWITCH][NTUSER] Realize Shift+Alt language switch (#4622)
- Fix co_UserProcessHotKeys on modifiers-only hot-keys.
- Add Alt+Shift hot-keys to kbswitch window.
CORE-11737
---
base/applications/kbswitch/kbswitch.c | 37 ++++++++++++++++++++++++++++++++---
win32ss/user/ntuser/hotkey.c | 4 +++-
2 files changed, 37 insertions(+), 4 deletions(-)
diff --git a/base/applications/kbswitch/kbswitch.c
b/base/applications/kbswitch/kbswitch.c
index 61fa5cc4cb8..5057fda8e42 100644
--- a/base/applications/kbswitch/kbswitch.c
+++ b/base/applications/kbswitch/kbswitch.c
@@ -4,6 +4,7 @@
* PURPOSE: Switching Keyboard Layouts
* PROGRAMMERS: Dmitry Chapyshev (dmitry(a)reactos.org)
* Colin Finck (mail(a)colinfinck.de)
+ * Katayama Hirofumi MZ (katayama.hirofumi.mz(a)gmail.com)
*/
#include "kbswitch.h"
@@ -13,7 +14,7 @@
PKBSWITCHSETHOOKS KbSwitchSetHooks = NULL;
PKBSWITCHDELETEHOOKS KbSwitchDeleteHooks = NULL;
UINT ShellHookMessage = 0;
-
+DWORD dwAltShiftHotKeyId = 0, dwShiftAltHotKeyId = 0;
static BOOL
GetLayoutID(LPTSTR szLayoutNum, LPTSTR szLCID, SIZE_T LCIDLength);
@@ -414,6 +415,25 @@ UpdateLanguageDisplayCurrent(HWND hwnd, WPARAM wParam)
return UpdateLanguageDisplay(hwnd,
GetKeyboardLayout(GetWindowThreadProcessId((HWND)wParam, 0)));
}
+VOID DoRegisterAltShiftHotKeys(HWND hwnd)
+{
+ dwAltShiftHotKeyId = GlobalAddAtom(TEXT("ReactOS Alt+Shift"));
+ dwShiftAltHotKeyId = GlobalAddAtom(TEXT("ReactOS Shift+Alt"));
+
+ RegisterHotKey(hwnd, dwAltShiftHotKeyId, MOD_ALT | MOD_SHIFT, VK_SHIFT);
+ RegisterHotKey(hwnd, dwShiftAltHotKeyId, MOD_ALT | MOD_SHIFT, VK_MENU);
+}
+
+VOID DoUnregisterAltShiftHotKeys(HWND hwnd)
+{
+ UnregisterHotKey(hwnd, dwAltShiftHotKeyId);
+ UnregisterHotKey(hwnd, dwShiftAltHotKeyId);
+
+ GlobalDeleteAtom(dwAltShiftHotKeyId);
+ GlobalDeleteAtom(dwShiftAltHotKeyId);
+ dwAltShiftHotKeyId = dwShiftAltHotKeyId = 0;
+}
+
LRESULT CALLBACK
WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
@@ -431,6 +451,7 @@ WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
ActivateLayout(hwnd, ulCurrentLayoutNum);
s_uTaskbarRestart = RegisterWindowMessage(TEXT("TaskbarCreated"));
+ DoRegisterAltShiftHotKeys(hwnd);
return 0;
}
@@ -439,10 +460,19 @@ WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
return UpdateLanguageDisplay(hwnd, (HKL)lParam);
}
- case WM_LOAD_LAYOUT:
+ case WM_HOTKEY:
{
- ActivateLayout(hwnd, GetNextLayout());
+ if (wParam != dwAltShiftHotKeyId && wParam != dwShiftAltHotKeyId)
+ break;
+ /* FALL THROUGH */
+ }
+
+ case WM_LOAD_LAYOUT:
+ {
+ ULONG uNextNum = GetNextLayout();
+ if (ulCurrentLayoutNum != uNextNum)
+ ActivateLayout(hwnd, uNextNum);
return 0;
}
@@ -526,6 +556,7 @@ WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
case WM_DESTROY:
{
+ DoUnregisterAltShiftHotKeys(hwnd);
DeleteHooks();
DestroyMenu(hRightPopupMenu);
DelTrayIcon(hwnd);
diff --git a/win32ss/user/ntuser/hotkey.c b/win32ss/user/ntuser/hotkey.c
index 02b504fe668..e9e11772a11 100644
--- a/win32ss/user/ntuser/hotkey.c
+++ b/win32ss/user/ntuser/hotkey.c
@@ -211,7 +211,9 @@ co_UserProcessHotKeys(WORD wVk, BOOL bIsDown)
if (IsModifier)
{
/* Modifier key up -- modifier-only keys are triggered here */
- pHotKey = IsHotKey(gfsModOnlyCandidate, 0);
+ pHotKey = IsHotKey(gfsModOnlyCandidate, wVk);
+ if (!pHotKey)
+ pHotKey = IsHotKey(gfsModOnlyCandidate, 0);
gfsModOnlyCandidate = 0;
}
else