aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ui
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-05-13 22:25:20 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2019-05-14 09:00:34 +0200
commit297615a9dc229158132df07c42bac92e42e8ce4a (patch)
tree09992533f6d96af1944df264f28b1d7556e4e27e /ui
parentattacksurface: updates (diff)
downloadwireguard-windows-297615a9dc229158132df07c42bac92e42e8ce4a.tar.xz
wireguard-windows-297615a9dc229158132df07c42bac92e42e8ce4a.zip
ui: do not use system tray on server core
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to '')
-rw-r--r--ui/managewindow.go6
-rw-r--r--ui/ui.go11
2 files changed, 15 insertions, 2 deletions
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()