From ffe90560cd719a095ccd73dafa09ee370ced51c9 Mon Sep 17 00:00:00 2001 From: fanlusky <1730976608@qq.com> Date: Sat, 22 Aug 2026 19:40:33 +0800 Subject: [PATCH] Fix the issue where the language bar and FTB are out of sync for the Chinese-Japanese status. --- src/IME/MetasequoiaIME.cpp | 4 ++++ src/LanguageBar/LanguageBar.cpp | 14 +++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/IME/MetasequoiaIME.cpp b/src/IME/MetasequoiaIME.cpp index c92121a1..f442d36d 100644 --- a/src/IME/MetasequoiaIME.cpp +++ b/src/IME/MetasequoiaIME.cpp @@ -2399,6 +2399,10 @@ LRESULT CALLBACK CMetasequoiaIME_WindowProc(HWND hWnd, UINT message, WPARAM wPar break; } case WM_ThreadFocus: { + // Some Chromium/Electron window switches surface only as thread-focus + // changes. Refresh this thread's cached TSF language-bar item even when + // there was no document-focus transition. + pIME->_RefreshLanguageBarThemeIcons(); SendCurrentImeStatusSnapshot(pIME); break; } diff --git a/src/LanguageBar/LanguageBar.cpp b/src/LanguageBar/LanguageBar.cpp index 559ae070..3709b04f 100644 --- a/src/LanguageBar/LanguageBar.cpp +++ b/src/LanguageBar/LanguageBar.cpp @@ -109,7 +109,19 @@ void CMetasequoiaIME::_UpdateLanguageBarOnSetFocus(_In_ ITfDocumentMgr *pDocMgrF CCompositionProcessorEngine *pCompositionProcessorEngine = nullptr; pCompositionProcessorEngine = _pCompositionProcessorEngine; - pCompositionProcessorEngine->SetLanguageBarStatus(TF_LBI_STATUS_DISABLED, needDisableButtons); + pCompositionProcessorEngine->SetLanguageBarStatus(TF_LBI_STATUS_DISABLED, needDisableButtons); + + // SetStatus intentionally keeps the item enabled when focus is absent so + // Firefox does not replace our mode glyph with its disabled/close glyph. + // Consequently, returning to a document may not change the status bits and + // therefore may not generate an ITfLangBarItemSink update. Always refresh + // the newly focused thread's item: Windows caches each host/thread's icon, + // and another host may have changed the shared Chinese/Japanese mode while + // this one was in the background. + if (!needDisableButtons) + { + pCompositionProcessorEngine->RefreshLanguageBarIcons(); + } } //+---------------------------------------------------------------------------