From 92b4073d516201e2b1c404c1033057d867f6b453 Mon Sep 17 00:00:00 2001 From: Weng Xuetian Date: Wed, 12 Jun 2024 06:34:54 -0700 Subject: [PATCH] Update the message and the logic for block message 1. option update now goes with showCustomInputMethodInfo, no need to block with keyboard event. 2. select schema shouldn't be the trigger of block message. 3. block message after success/error to prevent certain flood case if schema is invalid. --- src/rimeengine.cpp | 7 +++++++ src/rimestate.cpp | 2 -- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/rimeengine.cpp b/src/rimeengine.cpp index 2a6b835..e781016 100644 --- a/src/rimeengine.cpp +++ b/src/rimeengine.cpp @@ -568,6 +568,7 @@ void RimeEngine::notify(RimeSessionId session, const std::string &messageType, const char *icon = ""; const char *tipId = ""; int timeout = 3000; + bool blockMessage = false; if (messageType == "deploy") { tipId = "fcitx-rime-deploy"; icon = "fcitx_rime_deploy"; @@ -585,10 +586,12 @@ void RimeEngine::notify(RimeSessionId session, const std::string &messageType, } updateSchemaMenu(); refreshStatusArea(0); + blockMessage = true; } else if (messageValue == "failure") { needRefreshAppOption_ = false; message = _("Rime has encountered an error. " "See log for details."); + blockMessage = true; } } else if (messageType == "option") { updateStatusArea(session); @@ -603,6 +606,10 @@ void RimeEngine::notify(RimeSessionId session, const std::string &messageType, notifications->call( tipId, _("Rime"), icon, _("Rime"), message, timeout); } + // Block message after error / success. + if (blockMessage) { + blockNotificationFor(30000); + } } RimeState *RimeEngine::state(InputContext *ic) { diff --git a/src/rimestate.cpp b/src/rimestate.cpp index 2f0b685..6a51591 100644 --- a/src/rimestate.cpp +++ b/src/rimestate.cpp @@ -148,7 +148,6 @@ void RimeState::selectSchema(const std::string &schema) { if (api->is_maintenance_mode()) { return; } - engine_->blockNotificationFor(30000); api->set_option(session(), RIME_ASCII_MODE, false); api->select_schema(session(), schema.data()); } @@ -460,7 +459,6 @@ void RimeState::updateUI(InputContext *ic, bool keyRelease) { inputPanel.setAuxDown(Text()); } if (newEmptyExceptAux && lastMode_ != subMode()) { - engine_->blockNotificationFor(30000); engine_->instance()->showInputMethodInformation(ic); ic->updateUserInterface(UserInterfaceComponent::StatusArea); }