mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-08-26 19:33:31 +00:00
[KBSWITCH] Fix System Pen icon visibility (#8230)
Management of System Pen icon was inconsistent. JIRA issue: CORE-10667 - Add g_bSysPenNotifyAdded global variable. - Add checking the result of Shell_NotifyIcon. - Fix UpdateLanguageDisplayCurrent function. - Add WM_INPUTLANGCHANGEREQUEST message handling. Testbot runs (
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
#include <imm.h>
|
||||
#include <immdev.h>
|
||||
#include <imm32_undoc.h>
|
||||
#include <assert.h>
|
||||
#include "imemenu.h"
|
||||
|
||||
#include <wine/debug.h>
|
||||
@@ -62,6 +63,7 @@ HKL g_ahKLs[MAX_KLS] = { NULL };
|
||||
WORD g_aiSysPenIcons[MAX_KLS] = { 0 };
|
||||
WORD g_anToolTipAtoms[MAX_KLS] = { 0 };
|
||||
HICON g_ahSysPenIcons[MAX_KLS] = { NULL };
|
||||
BOOL g_bSysPenNotifyAdded = FALSE;
|
||||
BYTE g_anFlags[MAX_KLS] = { 0 };
|
||||
UINT g_uTaskbarRestartMsg = 0;
|
||||
UINT g_uShellHookMessage = 0;
|
||||
@@ -539,21 +541,25 @@ LoadDefaultPenIcon(PCWSTR szImeFile, HKL hKL)
|
||||
static VOID
|
||||
DeletePenNotifyIcon(HWND hwnd)
|
||||
{
|
||||
if (!g_bSysPenNotifyAdded)
|
||||
return;
|
||||
|
||||
NOTIFYICONDATA nid = { sizeof(nid), hwnd, NOTIFY_ICON_ID_SYSTEM_PEN };
|
||||
Shell_NotifyIcon(NIM_DELETE, &nid);
|
||||
if (!Shell_NotifyIcon(NIM_DELETE, &nid))
|
||||
ERR("Shell_NotifyIcon(NIM_DELETE) failed\n");
|
||||
else
|
||||
g_bSysPenNotifyAdded = FALSE;
|
||||
}
|
||||
|
||||
static VOID
|
||||
UpdatePenIcon(HWND hwnd, UINT iKL)
|
||||
{
|
||||
BOOL bHadIcon = (g_ahSysPenIcons[iKL] != NULL);
|
||||
DeletePenIcon(hwnd, iKL);
|
||||
|
||||
// Not Far-East?
|
||||
if (!(g_anFlags[iKL] & LAYOUTF_FAR_EAST))
|
||||
{
|
||||
if (bHadIcon)
|
||||
DeletePenNotifyIcon(hwnd);
|
||||
DeletePenNotifyIcon(hwnd);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -562,20 +568,19 @@ UpdatePenIcon(HWND hwnd, UINT iKL)
|
||||
GetKLIDFromHKL(g_ahKLs[iKL], szKLID, _countof(szKLID));
|
||||
if (!GetImeFile(szImeFile, _countof(szImeFile), szKLID))
|
||||
{
|
||||
if (bHadIcon)
|
||||
DeletePenNotifyIcon(hwnd);
|
||||
DeletePenNotifyIcon(hwnd);
|
||||
return;
|
||||
}
|
||||
|
||||
// Load pen icon
|
||||
assert(!g_ahSysPenIcons[iKL]);
|
||||
if (g_anFlags[iKL] & LAYOUTF_IME_ICON)
|
||||
g_ahSysPenIcons[iKL] = FakeExtractIcon(szImeFile, g_aiSysPenIcons[iKL]);
|
||||
if (!g_ahSysPenIcons[iKL])
|
||||
g_ahSysPenIcons[iKL] = LoadDefaultPenIcon(szImeFile, g_ahKLs[iKL]);
|
||||
if (!g_ahSysPenIcons[iKL])
|
||||
{
|
||||
if (bHadIcon)
|
||||
DeletePenNotifyIcon(hwnd);
|
||||
DeletePenNotifyIcon(hwnd);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -590,7 +595,10 @@ UpdatePenIcon(HWND hwnd, UINT iKL)
|
||||
else
|
||||
ImmGetDescription(g_ahKLs[iKL], nid.szTip, _countof(nid.szTip));
|
||||
|
||||
Shell_NotifyIcon((bHadIcon ? NIM_MODIFY : NIM_ADD), &nid);
|
||||
if (!Shell_NotifyIcon((g_bSysPenNotifyAdded ? NIM_MODIFY : NIM_ADD), &nid))
|
||||
ERR("Shell_NotifyIcon failed\n");
|
||||
else
|
||||
g_bSysPenNotifyAdded = TRUE;
|
||||
}
|
||||
|
||||
static HICON
|
||||
@@ -707,7 +715,8 @@ AddTrayIcon(HWND hwnd)
|
||||
tnid.hIcon = CreateTrayIcon(szKLID, szImeFile);
|
||||
StringCchCopy(tnid.szTip, _countof(tnid.szTip), szName);
|
||||
|
||||
Shell_NotifyIcon(NIM_ADD, &tnid);
|
||||
if (!Shell_NotifyIcon(NIM_ADD, &tnid))
|
||||
ERR("Shell_NotifyIcon(NIM_ADD) failed\n");
|
||||
|
||||
if (g_hTrayIcon)
|
||||
DestroyIcon(g_hTrayIcon);
|
||||
@@ -718,7 +727,8 @@ static VOID
|
||||
DeleteTrayIcon(HWND hwnd)
|
||||
{
|
||||
NOTIFYICONDATA tnid = { sizeof(tnid), hwnd, NOTIFY_ICON_ID_LANGUAGE };
|
||||
Shell_NotifyIcon(NIM_DELETE, &tnid);
|
||||
if (!Shell_NotifyIcon(NIM_DELETE, &tnid))
|
||||
ERR("Shell_NotifyIcon(NIM_DELETE) failed\n");
|
||||
|
||||
if (g_hTrayIcon)
|
||||
{
|
||||
@@ -906,10 +916,11 @@ UpdateLanguageDisplay(HWND hwnd, HKL hKL)
|
||||
UINT
|
||||
UpdateLanguageDisplayCurrent(HWND hwnd, HWND hwndFore)
|
||||
{
|
||||
UpdateLayoutList(NULL);
|
||||
DWORD dwThreadID = GetWindowThreadProcessId(GetTargetWindow(hwndFore), NULL);
|
||||
HKL hKL = GetKeyboardLayout(dwThreadID);
|
||||
UpdateLanguageDisplay(hwnd, hKL);
|
||||
|
||||
UpdatePenIcon(hwnd, g_iKL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -960,6 +971,7 @@ KbSwitch_OnDestroy(HWND hwnd)
|
||||
DeleteHooks();
|
||||
DeleteTrayIcon(hwnd);
|
||||
DestroyPenIcons();
|
||||
DeletePenNotifyIcon(hwnd);
|
||||
PostQuitMessage(0);
|
||||
}
|
||||
|
||||
@@ -1432,6 +1444,8 @@ WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
break;
|
||||
|
||||
case WM_INPUTLANGCHANGEREQUEST:
|
||||
TRACE("WM_INPUTLANGCHANGEREQUEST(%p, %p)\n", wParam, lParam);
|
||||
SetTimer(hwnd, TIMER_ID_LANG_CHANGED_DELAYED, TIMER_LANG_CHANGED_DELAY, NULL);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user