16
16
#include < fcitx-config/iniparser.h>
17
17
#include < fcitx-config/rawconfig.h>
18
18
#include < fcitx-utils/event.h>
19
+ #include < fcitx-utils/eventloopinterface.h>
19
20
#include < fcitx-utils/fs.h>
20
21
#include < fcitx-utils/i18n.h>
21
22
#include < fcitx-utils/log.h>
@@ -53,6 +54,8 @@ namespace fcitx::rime {
53
54
54
55
namespace {
55
56
57
+ constexpr uint64_t startUpMessageTimeout = 5000000 ;
58
+
56
59
std::unordered_map<std::string, std::unordered_map<std::string, bool >>
57
60
parseAppOptions (rime_api_t *api, RimeConfig *config) {
58
61
std::unordered_map<std::string, std::unordered_map<std::string, bool >>
@@ -224,6 +227,8 @@ RimeEngine::RimeEngine(Instance *instance)
224
227
globalConfigReloadHandle_ = instance_->watchEvent (
225
228
EventType::GlobalConfigReloaded, EventWatcherPhase::Default,
226
229
[this ](Event &) { refreshSessionPoolPolicy (); });
230
+
231
+ startUpTime_ = now (CLOCK_MONOTONIC);
227
232
reloadConfig ();
228
233
constructed_ = true ;
229
234
}
@@ -504,7 +509,6 @@ void RimeEngine::deactivate(const InputMethodEntry &entry,
504
509
505
510
void RimeEngine::keyEvent (const InputMethodEntry &entry, KeyEvent &event) {
506
511
FCITX_UNUSED (entry);
507
- lastKeyEventTime_ = now (CLOCK_MONOTONIC);
508
512
RIME_DEBUG () << " Rime receive key: " << event.rawKey () << " "
509
513
<< event.isRelease ();
510
514
auto *inputContext = event.inputContext ();
@@ -580,6 +584,7 @@ void RimeEngine::notify(RimeSessionId session, const std::string &messageType,
580
584
const char *tipId = " " ;
581
585
int timeout = 3000 ;
582
586
bool blockMessage = false ;
587
+ bool startUpTimeCheck = true ;
583
588
if (messageType == " deploy" ) {
584
589
tipId = " fcitx-rime-deploy" ;
585
590
icon = " fcitx_rime_deploy" ;
@@ -603,6 +608,8 @@ void RimeEngine::notify(RimeSessionId session, const std::string &messageType,
603
608
message = _ (" Rime has encountered an error. "
604
609
" See log for details." );
605
610
blockMessage = true ;
611
+ // Exclude error message from start up check.
612
+ startUpTimeCheck = false ;
606
613
}
607
614
} else if (messageType == " option" ) {
608
615
updateStatusArea (session);
@@ -612,8 +619,9 @@ void RimeEngine::notify(RimeSessionId session, const std::string &messageType,
612
619
}
613
620
614
621
auto *notifications = this ->notifications ();
615
- if (message && notifications &&
616
- now (CLOCK_MONOTONIC) > blockNotificationBefore_) {
622
+ const auto current = now (CLOCK_MONOTONIC);
623
+ if (message && notifications && current > blockNotificationBefore_ &&
624
+ (!startUpTimeCheck || current > startUpTime_ + startUpMessageTimeout)) {
617
625
notifications->call <INotifications::showTip>(
618
626
tipId, _ (" Rime" ), icon, _ (" Rime" ), message, timeout);
619
627
}
0 commit comments