Skip to content

Commit 45cf112

Browse files
committed
fix(server): postpone tray icon updating when focusing on explorer
1 parent 9e2f9f1 commit 45cf112

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

RimeWithWeasel/RimeWithWeasel.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <StringAlgorithm.hpp>
55
#include <WeaselUtility.h>
66
#include <WeaselVersion.h>
7+
#include <VersionHelpers.hpp>
78

89
#include <rime_api.h>
910

@@ -17,6 +18,7 @@ RimeWithWeaselHandler::RimeWithWeaselHandler(weasel::UI *ui)
1718
, m_active_session(0)
1819
, m_disabled(true)
1920
, _UpdateUICallback(NULL)
21+
, m_vista_greater(IsWindowsVistaOrGreater())
2022
{
2123
_Setup();
2224
}
@@ -347,7 +349,18 @@ void RimeWithWeaselHandler::_UpdateUI(UINT session_id)
347349
m_ui->Update(weasel_context, weasel_status);
348350
}
349351

350-
if (_UpdateUICallback) _UpdateUICallback();
352+
// Dangerous, don't touch
353+
static char app_name[50];
354+
RimeGetProperty(session_id, "client_app", app_name, sizeof(app_name) - 1);
355+
if (utf8towcs(app_name) == std::wstring(L"explorer.exe") && m_vista_greater) {
356+
boost::thread th([=]() {
357+
::Sleep(100);
358+
if (_UpdateUICallback) _UpdateUICallback();
359+
});
360+
}
361+
else {
362+
if (_UpdateUICallback) _UpdateUICallback();
363+
}
351364

352365
m_message_type.clear();
353366
m_message_value.clear();

RimeWithWeasel/stdafx.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <boost/interprocess/streams/bufferstream.hpp>
1616
#include <boost/archive/text_woarchive.hpp>
1717
#include <boost/archive/text_oarchive.hpp>
18+
#include <boost/thread.hpp>
1819

1920
#pragma warning(default : 4819)
2021
#include <algorithm>

include/RimeWithWeasel.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class RimeWithWeaselHandler :
4949
weasel::UI* m_ui; // reference
5050
UINT m_active_session;
5151
bool m_disabled;
52+
bool m_vista_greater;
5253
std::string m_last_schema_id;
5354
weasel::UIStyle m_base_style;
5455

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy