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@reactos.org) * Colin Finck (mail@colinfinck.de) + * Katayama Hirofumi MZ (katayama.hirofumi.mz@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_HOTKEY: + { + if (wParam != dwAltShiftHotKeyId && wParam != dwShiftAltHotKeyId) + break; + + /* FALL THROUGH */ + } + case WM_LOAD_LAYOUT: { - ActivateLayout(hwnd, GetNextLayout()); - + 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