diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-05-10 14:00:33 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-05-10 14:00:33 +0200 |
commit | 7220d62e96d214c790175aee5bce3ab935e43e82 (patch) | |
tree | 97e52ee6407c8f1c665dc6392a0800308f7a16d4 /ui/raise.go | |
parent | service: clean up addresses from stale interfaces (diff) | |
download | wireguard-windows-7220d62e96d214c790175aee5bce3ab935e43e82.tar.xz wireguard-windows-7220d62e96d214c790175aee5bce3ab935e43e82.zip |
ui: dont use main window and run our own message loop
This allows us to do custom things like send raise click messages.
Diffstat (limited to 'ui/raise.go')
-rw-r--r-- | ui/raise.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/ui/raise.go b/ui/raise.go index f902546e..c4a45833 100644 --- a/ui/raise.go +++ b/ui/raise.go @@ -15,8 +15,6 @@ import ( "golang.org/x/sys/windows" ) -const wireguardUIClass = "WireGuard UI - MainWindow" - func raise(hwnd win.HWND) { if win.IsIconic(hwnd) { win.ShowWindow(hwnd, win.SW_RESTORE) @@ -30,10 +28,11 @@ func raise(hwnd win.HWND) { } func RaiseUI() bool { - hwnd := win.FindWindow(windows.StringToUTF16Ptr(wireguardUIClass), nil) + hwnd := win.FindWindow(windows.StringToUTF16Ptr(manageWindowWindowClass), nil) if hwnd == 0 { return false } + win.SendMessage(hwnd, selectCorrectTabMsg, 0, 0) raise(hwnd) return true } @@ -42,12 +41,13 @@ func WaitForRaiseUIThenQuit() { var handle win.HWINEVENTHOOK runtime.LockOSThread() handle, err := win.SetWinEventHook(win.EVENT_OBJECT_CREATE, win.EVENT_OBJECT_CREATE, 0, func(hWinEventHook win.HWINEVENTHOOK, event uint32, hwnd win.HWND, idObject int32, idChild int32, idEventThread uint32, dwmsEventTime uint32) uintptr { - class := make([]uint16, len(wireguardUIClass)+2) /* Plus 2, one for the null terminator, and one to see if this is only a prefix */ + class := make([]uint16, len(manageWindowWindowClass)+2) /* Plus 2, one for the null terminator, and one to see if this is only a prefix */ n, err := win.GetClassName(hwnd, &class[0], len(class)) - if err != nil || n != len(wireguardUIClass) || windows.UTF16ToString(class) != wireguardUIClass { + if err != nil || n != len(manageWindowWindowClass) || windows.UTF16ToString(class) != manageWindowWindowClass { return 0 } win.UnhookWinEvent(handle) + win.SendMessage(hwnd, selectCorrectTabMsg, 0, 0) raise(hwnd) os.Exit(0) return 0 |