open main window on tray double-click on Windows

Wire the Windows systray's double-click to ShowWindow(), matching the
Windows-native convention for tray apps. The Wails v3 systray dispatches
WM_LBUTTONDBLCLK to the doubleClickHandler, so OnDoubleClick fires; left-
and right-click continue to open the menu. macOS/Linux are unchanged.
This commit is contained in:
Zoltán Papp
2026-06-01 16:41:44 +02:00
parent a4ad93008b
commit c5611dd766

View File

@@ -2,7 +2,7 @@
package main
// bindTrayClick wires the tray icon's left-click to open the menu on Windows.
// bindTrayClick wires the tray icon's click handlers on Windows.
//
// Unlike macOS (NSStatusItem auto-shows the menu on left-click) and Linux
// (the StatusNotifierItem host paints the menu itself), Wails v3's Windows
@@ -13,10 +13,16 @@ package main
// left- and right-click behave identically, matching the platform-native
// click→menu behaviour we get for free on macOS/Linux.
//
// On top of that, a double-click opens the main window — the Windows-native
// convention for tray apps (the Wails systray dispatches WM_LBUTTONDBLCLK to
// the doubleClickHandler; see systemtray_windows.go). ShowWindow() routes the
// SSO/install-progress edge cases correctly and calls SetForegroundWindow.
//
// The macOS freeze that motivated reverting an earlier OnClick→OpenMenu wiring
// (commit c77e5cef8: NSStatusItem's blocking [button mouseDown:] starves the
// serial main GCD queue) does not apply here — the Windows openMenu() path is
// the same menu.ShowAt() that right-click already uses without issue.
func bindTrayClick(t *Tray) {
t.tray.OnClick(func() { t.tray.OpenMenu() })
t.tray.OnDoubleClick(func() { t.ShowWindow() })
}