Skip to content

Commit

Permalink
chore: remove set option "__synced" (rime#1052)
Browse files Browse the repository at this point in the history
  • Loading branch information
fxliang authored Dec 17, 2023
1 parent b9ce276 commit 066fe94
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
16 changes: 6 additions & 10 deletions RimeWithWeasel/RimeWithWeasel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ UINT RimeWithWeaselHandler::AddSession(LPWSTR buffer, EatLine eat)
}
_UpdateUI(session_id);
m_active_session = session_id;
m_color_sync[session_id] = false;
__synced[session_id] = false;
return session_id;
}

Expand All @@ -181,7 +181,7 @@ UINT RimeWithWeaselHandler::RemoveSession(UINT session_id)
DLOG(INFO) << "Remove session: session_id = " << session_id;
// TODO: force committing? otherwise current composition would be lost
RimeDestroySession(session_id);
m_color_sync.erase(session_id);
__synced.erase(session_id);
m_active_session = 0;
return 0;
}
Expand Down Expand Up @@ -228,10 +228,9 @@ void RimeWithWeaselHandler::UpdateColorTheme(BOOL darkMode)
RimeConfigClose(&config);
}

RimeSetOption(m_active_session, "__synced", false);
_LoadAppInlinePreeditSet(m_active_session);
_UpdateInlinePreeditStatus(m_active_session);
for(auto &pair : m_color_sync)
for(auto &pair : __synced)
pair.second = false;
}

Expand Down Expand Up @@ -787,17 +786,14 @@ bool RimeWithWeaselHandler::_Respond(UINT session_id, EatLine eat)
messages.push_back(std::string("config.inline_preedit=") + std::to_string((int)m_ui->style().inline_preedit) + '\n');

// style
bool has_synced = RimeGetOption(session_id, "__synced");
if (!has_synced || !m_color_sync[session_id]) {
if (!__synced[session_id]) {
std::wstringstream ss;
boost::archive::text_woarchive oa(ss);
oa << m_ui->style();

actions.insert("style");
messages.push_back(std::string("style=") + wstring_to_string(ss.str().c_str(), CP_UTF8) + '\n');
if(!has_synced)
RimeSetOption(session_id, "__synced", true);
m_color_sync[session_id] = TRUE;
__synced[session_id] = TRUE;
}

// summarize
Expand Down Expand Up @@ -1214,7 +1210,7 @@ void RimeWithWeaselHandler::_GetStatus(Status & stat, UINT session_id, Context&
{
m_last_schema_id = schema_id;
if(schema_id != ".default") { // don't load for schema select menu
RimeSetOption(session_id, "__synced", false); // Sync new schema options with front end
__synced[session_id] = false;
bool inline_preedit = m_ui->style().inline_preedit;
_LoadSchemaSpecificSettings(schema_id);
_LoadAppInlinePreeditSet(session_id, true);
Expand Down
2 changes: 1 addition & 1 deletion include/RimeWithWeasel.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,6 @@ class RimeWithWeaselHandler :
const char* message_value);
static std::string m_message_type;
static std::string m_message_value;
std::map<UINT, BOOL> m_color_sync;
std::map<UINT, BOOL> __synced;
bool m_current_dark_mode;
};

0 comments on commit 066fe94

Please sign in to comment.