tray click is not executed and it shows the context menu instead · Issue #14941 · electron/electron · GitHub
Skip to content

tray click is not executed and it shows the context menu instead #14941

Closed

Description

@p3x-robot
  • Output of node_modules/.bin/electron --version: v3.0.2 and v4.0.0

  • Operating System (Platform and Version): Linux bitang 4.15.0-36-generic process.nextTick from dev tools doesn't fire until blurred #39-Ubuntu SMP Mon Sep 24 16:19:09 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

  • Output of node_modules/.bin/electron --version on last known working Electron version (if applicable): v2

Expected Behavior

I used the toggle show/hide of the window on the tray click and in v2 it was working.

Actual behavior

When I click now on the tray, it opens the context menu - which was working on right click only.

To Reproduce

If you provide a URL, please list the commands required to clone/setup/run your repo e.g.

$ git clone https://github.com/patrikx3/onenote
$ npm install
$ ./bin/p3x-onenote.js

Screenshots
not applicable

Additional Information
i suppose it is informative.

Activity

  1. p3x-robot commented on Oct 3, 2018

    @p3x-robot
    Author

    now on this line:
    https://github.com/patrikx3/onenote/blob/master/src/electron/main/create/tray.js#L11

    when i click on the tray, it should show on the console, but it is not shown and instead on the click it shows to context menu, here:
    https://github.com/patrikx3/onenote/blob/master/src/electron/main/create/tray.js#L16

    Why does it show the context menu when i click on it, when i never requested it? THANKS VERY MUCH!

  2. vladimiry commented on Nov 3, 2018

    @vladimiry

    Same issue. Since Electron v3 at least on Linux tray clicking started to show the context menu instead of executing subscribed to tray click event handler. Worked as expected with Electron v2.

    Btw on macOS tray click was opening a context menu even with Electron v2.

  3. raffis commented on Dec 6, 2018

    @raffis

    Same here, I receive the click event as soon as i click on the context menu which opens first after a click on the tray icon. Same problem on v3 and v4. Working fine with v2.

  4. p3x-robot commented on Dec 26, 2018

    @p3x-robot
    Author

    this acutally is happening with electron 4 as well, it was working in v2

  5. p3x-robot commented on Dec 26, 2018

    @p3x-robot
    Author

    @sofianguy would you please add that version 4 is the same error as well?

  6. p3x-robot commented on Dec 29, 2018

    @p3x-robot
    Author

    i reverted to v2.0.16, this is very important to have on a tray using app click event, maybe Atom, Visual Code it does not use the tray, but still on apps that have tray mostly, it should work on click, all linux apps work with the click and right click, but now on the docs, is says the tray click is ignore. but why?

    As the docs says: https://electronjs.org/docs/api/tray#class-tray
    When app indicator is used on Linux, the click event is ignored.

  7. vladimiry commented on Dec 30, 2018

    @vladimiry

    @sofianguy can the 4-0-x label be added here?

  8. p3x-robot commented on Jan 2, 2019

    @p3x-robot
    Author

    How come in v2 it is working then weirdly in v3 and v4 it says app indicator click event is ignored. That is 100% false!

  9. TGWKE commented on Jan 12, 2019

    @TGWKE

    different desktop environments have different typical behavior when clicking the tray icon. With electron 3, the tray icon behavior is now the same on all desktop environments that I've checked (Unity, GNOME, Xfce, MATE, Cinnamon). It copies the Unity behavior in that both a left-click and a right-click opens the context menu. Having the left-click show a context menu is a major change in behavior for many users who expect the left-click to be an action. (e.g., focus the app or open an app that is closed to the tray). Additionally, users on Xfce and MATE (and potentially others) had unread message count when hovering over the tray icon. This hover functionally no longer exists with Electron 3.

    Users on Ubuntu 18.04 (and later)/GNOME will not notice a change (although other GNOME users might) as Electron has code which masks the GNOME DE as Unity in order to have the Unity style libappindicator. (which is something that should be changed).

  10. p3x-robot commented on Jan 13, 2019

    @p3x-robot
    Author

    it is 100%, that the tray will come back with right left and right click as it should. unity is not the best desktop. i am certain.

  11. 70 remaining items

  12. MartinX3 commented on Mar 8, 2022

    @MartinX3

    It worked with signal in the past. That must be a regression there.

  13. cipriancraciun commented on Mar 8, 2022

    @cipriancraciun

    Yes, it's still an issue with latest versions of Skype, Discord and Slack. (I can't say what version of Electron they are using, because they don't report it on --version.)

  14. mykhi commented on Mar 8, 2022

    @mykhi

    Same for me, it's been so long I started to forget that left click used to work as left click.

  15. vladimiry commented on Mar 8, 2022

    @vladimiry

    It worked with signal in the past.

    It worked after the @chromium project switched to DBUS/StatusNotifier icon implementation (since Electron v8) and stopped working after the #23674 change.

  16. systemofapwne commented on Apr 1, 2022

    @systemofapwne

    It is really a shame, that this issue is still open more than 3 years after first complains.

    I recently struggled with different tray implementations in one of my python apps too (Using KDE Plasma as a DE).
    After finally having this solved (see list below), I was eager to fix it for element-web too (element-hq/element-web#11772). But it looks like it is an upstream issue with electron itself, affecting many "electronized" apps.

    So far, I tried the following tray indicators with different pros and cons:

    • LibAppIndicator is used by many projects for the tray icon but only display the context menu, no matter if you click left or right
    • GTKStatusIcon shows the correct behavior but is flagged deprecated and will be removed in newer GTK versions
    • XAppStatusIcon finally distinguishes again between left & right click. However I never was able to get the tray icon to a decent resolution (always looked like an ugly upscaled 16x16 px image)
    • QSystemTrayIcon finally allowed me to have right/left clicks behaving differently + a high resolution of the tray icon. But that needs the Qt framework to be installed. And I'm unsure, if this will also have the expected behavior on GTK based DEs (I guess/hope so?)

    If QSystemTrayIcon works across different DEs with the left & right click differentiation, it might be worth to give this a try.

  17. LRitzdorf commented on Apr 27, 2022

    @LRitzdorf

    Not to pile on here, but... yeah, this is an issue. Users do typically expect left- and right-click actions to do different things.

    Also, when libappindicator is not installed, this works the "right" way (i.e. left-click detection works), but installing it ­— even as a dependency for an unrelated package — breaks existing Electron tray icons, as described above. This, in itself, is incredibly annoying.

  18. janci007 commented on Aug 11, 2022

    @janci007

    The libappindicator is not implementing "Activate" method.
    But then there is not handler to call in Electron by that "Activate"
    There is code for creating a dummy MenuItem that will represent the left-click action,
    but it is not really created because HasClickAction returns false

    It needs to be fixed both in AppIndicator and Electron

    For more details, see:
    https://bugs.launchpad.net/ubuntu/+source/libappindicator/+bug/1910521/comments/8

  19. Rush commented on Aug 11, 2022

    @Rush

    Not to pile on here, but... yeah, this is an issue. Users do typically expect left- and right-click actions to do different things.

    Also, when libappindicator is not installed, this works the "right" way (i.e. left-click detection works), but installing it ­— even as a dependency for an unrelated package — breaks existing Electron tray icons, as described above. This, in itself, is incredibly annoying.

    At least there should be a way to disable this behavior via an environment variable - env vars are an extremely cheap way to add configurability.

  20. dima4p commented on Aug 11, 2022

    @dima4p

    Additionally, it would be great if all kde5 developers refer sometimes to how kde4 works…

  21. edlerd commented on Sep 26, 2022

    @edlerd

    I see in Ubuntu 22.04 there is no trace of libappindicator. Instead, it uses
    https://github.com/ubuntu/gnome-shell-extension-appindicator and
    https://github.com/AyatanaIndicators/libayatana-appindicator

  22. janci007 commented on Sep 26, 2022

    @janci007

    Unfortunately, libayatana-appindicator has the same issue of not differentiating between left-click and right-click and potentially other activation methods. The issue seems to be dead AyatanaIndicators/libayatana-appindicator#4
    In the meantime I investigated how QT is handling tray icons - it is directly talking to DBUS interface according to https://www.freedesktop.org/wiki/Specifications/StatusNotifierItem/ specification.
    As the protocol is simple, wouldn't talking directly to DBUS without half-assed intermediate library nicely solve this problem?

  23. vladimiry commented on Sep 26, 2022

    @vladimiry

    talking to DBUS interface according to https://www.freedesktop.org/wiki/Specifications/StatusNotifierItem/ specification.

    #14941 (comment)

  24. RobbieTheWagner commented on Oct 25, 2022

    @RobbieTheWagner

    Seems like a lot of people understand a fix here. Any possibility of opening a PR to fix it?

  25. surfzoid commented on Mar 8, 2023

    @surfzoid

    Hi,
    on linux Mageia with gnome desktop, schildichat electron app don't display anymore icon in systray, i'm not a dbus expert and perhaps i misunderstood between kernel or kde of kdbus, because under plasma/kde icon is here why using kdbus : https://github.com/search?q=org%3Aelectron+StatusIconLinuxDbus&type=code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions