linuxmint / xapp

Cross-desktop libraries and common resources
GNU Lesser General Public License v3.0
127 stars 44 forks source link

DBus menu items from StatusNotifierItem do nothing #153

Closed emildekeyser closed 2 years ago

emildekeyser commented 2 years ago

I am working on adding systray support to an XMPP client and one of my targets is Cinnamon. I use a StatusNotifierItem DBus api in Vala. The icon shows up, left click activate works and on right click the menu also shows. But when I click any of the menu items they do nothing. It does work on KDE.

links to the code: https://github.com/emildekeyser/dino-fork/blob/systray/libdino/src/dbus/status_notifier_item.vala https://github.com/emildekeyser/dino-fork/blob/systray/main/src/ui/application.vala#L134

dbus-monitor output on right click:

method call time=1647378705.958847 sender=:1.36 -> destination=:1.38 serial=222 path=/org/x/StatusIcon/Icon_2; interface=org.x.StatusIcon; member=ButtonPress
   int32 1452
   int32 852
   uint32 3
   uint32 923123
   int32 3
method call time=1647378706.047683 sender=:1.36 -> destination=:1.38 serial=223 path=/org/x/StatusIcon/Icon_2; interface=org.x.StatusIcon; member=ButtonRelease
   int32 1452
   int32 852
   uint32 3
   uint32 923209
   int32 3
method call time=1647378706.054277 sender=:1.38 -> destination=:1.65 serial=144 path=/StatusNotifierMenu; interface=com.canonical.dbusmenu; member=AboutToShowGroup
   array [
      int32 0
   ]
error time=1647378706.054642 sender=:1.65 -> destination=:1.38 error_name=org.freedesktop.DBus.Error.UnknownMethod reply_serial=144
   string "No such method “AboutToShowGroup”"

dbus-monitor output on menu item click:

method call time=1647378709.024626 sender=:1.38 -> destination=:1.65 serial=145 path=/StatusNotifierMenu; interface=com.canonical.dbusmenu; member=EventGroup
   array [
      struct {
         int32 2
         string "clicked"
         variant             int32 0
         uint32 926185
      }
   ]
error time=1647378709.025178 sender=:1.65 -> destination=:1.38 error_name=org.freedesktop.DBus.Error.UnknownMethod reply_serial=145
   string "No such method “EventGroup”"
mtwebster commented 2 years ago

Weird those failing methods are part of libdbusmenu, not xapp, though I'm not sure what's causing them to fail.

We use libdbusmenu-gtk3 - it allows us to call dbusmenu_gtkmenu_new (name, menu_obj_path) to parse menu objects. Though it's a deprecated library, I've never had any significant issue using it, either with appindicator/ayatana clients or straight StatusNotifier implementations.

I have a QSystemTrayIcon script that I use for testing this (it uses StatusNotifier if it's available). There's an appindicator one as well.

Is that project in a state I could build it to try and reproduce this? What desktop/distro are you on? Maybe there are some 3rd party library differences I'm not seeing.

ref: https://github.com/linuxmint/xapp/blob/master/xapp-sn-watcher/sn-item.c#L583

emildekeyser commented 2 years ago

My systray branch on gh builds properly on on Artix (Arch) and on MX Linux (Debian) and runs perfectly on KDE on MX. On Cinnamon it is alright but I just have the mentioned bugs.

On 22/03/16 07:54, Michael Webster wrote:

Weird those failing methods are part of libdbusmenu, not xapp, though I'm not sure what's causing them to fail.

We use libdbusmenu-gtk3 - it allows us to call dbusmenu_gtkmenu_new (name, menu_obj_path) to parse menu objects. Though it's a deprecated library, I've never had any significant issue using it, either with appindicator/ayatana clients or straight StatusNotifier implementations.

I have a QSystemTrayIcon script that I use for testing this (it uses StatusNotifier if it's available). There's an appindicator one as well.

Is that project in a state I could build it to try and reproduce this? What desktop/distro are you on? Maybe there are some 3rd party library differences I'm not seeing.

ref: https://github.com/linuxmint/xapp/blob/master/xapp-sn-watcher/sn-item.c#L583

-- Reply to this email directly or view it on GitHub: https://github.com/linuxmint/xapp/issues/153#issuecomment-1069214558 You are receiving this because you authored the thread.

Message ID: @.***>

mtwebster commented 2 years ago

I can't get it to build in Mint 20 (Ubuntu 20.04) - I get:

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/mtwebster/bin/dino-fork/libdino/src/dbus/status_notifier_item.vala:149.9-149.40: error: Argument 1: Cannot convert from `int' to `unowned string'
        foreach(var entry in properties) {
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

-- but, I think the problem is libdbusmenu is expecting you to implement AboutToShowGroup and EventGroup - for whatever reason it seems to want to use those instead of the singulars AboutToShow and Event. They look approximately the same except the Group variants send an array of the their respective parameters. From what I read this is done for optimization purposes (sending and backlogged events in one call rather than numerous dbus calls).

https://github.com/AyatanaIndicators/libdbusmenu/blob/master/libdbusmenu-glib/dbus-menu.xml

emildekeyser commented 2 years ago

Oh I see, that seems to be a pretty straitforward fix. I will look into it. Thanks alot for taking a look at it!

On 22/03/16 10:07, Michael Webster wrote:

I can't get it to build in Mint 20 (Ubuntu 20.04) - I get:

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
/home/mtwebster/bin/dino-fork/libdino/src/dbus/status_notifier_item.vala:149.9-149.40: error: Argument 1: Cannot convert from `int' to `unowned string'
        foreach(var entry in properties) {
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

-- but, I think the problem is libdbusmenu is expecting you to implement AboutToShowGroup and EventGroup - for whatever reason it seems to want to use those instead of the singulars AboutToShow and Event. They look approximately the same except the Group variants send an array of the their respective parameters. From what I read this is done for optimization purposes (sending and backlogged events in one call rather than numerous dbus calls).

https://github.com/AyatanaIndicators/libdbusmenu/blob/master/libdbusmenu-glib/dbus-menu.xml

-- Reply to this email directly or view it on GitHub: https://github.com/linuxmint/xapp/issues/153#issuecomment-1069364092 You are receiving this because you authored the thread.

Message ID: @.***>

emildekeyser commented 2 years ago

Okay I implmeneted EventGroup and now it works, thanks for guidance! You can mark this as resolved for me.

mtwebster commented 2 years ago

Cool, any time.