@@ -318,6 +318,7 @@ class InstancePrivate : public QPtrHolder<Instance> {
318
318
319
319
std::vector<ScopedConnection> connections_;
320
320
std::unique_ptr<EventSourceTime> imGroupInfoTimer_;
321
+ std::unique_ptr<EventSourceTime> focusInImInfoTimer_;
321
322
322
323
std::unordered_map<std::string,
323
324
std::unordered_map<std::string, xkb_keymap_autoptr>>
@@ -643,9 +644,24 @@ Instance::Instance(int argc, char **argv) {
643
644
}));
644
645
d->eventWatchers_ .emplace_back (d->watchEvent (
645
646
EventType::InputContextFocusIn, EventWatcherPhase::ReservedFirst,
646
- [this ](Event &event) {
647
+ [this , d ](Event &event) {
647
648
auto &icEvent = static_cast <InputContextEvent &>(event);
648
649
activateInputMethod (icEvent);
650
+ if (!d->globalConfig_ .showInputMethodInformationWhenFocusIn ()) {
651
+ return ;
652
+ }
653
+ // Give some time because the cursor location may need some time
654
+ // to be updated.
655
+ d->focusInImInfoTimer_ = d->eventLoop_ .addTimeEvent (
656
+ CLOCK_MONOTONIC, now (CLOCK_MONOTONIC) + 30000 , 0 ,
657
+ [this , icRef = icEvent.inputContext ()->watch ()](
658
+ EventSourceTime *, uint64_t ) {
659
+ // Check if ic is still valid and has focus.
660
+ if (auto ic = icRef.get (); ic && ic->hasFocus ()) {
661
+ showInputMethodInformation (ic);
662
+ }
663
+ return true ;
664
+ });
649
665
}));
650
666
d->eventWatchers_ .emplace_back (d->watchEvent (
651
667
EventType::InputContextFocusOut, EventWatcherPhase::ReservedFirst,
0 commit comments