aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ui
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-05-14 13:46:25 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2019-05-14 13:46:25 +0200
commit0c4820181b613325ef1f9c551efac1a63422e117 (patch)
tree65c7d1203a21b83b69109899b27b4ea64df1a4f6 /ui
parentservice: winipcfg no longer returns a wrapped error (diff)
downloadwireguard-windows-0c4820181b613325ef1f9c551efac1a63422e117.tar.xz
wireguard-windows-0c4820181b613325ef1f9c551efac1a63422e117.zip
ui: update progress indicator when created
Diffstat (limited to 'ui')
-rw-r--r--ui/managewindow.go37
1 files changed, 28 insertions, 9 deletions
diff --git a/ui/managewindow.go b/ui/managewindow.go
index 2c171bac..cd42e58a 100644
--- a/ui/managewindow.go
+++ b/ui/managewindow.go
@@ -23,7 +23,8 @@ type ManageTunnelsWindow struct {
logPage *LogPage
updatePage *UpdatePage
- tunnelChangedCB *service.TunnelChangeCallback
+ tunnelChangedCB *service.TunnelChangeCallback
+ taskbarButtonCreated bool
}
const (
@@ -32,6 +33,8 @@ const (
aboutWireGuardCmd = 0x37
)
+var taskbarButtonCreatedMsg = win.RegisterWindowMessage(windows.StringToUTF16Ptr("TaskbarButtonCreated"))
+
func init() {
walk.MustRegisterWindowClass(manageWindowWindowClass)
}
@@ -128,16 +131,22 @@ func (mtw *ManageTunnelsWindow) Dispose() {
mtw.FormBase.Dispose()
}
+func (mtw *ManageTunnelsWindow) updateProgressIndicator(globalState service.TunnelState) {
+ pi := mtw.ProgressIndicator()
+ if pi == nil {
+ return
+ }
+ switch globalState {
+ case service.TunnelStopping, service.TunnelStarting:
+ pi.SetState(walk.PIIndeterminate)
+ default:
+ pi.SetState(walk.PINoProgress)
+ }
+}
+
func (mtw *ManageTunnelsWindow) onTunnelChange(tunnel *service.Tunnel, state service.TunnelState, globalState service.TunnelState, err error) {
mtw.Synchronize(func() {
- if pi := mtw.ProgressIndicator(); pi != nil {
- switch globalState {
- case service.TunnelStopping, service.TunnelStarting:
- pi.SetState(walk.PIIndeterminate)
- default:
- pi.SetState(walk.PINoProgress)
- }
- }
+ mtw.updateProgressIndicator(globalState)
icon, err2 := iconWithOverlayForState(globalState, mtw.DPI()/3) //TODO: calculate DPI dynamically
if err2 == nil {
@@ -193,6 +202,16 @@ func (mtw *ManageTunnelsWindow) WndProc(hwnd win.HWND, msg uint32, wParam, lPara
}
raise(mtw.Handle())
return 0
+ case taskbarButtonCreatedMsg:
+ ret := mtw.FormBase.WndProc(hwnd, msg, wParam, lParam)
+ if !mtw.taskbarButtonCreated {
+ mtw.taskbarButtonCreated = true
+ globalState, err := service.IPCClientGlobalState()
+ if err == nil {
+ mtw.updateProgressIndicator(globalState)
+ }
+ }
+ return ret
}
return mtw.FormBase.WndProc(hwnd, msg, wParam, lParam)