mirror of
https://github.com/netbirdio/netbird.git
synced 2026-10-20 20:39:08 +02:00
Wails v3 does not auto-show the tray menu on left-click on Windows — its
default left-click handler only logs and does nothing visible, so only
right-click opened the menu. macOS (NSStatusItem) and Linux
(StatusNotifierItem host) give us click→menu natively.
Add a build-tag-split bindTrayClick: the Windows variant wires
OnClick→OpenMenu (the same menu.ShowAt path right-click uses), while the
macOS/Linux variant stays a no-op — binding OnClick→OpenMenu on macOS
freezes the tray via NSStatusItem's blocking mouseDown on the main GCD
queue (the reason commit c77e5cef8 reverted the earlier wiring).
23 lines
1.1 KiB
Go
23 lines
1.1 KiB
Go
//go:build windows
|
|
|
|
package main
|
|
|
|
// bindTrayClick wires the tray icon's left-click to open the menu 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
|
|
// systray installs a default left-click handler that only logs "Left Button
|
|
// Clicked" and does nothing visible — only right-click opens the menu via the
|
|
// default rightClickHandler (see systemtray_windows.go run()). Left-clicking
|
|
// the icon therefore appears dead to the user. We bind OnClick to OpenMenu so
|
|
// left- and right-click behave identically, matching the platform-native
|
|
// click→menu behaviour we get for free on macOS/Linux.
|
|
//
|
|
// 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() })
|
|
}
|