flathub / com.discordapp.Discord

https://flathub.org/apps/details/com.discordapp.Discord
124 stars 41 forks source link

Clicking on the system tray icon does not restore Discord window #84

Open realnc opened 4 years ago

realnc commented 4 years ago

I switched from a native Discord install (Gentoo net-im/discord-bin package) to the flatpak one. There is a bug, however. Left-clicking on the tray icon when running the flatpak version does not restore the discord window. Instead it thinks that I did a right-click and just opens the tray menu.

The native install does not have this problem; if I left-click, the discord window opens. If I right-click, the tray menu opens.

Everything seems up-to-date when doing flatpak update.

I'm on Gentoo Linux 64-bit, KDE Plasma 5.17.5.

TingPing commented 4 years ago

I'm going to guess its because the flatpak forces using AppIndicator, while the native application might have been using an XEmbed tray.

How does middle click behave?

realnc commented 4 years ago

How does middle click behave?

In both cases, it does nothing.

lionirdeadman commented 3 years ago

Is this still an issue? I believe this is a duplicate of #20 and so closing, feel free to reopen.

realnc commented 3 years ago

@lionirdeadman

Is this still an issue? I believe this is a duplicate of #20 and so closing

Yes, nothing changed. Left-click on tray icon does the same thing as right-click.

feel free to reopen.

How?

Fuseteam commented 3 years ago

@realnc is it not a duplicate of #20? edit: oh that one was resolved, you can reopen by clicking the green reopen button

realnc commented 3 years ago

@Fuseteam

@realnc is it not a duplicate of #20?

No. That one is about the menu entries on right-click not working. This one is about left-click showing that menu instead of restoring the Discord main window.

edit: oh that one was resolved, you can reopen by clicking the green reopen button

There is no such button. This is what I see:

image

lionirdeadman commented 3 years ago

I guess you can't reopen issues, strange. Reopened, sorry about that.

Yes, nothing changed. Left-click on tray icon does the same thing as right-click.

Are you sure this is related to the flatpak and not simply the extension you're using or DE?

realnc commented 3 years ago

Are you sure this is related to the flatpak and not simply the extension you're using or DE?

As mentioned in the first comment of this issue, only the flatpak behaves that way. Native install through the gentoo package manager does not have this issue.

lionirdeadman commented 3 years ago

Right.. Can you look at dbus-monitor to try and guess what interface it might be using to do this or well, any clues as to what makes that functionality work?

realnc commented 3 years ago

When I do $ dbus-monitor | grep -i discord, I get this when right-clicking:

method call time=1610172331.040227 sender=:1.50 -> destination=:1.234 serial=6610 path=/org/ayatana/NotificationItem/discord1/Menu; interface=com.canonical.dbusmenu; member=AboutToShow
method call time=1610172331.040252 sender=:1.50 -> destination=:1.234 serial=6611 path=/org/ayatana/NotificationItem/discord1/Menu; interface=com.canonical.dbusmenu; member=Event

and this when left-clicking:

method call time=1610172399.058531 sender=:1.50 -> destination=:1.234 serial=6658 path=/org/ayatana/NotificationItem/discord1; interface=org.kde.StatusNotifierItem; member=Activate
method call time=1610172399.059586 sender=:1.50 -> destination=:1.234 serial=6659 path=/org/ayatana/NotificationItem/discord1/Menu; interface=com.canonical.dbusmenu; member=AboutToShow
method call time=1610172399.059608 sender=:1.50 -> destination=:1.234 serial=6660 path=/org/ayatana/NotificationItem/discord1/Menu; interface=com.canonical.dbusmenu; member=Event
realnc commented 3 years ago

That was probably not enough. Here is the full output.

Right-click:

method call time=1610172645.190046 sender=:1.50 -> destination=:1.234 serial=6732 path=/org/ayatana/NotificationItem/discord1/Menu; interface=com.canonical.dbusmenu; member=AboutToShow
int32 0
method call time=1610172645.190075 sender=:1.50 -> destination=:1.234 serial=6733 path=/org/ayatana/NotificationItem/discord1/Menu; interface=com.canonical.dbusmenu; member=Event
int32 0
string "opened"
variant       string ""
uint32 0
method return time=1610172645.190819 sender=:1.234 -> destination=:1.50 serial=49 reply_serial=6732
boolean false

Left-click:

