Skip to content

fix(linux): let the panel open the tray menu - #258

Merged
yiguodev merged 1 commit into
YuanDevTeam:mainfrom
the-angwe:fix/linux-tray-menu
Nov 2, 2026
Merged

yiguodev merged 1 commit into
YuanDevTeam:mainfrom
the-angwe:fix/linux-tray-menu

Conversation

@the-angwe

Copy link
Copy Markdown
Contributor

Fixes #257: the Linux tray menu no longer opens in 26.11.1.

Cause

tray_manager 0.8.0 runs on nativeapi, whose Linux tray is a StatusNotifierItem. The panel draws the menu from the exported dbusmenu. NativeTrayPlatform.init set ContextMenuTrigger.none and opened the menu itself on click. On Linux:

  • TrayIcon.openContextMenu() always returns false (nativeapi 0.5.2 up to the current core), so openMenu() throws Unable to open the tray menu.
  • With trigger none, the item exports Menu = /NO_DBUSMENU and ItemIsMenu = false, so the panel has no menu to show. On GNOME a single click doesn't reach the app at all.

Change

lib/service/shared/menu/tray/platform.dart, Linux only:

  • Use ContextMenuTrigger.clicked, so the item exports its dbusmenu with ItemIsMenu = true and the panel opens the menu on a left or right click.
  • Ignore tray click events instead of calling onClick (which led to openMenu()). Some hosts still send Activate / ContextMenu alongside the exported menu. A debug log line records it.

Windows and macOS keep none + openContextMenu().

The panel's dbusmenu opened / closed events arrive as MenuOpenedEvent / MenuClosedEvent, so onMenuVisibility and the TrayService refresh hold while the menu is open still work. Item clicks arrive as MenuItemClickedEvent through the same listeners as before.

Verification

  • Static: git diff --check passes. I didn't have a Flutter SDK on the test host, so flutter analyze / flutter test were not run, and I didn't build or run the patched app.
  • Native layer, on Ubuntu 26.04.1, GNOME Shell 50.1 (Wayland), Ubuntu AppIndicators extension: a small C program used libcnativeapi.so from the 26.11.1 DEB the same way NativeTrayPlatform does.
    • Trigger none (current code): openContextMenu() = false, Menu = /NO_DBUSMENU, ItemIsMenu = false. This matches the installed 26.11.1.
    • Trigger clicked (this change): Menu = /StatusNotifierItem/Menu, ItemIsMenu = true, GetLayout returns the items. Sending dbusmenu Event opened, then clicked on an item, then closed, delivered MenuOpenedEvent, MenuItemClickedEvent and MenuClosedEvent in that order.
  • Not yet checked: clicking the panel with a build of this branch, on GNOME and on KDE.

🤖 Generated with Claude Code

https://claude.ai/code/session_01JwtuH1tqyDzGFdewtgzKgx

tray_manager 0.8.0 runs on nativeapi, whose Linux tray is a
StatusNotifierItem. There TrayIcon.openContextMenu() always returns
false, and with ContextMenuTrigger.none the item exports /NO_DBUSMENU,
so no click could ever show the menu.

On Linux, use ContextMenuTrigger.clicked so the panel draws the exported
dbusmenu, and ignore click events instead of opening the menu from Dart.
The dbusmenu opened/closed events still drive the menu-open refresh hold.

Fixes YuanDevTeam#257

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01JwtuH1tqyDzGFdewtgzKgx
@yiguodev
yiguodev merged commit 5efc92c into YuanDevTeam:main Nov 2, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Linux tray menu does not open in 26.11.1

2 participants