@@ -72,6 +72,14 @@ class StatusNotifierItem : public dbus::ObjectVTable<StatusNotifierItem> {
7272
7373 std::string label () { return " " ; }
7474
75+ std::string title () {
76+ const InputMethodEntry *imEntry = nullptr ;
77+ if (auto *ic = parent_->menu ()->lastRelevantIc ()) {
78+ imEntry = parent_->instance ()->inputMethodEntry (ic);
79+ }
80+ return imEntry == nullptr ? _ (" Input Method" ) : imEntry->name ();
81+ }
82+
7583 static dbus::DBusStruct<
7684 std::string,
7785 std::vector<dbus::DBusStruct<int32_t , int32_t , std::vector<uint8_t >>>,
@@ -104,6 +112,15 @@ class StatusNotifierItem : public dbus::ObjectVTable<StatusNotifierItem> {
104112 lastLabel_ = std::move (label);
105113 }
106114
115+ void notifyNewTitle () {
116+ std::string currentTitle = title ();
117+ if (currentTitle.empty () || lastTitle_ == currentTitle) {
118+ return ;
119+ }
120+ newTitle ();
121+ lastTitle_ = std::move (currentTitle);
122+ }
123+
107124 void reset () {
108125 releaseSlot ();
109126 lastIconName_.clear ();
@@ -138,8 +155,7 @@ class StatusNotifierItem : public dbus::ObjectVTable<StatusNotifierItem> {
138155 FCITX_OBJECT_VTABLE_PROPERTY (category, " Category" , " s" ,
139156 []() { return " SystemServices" ; });
140157 FCITX_OBJECT_VTABLE_PROPERTY (id, " Id" , " s" , []() { return " Fcitx" ; });
141- FCITX_OBJECT_VTABLE_PROPERTY (title, " Title" , " s" ,
142- []() { return _ (" Input Method" ); });
158+ FCITX_OBJECT_VTABLE_PROPERTY (title, " Title" , " s" , [this ]() { return title (); });
143159 FCITX_OBJECT_VTABLE_PROPERTY (status, " Status" , " s" ,
144160 []() { return " Active" ; });
145161 FCITX_OBJECT_VTABLE_PROPERTY (windowId, " WindowId" , " i" , []() { return 0 ; });
@@ -238,6 +254,7 @@ class StatusNotifierItem : public dbus::ObjectVTable<StatusNotifierItem> {
238254 std::string cachedLabel_;
239255 std::vector<dbus::DBusStruct<int , int , std::vector<uint8_t >>>
240256 cachedLabelIcon_;
257+ std::string lastTitle_;
241258};
242259
243260NotificationItem::NotificationItem (Instance *instance)
@@ -406,6 +423,13 @@ void NotificationItem::newIcon() {
406423 // sni_->xayatanaNewLabel(sni_->label(), sni_->label());
407424}
408425
426+ void NotificationItem::newTitle () {
427+ if (!sni_->isRegistered ()) {
428+ return ;
429+ }
430+ sni_->notifyNewTitle ();
431+ }
432+
409433class NotificationItemFactory : public AddonFactory {
410434 AddonInstance *create (AddonManager *manager) override {
411435 return new NotificationItem (manager->instance ());
0 commit comments