diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-05-14 12:46:18 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2019-05-14 12:50:33 +0200 |
commit | 9975dac62e8ebe56d9116435554ff7e876fe29be (patch) | |
tree | 2de22d926cdf9bab26366b5b09c825acb0b0e7cc | |
parent | service: account for loggedon but disconnected sessions (diff) | |
download | wireguard-windows-9975dac62e8ebe56d9116435554ff7e876fe29be.tar.xz wireguard-windows-9975dac62e8ebe56d9116435554ff7e876fe29be.zip |
ui: add about to corner menu
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to '')
-rw-r--r-- | ui/managewindow.go | 28 | ||||
-rw-r--r-- | ui/tray.go | 2 |
2 files changed, 29 insertions, 1 deletions
diff --git a/ui/managewindow.go b/ui/managewindow.go index 4da7198e..2c171bac 100644 --- a/ui/managewindow.go +++ b/ui/managewindow.go @@ -6,8 +6,12 @@ package ui import ( + "unsafe" + "github.com/lxn/walk" "github.com/lxn/win" + "golang.org/x/sys/windows" + "golang.zx2c4.com/wireguard/windows/service" ) @@ -25,6 +29,7 @@ type ManageTunnelsWindow struct { const ( manageWindowWindowClass = "WireGuard UI - Manage Tunnels" raiseMsg = win.WM_USER + 0x3510 + aboutWireGuardCmd = 0x37 ) func init() { @@ -95,6 +100,23 @@ func NewManageTunnelsWindow() (*ManageTunnelsWindow, error) { globalState, _ := service.IPCClientGlobalState() mtw.onTunnelChange(nil, service.TunnelUnknown, globalState, nil) + systemMenu := win.GetSystemMenu(mtw.Handle(), false) + if systemMenu != 0 { + win.InsertMenuItem(systemMenu, 0, true, &win.MENUITEMINFO{ + CbSize: uint32(unsafe.Sizeof(win.MENUITEMINFO{})), + FMask: win.MIIM_ID | win.MIIM_STRING | win.MIIM_FTYPE, + FType: win.MIIM_STRING, + DwTypeData: windows.StringToUTF16Ptr("About WireGuard..."), + WID: uint32(aboutWireGuardCmd), + }) + win.InsertMenuItem(systemMenu, 1, true, &win.MENUITEMINFO{ + CbSize: uint32(unsafe.Sizeof(win.MENUITEMINFO{})), + FMask: win.MIIM_TYPE, + FType: win.MFT_SEPARATOR, + }) + win.CloseHandle(win.HANDLE(systemMenu)) + } + return mtw, nil } @@ -154,6 +176,11 @@ func (mtw *ManageTunnelsWindow) WndProc(hwnd win.HWND, msg uint32, wParam, lPara if lParam == win.ENDSESSION_CLOSEAPP && wParam == 1 { walk.App().Exit(198) } + case win.WM_SYSCOMMAND: + if wParam == aboutWireGuardCmd { + onAbout(mtw) + return 0 + } case raiseMsg: if !mtw.Visible() { mtw.tunnelsPage.listView.SelectFirstActiveTunnel() @@ -165,6 +192,7 @@ func (mtw *ManageTunnelsWindow) WndProc(hwnd win.HWND, msg uint32, wParam, lPara mtw.tabs.SetCurrentIndex(2) } raise(mtw.Handle()) + return 0 } return mtw.FormBase.WndProc(hwnd, msg, wParam, lParam) @@ -83,7 +83,7 @@ func (tray *Tray) setup() error { {label: "&Manage tunnels...", handler: tray.onManageTunnels, enabled: true, defawlt: true}, {label: "&Import tunnel(s) from file...", handler: tray.onImport, enabled: true}, {separator: true}, - {label: "&About WireGuard", handler: tray.onAbout, enabled: true}, + {label: "&About WireGuard...", handler: tray.onAbout, enabled: true}, {label: "&Exit", handler: onQuit, enabled: true}, } { var action *walk.Action |