From 297615a9dc229158132df07c42bac92e42e8ce4a Mon Sep 17 00:00:00 2001 From: "Jason A. Donenfeld" Date: Mon, 13 May 2019 22:25:20 +0200 Subject: ui: do not use system tray on server core Signed-off-by: Jason A. Donenfeld --- ui/managewindow.go | 6 +++++- ui/ui.go | 11 ++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'ui') diff --git a/ui/managewindow.go b/ui/managewindow.go index aa6ec21a..4da7198e 100644 --- a/ui/managewindow.go +++ b/ui/managewindow.go @@ -63,7 +63,11 @@ func NewManageTunnelsWindow() (*ManageTunnelsWindow, error) { mtw.Closing().Attach(func(canceled *bool, reason walk.CloseReason) { // "Close to tray" instead of exiting application *canceled = true - mtw.Hide() + if !noTrayAvailable { + mtw.Hide() + } else { + win.ShowWindow(mtw.Handle(), win.SW_MINIMIZE) + } }) mtw.VisibleChanged().Attach(func() { if mtw.Visible() { diff --git a/ui/ui.go b/ui/ui.go index 4ee684bc..972a7087 100644 --- a/ui/ui.go +++ b/ui/ui.go @@ -8,12 +8,15 @@ package ui import ( "fmt" "github.com/lxn/walk" + "github.com/lxn/win" "golang.zx2c4.com/wireguard/windows/service" + "golang.zx2c4.com/wireguard/windows/version" "runtime" "runtime/debug" "time" ) +var noTrayAvailable = false var shouldQuitManagerWhenExiting = false var startTime = time.Now() @@ -33,6 +36,8 @@ func RunUI() { tray *Tray ) + noTrayAvailable = version.OsIsCore() + for mtw == nil { mtw, err = NewManageTunnelsWindow() if err != nil { @@ -40,7 +45,7 @@ func RunUI() { } } - for tray == nil { + for tray == nil && !noTrayAvailable { tray, err = NewTray(mtw) if err != nil { time.Sleep(time.Millisecond * 400) @@ -75,6 +80,10 @@ func RunUI() { } }() + if noTrayAvailable { + win.ShowWindow(mtw.Handle(), win.SW_MINIMIZE) + } + mtw.Run() tray.Dispose() mtw.Dispose() -- cgit v1.2.3-59-g8ed1b