client/ui: open main window on tray left-click on Linux

KDE Plasma routes a tray left-click to the SNI Activate method (right-click
opens the context menu), but NetBird wired no Activate action, so on KDE a
left-click appeared completely dead while only right-click surfaced the menu.

Bind the Linux tray OnClick handler to ShowWindow(). OpenMenu() is not an
option on Linux: Wails v3 leaves linuxSystemTray.openMenu unimplemented (it
only logs), so left-click→OpenMenu would still do nothing on KDE. ShowWindow()
is the same call Windows already runs from its double-click handler, and it
does not reproduce the macOS OpenMenu freeze (c77e5cef8) — that came from
NSStatusItem's blocking embedded menu loop, whereas Show/Focus return
immediately.

Split the Linux click handler into its own tray_click_linux.go and narrow the
macOS no-op bindTrayClick build tag accordingly. The context menu stays on
right-click on every host. On hosts that already open the menu on left-click
natively (GNOME Shell + AppIndicator) left-click now opens the window instead;
the menu remains on right-click.
This commit is contained in:
Zoltán Papp
2026-06-01 22:04:49 +02:00
parent 072d789463
commit dfee5252a3
3 changed files with 50 additions and 21 deletions
+11 -12
View File
@@ -215,18 +215,17 @@ func NewTray(app *application.App, window *application.WebviewWindow, svc TraySe
}
t.menu = t.buildMenu()
t.tray.SetMenu(t.menu)
// Left-click on the tray icon opens the menu, and the window is reached
// through the explicit "Open NetBird" entry. This matches macOS
// NSStatusItem convention (click → menu), the Linux StatusNotifierItem
// spec, and the legacy Fyne client. macOS and Linux give us click→menu
// natively, so bindTrayClick is a no-op there (binding OnClick→OpenMenu
// on macOS would freeze the tray — see tray_click_other.go). Windows has
// no native left-click handler, so bindTrayClick wires one explicitly
// (see tray_click_windows.go). On Linux we deliberately skip AttachWindow:
// it plus Wails3's applySmartDefaults would pop the window alongside the
// menu on environments like GNOME Shell with the AppIndicator extension.
// Right-click opens the menu through Wails' default rightClickHandler on
// every platform.
// Tray click handling is platform-specific (see the tray_click_*.go
// files): macOS auto-shows the menu on left-click natively, so its
// bindTrayClick is a no-op (binding OnClick→OpenMenu would freeze the
// tray — see tray_click_other.go). Windows has no native left-click
// handler, so it wires left→OpenMenu + double→ShowWindow. Linux hosts
// disagree on left-click (KDE routes it to Activate, which was unwired
// and appeared dead), so Linux binds left→ShowWindow. The context menu
// stays reachable via right-click on every platform, plus the explicit
// "Open NetBird" entry. AttachWindow is deliberately skipped everywhere:
// with Wails3's applySmartDefaults it would pop the window alongside the
// menu on GNOME Shell + AppIndicator.
bindTrayClick(t)
app.Event.On(services.EventStatusSnapshot, t.onStatusEvent)