summaryrefslogtreecommitdiff
path: root/uitask_windows.go
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-03-01 15:18:29 -0500
committerPietro Gagliardi <[email protected]>2014-03-01 15:18:29 -0500
commitbe5458c0a37cf83f2392f3951233dd3f9f406c14 (patch)
treeae358af220f4533465ca8807157889b819dcf884 /uitask_windows.go
parentc8c257f8c84c163354a2b3ba7c97bd76f2700443 (diff)
Major code restructure to allow Cocoa to work correctly. Cocoa requires that the application loop run on the very first OS thread created, not just an any ordinary thread. To support this, your code must now be run by the UI init code. Windows and Unix builds still work fine; Mac OS X fails for reasons I now have to debug.
Diffstat (limited to 'uitask_windows.go')
-rw-r--r--uitask_windows.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/uitask_windows.go b/uitask_windows.go
index c1f867c..33ab0ad 100644
--- a/uitask_windows.go
+++ b/uitask_windows.go
@@ -35,17 +35,22 @@ var (
_postThreadMessage = user32.NewProc("PostThreadMessageW")
)
-func ui(initDone chan error) {
+func ui(main func()) error {
runtime.LockOSThread()
uitask = make(chan *uimsg)
- initDone <- doWindowsInit()
+ err := doWindowsInit()
+ if err != nil {
+ return err
+ }
threadIDReq := make(chan uintptr)
msglooperrs := make(chan error)
go msgloop(threadIDReq, msglooperrs)
threadID := <-threadIDReq
+ go main()
+
quit := false
for !quit {
select {
@@ -66,6 +71,8 @@ func ui(initDone chan error) {
}
}
}
+
+ return nil
}
var (