aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ui/tray.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-05-10 11:00:16 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2019-05-10 11:50:34 +0200
commit5cb7a511dbdfc78a6fa5a7361df11420b08afb2b (patch)
tree8f65c9637aff82014ce02adb1d6420734464bcf1 /ui/tray.go
parentservice: fix user logout (diff)
downloadwireguard-windows-5cb7a511dbdfc78a6fa5a7361df11420b08afb2b.tar.xz
wireguard-windows-5cb7a511dbdfc78a6fa5a7361df11420b08afb2b.zip
ui: somewhat aggressively cache icons
Diffstat (limited to '')
-rw-r--r--ui/tray.go12
1 files changed, 2 insertions, 10 deletions
diff --git a/ui/tray.go b/ui/tray.go
index 3861f9c9..668163da 100644
--- a/ui/tray.go
+++ b/ui/tray.go
@@ -54,9 +54,8 @@ func (tray *Tray) setup() error {
tray.SetToolTip("WireGuard: Deactivated")
tray.SetVisible(true)
- wireguardIcon, err := walk.NewIconFromResourceWithSize("$wireguard.ico", walk.Size{tray.mtw.DPI() / 6, tray.mtw.DPI() / 6}) //TODO: calculate DPI dynamically
- if err == nil {
- tray.SetIcon(wireguardIcon)
+ if icon, err := loadLogoIcon(tray.mtw.DPI() / 6); err == nil { //TODO: calculate DPI dynamically
+ tray.SetIcon(icon)
}
tray.MouseDown().Attach(func(x, y int, button walk.MouseButton) {
@@ -220,11 +219,7 @@ func (tray *Tray) onTunnelChange(tunnel *service.Tunnel, state service.TunnelSta
func (tray *Tray) updateGlobalState(globalState service.TunnelState) {
if icon, err := iconWithOverlayForState(globalState, tray.mtw.DPI()/6); err == nil { //TODO: calculate DPI dynamically
- prior := tray.Icon()
tray.SetIcon(icon)
- if prior != nil {
- prior.Dispose()
- }
}
actions := tray.ContextMenu().Actions()
@@ -304,7 +299,6 @@ func (tray *Tray) SetTunnelState(tunnel *service.Tunnel, state service.TunnelSta
tunnelAction.SetChecked(false)
if wasChecked && showNotifications {
icon, _ := loadSystemIcon("imageres", 26, tray.mtw.DPI()*4/3) //TODO: this icon isn't very good..., also calculate dpi dynamically
- defer icon.Dispose()
tray.ShowCustom("WireGuard Deactivated", fmt.Sprintf("The %s tunnel has been deactivated.", tunnel.Name), icon)
}
}
@@ -316,7 +310,6 @@ func (tray *Tray) UpdateFound() {
iconSize := tray.mtw.DPI() / 6 //TODO: This should use dynamic DPI.
menuIcon, _ := loadSystemIcon("imageres", 1, iconSize)
bitmap, _ := walk.NewBitmapFromIcon(menuIcon, walk.Size{iconSize, iconSize})
- menuIcon.Dispose()
action.SetImage(bitmap)
action.SetDefault(true)
showUpdateTab := func() {
@@ -333,7 +326,6 @@ func (tray *Tray) UpdateFound() {
showUpdateBalloon := func() {
icon, _ := loadSystemIcon("imageres", 1, tray.mtw.DPI()*4/3) //TODO: calculate DPI dynamically
tray.ShowCustom("WireGuard Update Available", "An update to WireGuard is now available. You are advised to update as soon as possible.", icon)
- icon.Dispose()
}
timeSinceStart := time.Now().Sub(startTime)