mirror of
https://github.com/jahruz67/wisp-open.git
synced 2026-08-08 18:14:08 +00:00
14.
This commit is contained in:
@@ -46,21 +46,6 @@ var statusMenuItem *systray.MenuItem
|
||||
var triggerCountItem *systray.MenuItem
|
||||
var triggerCount int
|
||||
|
||||
// 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,
|
||||
)
|
||||
}
|
||||
|
||||
func appDisplayName(app App) string {
|
||||
v := app.Version()
|
||||
if v != "" && v != "dev" {
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
//go:build linux
|
||||
|
||||
package tray
|
||||
|
||||
import "github.com/getlantern/systray"
|
||||
|
||||
// On Linux, Wails already runs the GTK main loop on the main thread.
|
||||
// Calling systray.Run() would start a second gtk_main() and may abort.
|
||||
// Instead, we only register the tray and let the existing GTK loop drive it.
|
||||
func Start(app App) {
|
||||
systray.Register(
|
||||
func() { onReady(app) },
|
||||
onExit,
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
//go:build !linux
|
||||
|
||||
package tray
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
|
||||
"github.com/getlantern/systray"
|
||||
)
|
||||
|
||||
// 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,
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user