aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/ui/confview.go
diff options
context:
space:
mode:
authorAlexander Neumann <alexander.neumann@picos-software.com>2019-04-10 14:39:28 +0200
committerAlexander Neumann <alexander.neumann@picos-software.com>2019-04-23 11:04:59 +0200
commit60e2ee8922e64f1453a4b2e1b880fd20932e3fa9 (patch)
treef6fd3b1633031eb4f3945f6457103102c06ff4ba /ui/confview.go
parentui: implement [de]activation of tunnels via tray (diff)
downloadwireguard-windows-60e2ee8922e64f1453a4b2e1b880fd20932e3fa9.tar.xz
wireguard-windows-60e2ee8922e64f1453a4b2e1b880fd20932e3fa9.zip
ui: use Synchronize method for cross-goroutine calls to walk
Signed-off-by: Alexander Neumann <alexander.neumann@picos-software.com>
Diffstat (limited to 'ui/confview.go')
-rw-r--r--ui/confview.go25
1 files changed, 2 insertions, 23 deletions
diff --git a/ui/confview.go b/ui/confview.go
index 230d4dd7..2101aa0a 100644
--- a/ui/confview.go
+++ b/ui/confview.go
@@ -403,9 +403,8 @@ func NewConfView(parent walk.Container) (*ConfView, error) {
cv.peers = make(map[conf.Key]*peerView)
cv.creatingThread = windows.GetCurrentThreadId()
win.SetWindowLongPtr(cv.Handle(), win.GWLP_USERDATA, uintptr(unsafe.Pointer(cv)))
- cv.originalWndProc = win.SetWindowLongPtr(cv.Handle(), win.GWL_WNDPROC, crossThreadMessageHijack)
cv.tunnelChangedCB = service.IPCClientRegisterTunnelChange(cv.onTunnelChanged)
- cv.setTunnel(nil)
+ cv.SetTunnel(nil)
if err := walk.InitWrapperWindow(cv); err != nil {
return nil, err
@@ -423,18 +422,6 @@ func (cv *ConfView) Dispose() {
cv.ScrollView.Dispose()
}
-//TODO: choose actual good value for this
-const crossThreadUpdate = win.WM_APP + 17
-
-var crossThreadMessageHijack = windows.NewCallback(func(hwnd win.HWND, msg uint32, wParam, lParam uintptr) uintptr {
- cv := (*ConfView)(unsafe.Pointer(win.GetWindowLongPtr(hwnd, win.GWLP_USERDATA)))
- if msg == crossThreadUpdate {
- cv.setTunnel((*service.Tunnel)(unsafe.Pointer(wParam)))
- return 0
- }
- return win.CallWindowProc(cv.originalWndProc, hwnd, msg, wParam, lParam)
-})
-
func (cv *ConfView) TunnelTracker() *TunnelTracker {
return cv.interfaze.toggleActive.tunnelTracker
}
@@ -461,7 +448,7 @@ func (cv *ConfView) onToggleActiveClicked() {
return
}
- cv.setTunnel(cv.tunnel)
+ cv.SetTunnel(cv.tunnel)
}
func (cv *ConfView) onTunnelChanged(tunnel *service.Tunnel, state service.TunnelState, err error) {
@@ -478,14 +465,6 @@ func (cv *ConfView) updateTunnelStatus(state service.TunnelState) {
}
func (cv *ConfView) SetTunnel(tunnel *service.Tunnel) {
- if cv.creatingThread == windows.GetCurrentThreadId() {
- cv.setTunnel(tunnel)
- } else {
- cv.SendMessage(crossThreadUpdate, uintptr(unsafe.Pointer(tunnel)), 0)
- }
-}
-
-func (cv *ConfView) setTunnel(tunnel *service.Tunnel) {
cv.tunnel = tunnel
var state service.TunnelState