Skip to content

Commit

Permalink
fix(server): postpone tray icon updating when focusing on explorer
Browse files Browse the repository at this point in the history
  • Loading branch information
nameoverflow committed Apr 3, 2018
1 parent 9e2f9f1 commit 45cf112
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
15 changes: 14 additions & 1 deletion RimeWithWeasel/RimeWithWeasel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <StringAlgorithm.hpp>
#include <WeaselUtility.h>
#include <WeaselVersion.h>
#include <VersionHelpers.hpp>

#include <rime_api.h>

Expand All @@ -17,6 +18,7 @@ RimeWithWeaselHandler::RimeWithWeaselHandler(weasel::UI *ui)
, m_active_session(0)
, m_disabled(true)
, _UpdateUICallback(NULL)
, m_vista_greater(IsWindowsVistaOrGreater())
{
_Setup();
}
Expand Down Expand Up @@ -347,7 +349,18 @@ void RimeWithWeaselHandler::_UpdateUI(UINT session_id)
m_ui->Update(weasel_context, weasel_status);
}

if (_UpdateUICallback) _UpdateUICallback();
// Dangerous, don't touch
static char app_name[50];
RimeGetProperty(session_id, "client_app", app_name, sizeof(app_name) - 1);
if (utf8towcs(app_name) == std::wstring(L"explorer.exe") && m_vista_greater) {
boost::thread th([=]() {
::Sleep(100);
if (_UpdateUICallback) _UpdateUICallback();
});
}
else {
if (_UpdateUICallback) _UpdateUICallback();
}

m_message_type.clear();
m_message_value.clear();
Expand Down
1 change: 1 addition & 0 deletions RimeWithWeasel/stdafx.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <boost/interprocess/streams/bufferstream.hpp>
#include <boost/archive/text_woarchive.hpp>
#include <boost/archive/text_oarchive.hpp>
#include <boost/thread.hpp>

#pragma warning(default : 4819)
#include <algorithm>
Expand Down
1 change: 1 addition & 0 deletions include/RimeWithWeasel.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class RimeWithWeaselHandler :
weasel::UI* m_ui; // reference
UINT m_active_session;
bool m_disabled;
bool m_vista_greater;
std::string m_last_schema_id;
weasel::UIStyle m_base_style;

Expand Down

0 comments on commit 45cf112

Please sign in to comment.