Skip to content

Commit

Permalink
[KBSWITCH][CPL:INPUT][NTUSER][EXPLORER] Fix keyboard layout icon (#4815)
Browse files Browse the repository at this point in the history
Fix keyboard layout icon in taskbar notification area. JIRA issue: CORE-11700, CORE-2699, CORE-18546
- Call ActivateKeyboardLayout to select the keyboard layout correctly.
- Modify WM_INPUTLANGCHANGEREQUEST parameter.
- Modify BroadcastSystemMessageW parameter.
- Revert Taskbar Notification Area MA_NOACTIVATE HACK 8344291 . This fixes Context Menu display.
- Load the "IME File" value and set the IME icon if necessary.
- Correctly implement global hooks.
  • Loading branch information
katahiromz committed Oct 28, 2022
1 parent a06f10d commit 36f7d1a
Show file tree
Hide file tree
Showing 8 changed files with 317 additions and 70 deletions.
2 changes: 1 addition & 1 deletion base/applications/kbswitch/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
add_rc_deps(kbswitch.rc ${CMAKE_CURRENT_SOURCE_DIR}/res/kbswitch.ico)
add_executable(kbswitch kbswitch.c kbswitch.rc)
set_module_type(kbswitch win32gui UNICODE)
add_importlibs(kbswitch advapi32 user32 shell32 gdi32 msvcrt kernel32)
add_importlibs(kbswitch advapi32 imm32 user32 shell32 gdi32 msvcrt kernel32)
add_cd_file(TARGET kbswitch DESTINATION reactos/system32 FOR all)

add_subdirectory(kbsdll)
36 changes: 24 additions & 12 deletions base/applications/kbswitch/kbsdll/kbsdll.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,44 +13,48 @@ HINSTANCE hInstance = NULL;
HWND hKbSwitchWnd = NULL;

static VOID
SendMessageToMainWnd(UINT Msg, WPARAM wParam, LPARAM lParam)
PostMessageToMainWnd(UINT Msg, WPARAM wParam, LPARAM lParam)
{
PostMessage(hKbSwitchWnd, Msg, wParam, lParam);
}

LRESULT CALLBACK
WinHookProc(int code, WPARAM wParam, LPARAM lParam)
{
int id = GlobalAddAtom(_T("KBSWITCH"));
if (code < 0)
{
return CallNextHookEx(hWinHook, code, wParam, lParam);
}

switch (code)
{
case HCBT_SETFOCUS:
{
if ((HWND)wParam != NULL)
HWND hwndFocus = (HWND)wParam;
if (hwndFocus && hwndFocus != hKbSwitchWnd)
{
if ((HWND)wParam != hKbSwitchWnd)
{
SendMessageToMainWnd(WM_WINDOW_ACTIVATE, wParam, lParam);
}
PostMessageToMainWnd(WM_WINDOW_ACTIVATE, wParam, lParam);
}
}
break;
}

GlobalDeleteAtom(id);

return CallNextHookEx(hWinHook, code, wParam, lParam);
}

LRESULT CALLBACK
ShellHookProc(int code, WPARAM wParam, LPARAM lParam)
{
if (code < 0)
{
return CallNextHookEx(hShellHook, code, wParam, lParam);
}

switch (code)
{
case HSHELL_LANGUAGE:
{
SendMessageToMainWnd(WM_LANG_CHANGED, wParam, lParam);
PostMessageToMainWnd(WM_LANG_CHANGED, wParam, lParam);
}
break;
}
Expand All @@ -75,8 +79,16 @@ KbSwitchSetHooks(VOID)
VOID WINAPI
KbSwitchDeleteHooks(VOID)
{
if (hWinHook) UnhookWindowsHookEx(hWinHook);
if (hShellHook) UnhookWindowsHookEx(hShellHook);
if (hWinHook)
{
UnhookWindowsHookEx(hWinHook);
hWinHook = NULL;
}
if (hShellHook)
{
UnhookWindowsHookEx(hShellHook);
hShellHook = NULL;
}
}

BOOL WINAPI
Expand Down

1 comment on commit 36f7d1a

@JoachimHenze
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This commit introduced regression https://jira.reactos.org/browse/CORE-18563

Please sign in to comment.