[KBSWITCH] Update tray icon on color scheme change

CORE-14240 #resolve
This commit is contained in:
Stanislav Motylkov 2018-01-22 17:49:33 +03:00 committed by Giannis Adamopoulos
parent 9d29ee3a62
commit 20a782b7b1

View file

@ -396,11 +396,28 @@ GetNextLayout(VOID)
return -1; return -1;
} }
LRESULT
UpdateLanguageDisplay(HWND hwnd, HKL hKl)
{
static TCHAR szLCID[MAX_PATH], szLangName[MAX_PATH];
GetLayoutIDByHkl(hKl, szLCID, ARRAYSIZE(szLCID));
GetLocaleInfo((LANGID)_tcstoul(szLCID, NULL, 16), LOCALE_SLANGUAGE, (LPTSTR)szLangName, ARRAYSIZE(szLangName));
UpdateTrayIcon(hwnd, szLCID, szLangName);
return 0;
}
LRESULT
UpdateLanguageDisplayCurrent(HWND hwnd, WPARAM wParam)
{
return UpdateLanguageDisplay(hwnd, GetKeyboardLayout(GetWindowThreadProcessId((HWND)wParam, 0)));
}
LRESULT CALLBACK LRESULT CALLBACK
WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{ {
static HMENU hRightPopupMenu; static HMENU hRightPopupMenu;
static TCHAR szLCID[MAX_PATH], szLangName[MAX_PATH];
static UINT s_uTaskbarRestart; static UINT s_uTaskbarRestart;
switch (Message) switch (Message)
@ -419,11 +436,7 @@ WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
case WM_LANG_CHANGED: case WM_LANG_CHANGED:
{ {
GetLayoutIDByHkl((HKL)lParam, szLCID, ARRAYSIZE(szLCID)); return UpdateLanguageDisplay(hwnd, (HKL)lParam);
GetLocaleInfo((LANGID)_tcstoul(szLCID, NULL, 16), LOCALE_SLANGUAGE, (LPTSTR)szLangName, ARRAYSIZE(szLangName));
UpdateTrayIcon(hwnd, szLCID, szLangName);
return 0;
} }
case WM_LOAD_LAYOUT: case WM_LOAD_LAYOUT:
@ -435,11 +448,7 @@ WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
case WM_WINDOW_ACTIVATE: case WM_WINDOW_ACTIVATE:
{ {
GetLayoutIDByHkl(GetKeyboardLayout(GetWindowThreadProcessId((HWND)wParam, 0)), szLCID, ARRAYSIZE(szLCID)); return UpdateLanguageDisplayCurrent(hwnd, wParam);
GetLocaleInfo((LANGID)_tcstoul(szLCID, NULL, 16), LOCALE_SLANGUAGE, (LPTSTR)szLangName, ARRAYSIZE(szLangName));
UpdateTrayIcon(hwnd, szLCID, szLangName);
return 0;
} }
case WM_NOTIFYICONMSG: case WM_NOTIFYICONMSG:
@ -508,6 +517,10 @@ WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{ {
//FIXME: Should detect default language changes by CPL applet or by other tools and update UI //FIXME: Should detect default language changes by CPL applet or by other tools and update UI
} }
if (wParam == SPI_SETNONCLIENTMETRICS)
{
return UpdateLanguageDisplayCurrent(hwnd, wParam);
}
} }
break; break;