Skip to content

Commit

Permalink
Update inline preedit option only when inline_preedit is changed
Browse files Browse the repository at this point in the history
  • Loading branch information
fxliang committed Dec 9, 2023
1 parent dfd1a56 commit e4d9ac6
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions RimeWithWeasel/RimeWithWeasel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,20 +491,22 @@ void RimeWithWeaselHandler::_LoadAppInlinePreeditSet(UINT session_id, bool ignor
if(!ignore_app_name && m_last_app_name == app_name)
return;
m_last_app_name = app_name;
bool inline_preedit = m_ui->style().inline_preedit;
if (!app_name.empty())
{
if (m_app_options.find(app_name) != m_app_options.end())
{
AppOptions& options(m_app_options[app_name]);
auto pfind = std::make_shared<bool>(false);
std::for_each(options.begin(), options.end(), [session_id, app_name, pfind, this](std::pair<const std::string, bool> &pair)
std::for_each(options.begin(), options.end(), [session_id, app_name, pfind, inline_preedit, this](std::pair<const std::string, bool> &pair)
{
if(pair.first == "inline_preedit")
{
*pfind = true;
RimeSetOption(session_id, pair.first.c_str(), Bool(pair.second));
m_ui->style().inline_preedit = Bool(pair.second);
_UpdateInlinePreeditStatus(session_id);
if(m_ui->style().inline_preedit != inline_preedit)
_UpdateInlinePreeditStatus(session_id);
}
});
if (!(*pfind))
Expand All @@ -527,7 +529,8 @@ void RimeWithWeaselHandler::_LoadAppInlinePreeditSet(UINT session_id, bool ignor
m_ui->style().inline_preedit = !!inline_preedit;
RimeConfigClose(&config);
RimeFreeStatus(&status);
_UpdateInlinePreeditStatus(session_id);
if(m_ui->style().inline_preedit != inline_preedit)
_UpdateInlinePreeditStatus(session_id);
}
}
}
Expand Down Expand Up @@ -1124,9 +1127,11 @@ 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
bool inline_preedit = m_ui->style().inline_preedit;
_LoadSchemaSpecificSettings(schema_id);
_LoadAppInlinePreeditSet(session_id, true);
_UpdateInlinePreeditStatus(session_id); // in case of inline_preedit set in schema
if(m_ui->style().inline_preedit != inline_preedit)
_UpdateInlinePreeditStatus(session_id); // in case of inline_preedit set in schema
_RefreshTrayIcon(session_id, _UpdateUICallback); // refresh icon after schema changed
if (m_show_notifications_when & SHOWN_SCHEMA) {
ctx.aux.str = stat.schema_name;
Expand Down

0 comments on commit e4d9ac6

Please sign in to comment.