method call time=1610172699.007496 sender=:1.50 -> destination=:1.234 serial=6735 path=/org/ayatana/NotificationItem/discord1; interface=org.kde.StatusNotifierItem; member=Activate
int32 17
int32 1250
error time=1610172699.008072 sender=:1.234 -> destination=:1.50 error_name=org.freedesktop.DBus.Error.UnknownMethod reply_serial=6735
string "No such method “Activate”"
method call time=1610172699.008558 sender=:1.50 -> destination=:1.234 serial=6736 path=/org/ayatana/NotificationItem/discord1/Menu; interface=com.canonical.dbusmenu; member=AboutToShow
int32 0
method call time=1610172699.008583 sender=:1.50 -> destination=:1.234 serial=6737 path=/org/ayatana/NotificationItem/discord1/Menu; interface=com.canonical.dbusmenu; member=Event
int32 0
string "opened"
variant       string ""
uint32 0
method return time=1610172699.009095 sender=:1.234 -> destination=:1.50 serial=51 reply_serial=6736
boolean false
realnc commented 3 years ago

Finally, with a native install of Discord, left-click works fine and I get this:

method call time=1610173079.816691 sender=:1.50 -> destination=:1.316 serial=6813 path=/StatusNotifierItem; interface=org.kde.StatusNotifierItem; member=Activate
int32 54
int32 1285
method return time=1610173079.817093 sender=:1.316 -> destination=:1.50 serial=25 reply_serial=6813

There is no "UnknownMethod" error on "Activate".

lionirdeadman commented 3 years ago

Alright, I think I know what you can do...

Using Flatseal, if you give it access to the Session Bus org.kde.StatusNotifierItem, it might work? The command equivalent would be

flatpak override [--user] com.discordapp.Discord --talk-name=org.kde.StatusNotifierItem

Sorry for not responding quicker and thanks for the information! If this work, I'll add it to #132

realnc commented 3 years ago

I executed the command twice, once with --user and once without. Didn't fix it. Problem persists.

lionirdeadman commented 3 years ago

You killed and restarted discord afterwards? I'm not sure if flatpaks gain knowledge of new permissions without first being killed. (easiest way to kill is flatpak pkill com.discordapp.Discord)

realnc commented 3 years ago

Yes, I quit Discord before running the commands.

Now I also executed flatpak pkill com.discordapp.Discord after quitting Discord again, which resulted in:

error: 'pkill' is not a flatpak command. Did you mean 'kill'?

I replaced it with flatpak kill which says:

error: com.discordapp.Discord is not running
lionirdeadman commented 3 years ago

Well, alright, thank you for trying. I'm not sure how to fix this then, any help with this would be good.

realnc commented 3 years ago

What is "/org/ayatana" that the Flatpak version sets as path? The native version uses path=/StatusNotifierItem.

lionirdeadman commented 3 years ago

Ah... that's interesting. After looking it up, this is Unity-related. Can you try removing the environment variable that sets Unity? I'm not sure how to do it from CLI but Flatseal allows you to do it. It's already removed in the PR in favour of ubuntu:GNOME but I might remove that too.

realnc commented 3 years ago

No go. I installed Flatseal and deleted the XDG_CURRENT_DESKTOP env var first. Then I tried each one of the following:

XDG_CURRENT_DESKTOP=GNOME
XDG_CURRENT_DESKTOP=ubuntu:GNOME
XDG_CURRENT_DESKTOP=KDE

None of them helped.

lionirdeadman commented 3 years ago

Well.. alright. Feel free to report other testing. Maybe I should send an email to know what they need here and for dash-to-panel notifications because I have no clue.

waltergallegog commented 2 years ago

I had a similar issue, in kde, with installation from the .deb downloaded from the website. Not sure it can be relevant for your problem but I found this workaround: https://bodhilinux.boards.net/thread/896/make-discord-open-click-system

sudo touch /usr/share/discord/libappindicator3.so
sudo touch /usr/share/discord/libappindicator3.so.1

which works for me (I'm using KDE), Probably your path would be different as you are using flatpak

The workaround however makes the discord tray icon blurry (again).

When I first installed discord, the tray icon was blurry, which I solved following: https://wiki.archlinux.org/title/KDE#Blurry_icons_in_system_tray.

sudo apt install libappindicator3-1

So at least for me:

realnc commented 2 years ago

I don't use flatpak anymore, but this probably explains the issue if Flatpak is providing libappindicator in one of its runtimes. Discord sees it and this breaks the tray icon.

I don't have libappindicator installed on my machine, so when discord runs natively, it works. I just installed libappindicator as a test, and indeed, when doing that, native discord then has a broken systray, just like the flatpak.