diff options
| author | Pietro Gagliardi <[email protected]> | 2014-02-11 22:18:14 -0500 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-02-11 22:18:14 -0500 |
| commit | 08ba4a1074fecc9bae73e6e72e0bc6162b81b344 (patch) | |
| tree | 76c28a47f52d2c84e1ca88b32f17b9232fb4d9a9 | |
| parent | ae14253c80e977c7d9786663b6aacf7d383a15b7 (diff) | |
Fixed the wndproc not responding: turns out I have to have message dispatch in the UI thread...
| -rw-r--r-- | uitask_windows.go | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/uitask_windows.go b/uitask_windows.go index d944869..b1c0bfe 100644 --- a/uitask_windows.go +++ b/uitask_windows.go @@ -28,13 +28,34 @@ func ui(initDone chan error) { uitask = make(chan *uimsg) initDone <- doWindowsInit() - go msgloop() +// go msgloop() + var msg struct { + Hwnd _HWND + Message uint32 + WParam _WPARAM + LParam _LPARAM + Time uint32 + Pt _POINT + } + var _peekMessage = user32.NewProc("PeekMessageW") + const _PM_REMOVE = 0x0001 - for m := range uitask { - r1, _, err := m.call.Call(m.p...) - m.ret <- uiret{ - ret: r1, - err: err, + for { + select { + case m := <-uitask: + r1, _, err := m.call.Call(m.p...) + m.ret <- uiret{ + ret: r1, + err: err, + } + default: + // TODO figure out how to handle errors + _peekMessage.Call( + uintptr(unsafe.Pointer(&msg)), + uintptr(_NULL), + 0, + 0, + uintptr(_PM_REMOVE)) } } } |
