microsoft windows only: open application on left click and tray menu on right click

This commit is contained in:
Eduard Gert
2026-06-17 09:55:00 +02:00
parent 0c21aefc7f
commit 3e1dc1f023
2 changed files with 6 additions and 11 deletions

View File

@@ -189,9 +189,10 @@ func NewTray(app *application.App, window *application.WebviewWindow, svc TraySe
t.tray.SetMenu(t.menu)
// macOS/Linux give click→menu natively, so bindTrayClick is a no-op there
// (binding OnClick→OpenMenu on macOS would freeze the tray); Windows has no
// native handler so it wires one (see tray_click_*.go). On Linux
// AttachWindow is skipped — with applySmartDefaults it would pop the window
// alongside the menu (e.g. GNOME Shell AppIndicator).
// native left-click handler so it wires one to open the main window, leaving
// the menu on right-click (see tray_click_*.go). On Linux AttachWindow is
// skipped — with applySmartDefaults it would pop the window alongside the
// menu (e.g. GNOME Shell AppIndicator).
bindTrayClick(t)
app.Event.On(services.EventStatusSnapshot, t.onStatusEvent)

View File

@@ -2,13 +2,7 @@
package main
// bindTrayClick wires the tray icon's click handlers on Windows.
//
// Wails v3's Windows systray leaves left-click a no-op (only right-click opens
// the menu), so bind OnClick to OpenMenu to match macOS/Linux. The macOS freeze
// that blocks OnClick→OpenMenu doesn't apply here: openMenu() is the same
// menu.ShowAt() path right-click already uses.
// Open application window on left click, right click opens the tray menu
func bindTrayClick(t *Tray) {
t.tray.OnClick(func() { t.tray.OpenMenu() })
t.tray.OnDoubleClick(func() { t.ShowWindow() })
t.tray.OnClick(func() { t.ShowWindow() })
}