aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ui/tray.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-05-07 09:56:56 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2019-05-07 10:59:06 +0200
commitb3eb50ae6bdae591df1cf3948333a56458f405b5 (patch)
treecb9da7b9030cd19e2aa5eb61952a50ab8c341207 /ui/tray.go
parentui: select first tunnel even when showing updates tab (diff)
downloadwireguard-windows-b3eb50ae6bdae591df1cf3948333a56458f405b5.tar.xz
wireguard-windows-b3eb50ae6bdae591df1cf3948333a56458f405b5.zip
ui: defer update popup until 3 seconds after app start
Diffstat (limited to '')
-rw-r--r--ui/tray.go17
1 files changed, 14 insertions, 3 deletions
diff --git a/ui/tray.go b/ui/tray.go
index 3d626dbf..10fb350e 100644
--- a/ui/tray.go
+++ b/ui/tray.go
@@ -10,6 +10,7 @@ import (
"golang.zx2c4.com/wireguard/windows/conf"
"sort"
"strings"
+ "time"
"github.com/lxn/walk"
"golang.zx2c4.com/wireguard/windows/service"
@@ -303,7 +304,6 @@ func (tray *Tray) UpdateFound() {
action := walk.NewAction()
action.SetText("An Update is Available!")
icon, _ := loadSystemIcon("imageres", 1)
- defer icon.Dispose()
bitmap, _ := walk.NewBitmapFromIcon(icon, walk.Size{tray.mtw.DPI() / 6, tray.mtw.DPI() / 6}) //TODO: This should use dynamic DPI.
action.SetImage(bitmap)
action.SetDefault(true)
@@ -318,8 +318,19 @@ func (tray *Tray) UpdateFound() {
tray.clicked = showUpdateTab
tray.ContextMenu().Actions().Insert(tray.ContextMenu().Actions().Len()-2, action)
- //TODO: make clicking on this call showUpdateTab
- tray.ShowCustom("WireGuard Update Available", "An update to WireGuard is now available. You are advised to update as soon as possible.", icon)
+ showUpdateBalloon := func() {
+ tray.ShowCustom("WireGuard Update Available", "An update to WireGuard is now available. You are advised to update as soon as possible.", icon)
+ defer icon.Dispose()
+ }
+
+ timeSinceStart := time.Now().Sub(startTime)
+ if timeSinceStart < time.Second*3 {
+ time.AfterFunc(time.Second*3-timeSinceStart, func() {
+ tray.mtw.Synchronize(showUpdateBalloon)
+ })
+ } else {
+ showUpdateBalloon()
+ }
}
func (tray *Tray) onManageTunnels() {