feat: implement system tray interface and manage OS thread locking for cross-platform stability

This commit is contained in:
jahruz67
2026-05-08 16:26:47 -07:00
parent 0cd56ca083
commit f71d6ccd1d
3 changed files with 13 additions and 0 deletions
+7
View File
@@ -5,6 +5,7 @@ package tray
import (
_ "embed"
"os"
"runtime"
"strings"
"wis-free-v3/internal/config"
@@ -40,6 +41,12 @@ var statusMenuItem *systray.MenuItem
// Start initializes and runs the system tray.
// This function blocks until the tray is terminated.
func Start(app App) {
// Pin this goroutine to one OS thread for the whole lifetime of systray.Run.
// getlantern/systray creates the notify icon and runs the Win32 message pump on
// whichever thread calls Run; if the goroutine migrates between threads, callbacks
// and the tray context menu break until restart (often seen after sleep/resume).
runtime.LockOSThread()
defer runtime.UnlockOSThread()
systray.Run(
func() { onReady(app) },
onExit,