diff --git a/systray.go b/systray.go index 729b521a..6d521503 100644 --- a/systray.go +++ b/systray.go @@ -13,7 +13,9 @@ import ( ) var ( - log = golog.LoggerFor("systray") + // ClickedCh is the channel which will be notified when the systray icon is clicked + ClickedCh = make(chan struct{}) + log = golog.LoggerFor("systray") systrayReady func() systrayExit func() @@ -208,3 +210,11 @@ func systrayMenuItemSelected(id int32) { default: } } + +func systrayClicked() { + select { + case ClickedCh <- struct{}{}: + default: + showMenu() + } +} diff --git a/systray_nonwindows.go b/systray_nonwindows.go index 6e06c3db..ae64cc5f 100644 --- a/systray_nonwindows.go +++ b/systray_nonwindows.go @@ -23,6 +23,9 @@ func nativeLoop() { C.nativeLoop() } +func showMenu() { +} + func quit() { C.quit() } diff --git a/systray_windows.go b/systray_windows.go index 1f4bbc27..9819b8be 100644 --- a/systray_windows.go +++ b/systray_windows.go @@ -281,8 +281,10 @@ func (t *winTray) wndProc(hWnd windows.Handle, message uint32, wParam, lParam ui systrayExit() case t.wmSystrayMessage: switch lParam { - case WM_RBUTTONUP, WM_LBUTTONUP: + case WM_RBUTTONUP: t.showMenu() + case WM_LBUTTONUP: + systrayClicked() } case t.wmTaskbarCreated: // on explorer.exe restarts t.muNID.Lock() @@ -803,6 +805,10 @@ func nativeLoop() { } } +func showMenu() { + wt.showMenu() +} + func quit() { const WM_CLOSE = 0x0010