mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 10:35:28 +00:00
36f7d1a953
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.
114 lines
2.2 KiB
C
114 lines
2.2 KiB
C
/*
|
|
* PROJECT: ReactOS Keyboard Layout Switcher
|
|
* FILE: base/applications/kbswitch/kbsdll/kbsdll.c
|
|
* PROGRAMMER: Dmitry Chapyshev <dmitry@reactos.org>
|
|
*
|
|
*/
|
|
|
|
#include "../kbswitch.h"
|
|
|
|
HHOOK hWinHook = NULL;
|
|
HHOOK hShellHook = NULL;
|
|
HINSTANCE hInstance = NULL;
|
|
HWND hKbSwitchWnd = NULL;
|
|
|
|
static VOID
|
|
PostMessageToMainWnd(UINT Msg, WPARAM wParam, LPARAM lParam)
|
|
{
|
|
PostMessage(hKbSwitchWnd, Msg, wParam, lParam);
|
|
}
|
|
|
|
LRESULT CALLBACK
|
|
WinHookProc(int code, WPARAM wParam, LPARAM lParam)
|
|
{
|
|
if (code < 0)
|
|
{
|
|
return CallNextHookEx(hWinHook, code, wParam, lParam);
|
|
}
|
|
|
|
switch (code)
|
|
{
|
|
case HCBT_SETFOCUS:
|
|
{
|
|
HWND hwndFocus = (HWND)wParam;
|
|
if (hwndFocus && hwndFocus != hKbSwitchWnd)
|
|
{
|
|
PostMessageToMainWnd(WM_WINDOW_ACTIVATE, wParam, lParam);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
|
|
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:
|
|
{
|
|
PostMessageToMainWnd(WM_LANG_CHANGED, wParam, lParam);
|
|
}
|
|
break;
|
|
}
|
|
|
|
return CallNextHookEx(hShellHook, code, wParam, lParam);
|
|
}
|
|
|
|
BOOL WINAPI
|
|
KbSwitchSetHooks(VOID)
|
|
{
|
|
hWinHook = SetWindowsHookEx(WH_CBT, WinHookProc, hInstance, 0);
|
|
hShellHook = SetWindowsHookEx(WH_SHELL, ShellHookProc, hInstance, 0);
|
|
|
|
if (!hWinHook || !hShellHook)
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
VOID WINAPI
|
|
KbSwitchDeleteHooks(VOID)
|
|
{
|
|
if (hWinHook)
|
|
{
|
|
UnhookWindowsHookEx(hWinHook);
|
|
hWinHook = NULL;
|
|
}
|
|
if (hShellHook)
|
|
{
|
|
UnhookWindowsHookEx(hShellHook);
|
|
hShellHook = NULL;
|
|
}
|
|
}
|
|
|
|
BOOL WINAPI
|
|
DllMain(IN HINSTANCE hinstDLL,
|
|
IN DWORD dwReason,
|
|
IN LPVOID lpvReserved)
|
|
{
|
|
switch (dwReason)
|
|
{
|
|
case DLL_PROCESS_ATTACH:
|
|
{
|
|
hInstance = hinstDLL;
|
|
hKbSwitchWnd = FindWindow(szKbSwitcherName, NULL);
|
|
if (!hKbSwitchWnd)
|
|
{
|
|
return FALSE;
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
|
|
return TRUE;
|
|
}
|