electron: tray click is not executed and it shows the context menu instead
-
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 #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 --versionon 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.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 36
- Comments: 89 (1 by maintainers)
Looks like the proper left/primary mouse click behavior is getting back with electron version 8, see https://github.com/electron/electron/issues/21445#issuecomment-565061274 for details (tested using 8-beta4). But it seems that Linux users are going to face new tray icon related curse š
@rwwagner90 Iām just tricking electron to think libappindicator is not there. In this case, it falls back to the old behaviour. It can be easily added as a switch.
The relevant code is here:
https://github.com/electron/electron/blob/8798571a77a4d2a7e073b046d2e8b56caa4d1e68/shell/browser/ui/gtk/app_indicator_icon.cc#L98-L106
The code tries to load libappindicator with/without a trailing ā.1ā. If that fails, it returns.
So what I do is to create libappindicator3.so and libappindicator3.so.1 in the program folder - thatās the location where itās first looked for. This causes both dlopen to fail.
If libappindicator is not loaded, the condition here is false:
https://github.com/electron/electron/blob/d8594f7a782418d2da3351541b170d047392277b/shell/browser/ui/gtk/status_icon.cc#L46
In this case, it falls back to āGtkStatusIconā:
https://github.com/electron/electron/blob/d8594f7a782418d2da3351541b170d047392277b/shell/browser/ui/gtk/status_icon.cc#L53-L54
So in gtk/status_icon.cc#L46 should be an extra condition, something like āif getenv(ā¦)ā or better, add a config setting that is tested at this location.
Hello, I cannot believe that this is still unresolved after years š¦
The docs at https://www.electronjs.org/docs/api/tray states: āOn Linux the app indicator will be used if it is supported, otherwise GtkStatusIcon will be used insteadā. So I uninstalled libindicator to check if it works better with GtkStatusIcon. But in this case no status icon at all occurs. Did I miss something? And if it would work, maybe an option to enforce GtkStatusIcon could help to workarount this issue?
Get rid of electron? š
Just more proof, ubuntu is the worst desktopā¦
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.
It should definitely be added to electron. Thereās no guarantee that the workaround will work in later releases. If you ask me, the old behavior should be the default until the new implementation works properly.
This is annoying af. Makes using apps such as slack-desktop or discord real pain. š¦
This is still an issue with:
I donāt, tray plugins for Linux do.
Reproducible with libappindicator3 (libappindicator-gtk3) package installed with any electron version including latest. Reproducible with Riot for ex. Works fine if package is not installed. However icon looks weird, see: vector-im/riot-web#7553
Happens also on Xubuntu 18.04.
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 https://github.com/electron/electron/blob/8532e1239ec929e31b764ffcd314c8db3e09a19f/shell/browser/ui/tray_icon_gtk.cc#L64
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
@micw should we add this to Electron itself or suggest this workaround?
The proper left/primary mouse click behavior is going to be broken again, see #23674. This is just a guess though.
Hi, are there any updates on a possible solution to this problem�
I donāt know the v2 Version, but i would asume leftClick on trayIcon is show/hide (or show and go to new message if there is an indicator), rightClick is the context menue. This leftClick visibility toggle would help a lot on tiling window managers, since you can pull in rocketchat on whatever workspace your on when you need it š
Now on 2.15.3 its both clicks context menue on ubuntu x86 I3wm
This Electron version has less functions on the tray. We like more functions not less. Although, Electron is one if the best platform, i have to stay.
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.
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!