Have ui.Go() return on main() return on Windows.
This commit is contained in:
parent
db87ddae7f
commit
c0c1e09186
|
@ -29,6 +29,7 @@ type uiret struct {
|
||||||
const (
|
const (
|
||||||
_WM_APP = 0x8000 + iota
|
_WM_APP = 0x8000 + iota
|
||||||
msgRequested
|
msgRequested
|
||||||
|
msgQuit
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -49,7 +50,17 @@ func ui(main func()) error {
|
||||||
go msgloop(threadIDReq, msglooperrs)
|
go msgloop(threadIDReq, msglooperrs)
|
||||||
threadID := <-threadIDReq
|
threadID := <-threadIDReq
|
||||||
|
|
||||||
go main()
|
go func() {
|
||||||
|
main()
|
||||||
|
r1, _, err := _postThreadMessage.Call(
|
||||||
|
threadID,
|
||||||
|
msgQuit,
|
||||||
|
uintptr(0),
|
||||||
|
uintptr(0))
|
||||||
|
if r1 == 0 { // failure
|
||||||
|
panic("error sending quit message to message loop: " + err.Error()) // TODO
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
quit := false
|
quit := false
|
||||||
for !quit {
|
for !quit {
|
||||||
|
@ -123,6 +134,11 @@ func msgloop(threadID chan uintptr, errors chan error) {
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if msg.Message == msgQuit {
|
||||||
|
// does not return a value according to MSDN
|
||||||
|
_postQuitMessage.Call(0)
|
||||||
|
continue
|
||||||
|
}
|
||||||
_translateMessage.Call(uintptr(unsafe.Pointer(&msg)))
|
_translateMessage.Call(uintptr(unsafe.Pointer(&msg)))
|
||||||
_dispatchMessage.Call(uintptr(unsafe.Pointer(&msg)))
|
_dispatchMessage.Call(uintptr(unsafe.Pointer(&msg)))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue