From be5458c0a37cf83f2392f3951233dd3f9f406c14 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Sat, 1 Mar 2014 15:18:29 -0500 Subject: 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. --- uitask_unix.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'uitask_unix.go') diff --git a/uitask_unix.go b/uitask_unix.go index fad1503..759ac1d 100644 --- a/uitask_unix.go +++ b/uitask_unix.go @@ -10,15 +10,13 @@ import ( var uitask chan func() -func ui(initDone chan error) { +func ui(main func()) error { runtime.LockOSThread() uitask = make(chan func()) if gtk_init() != true { - initDone <- fmt.Errorf("gtk_init failed (reason unknown; TODO)") - return + return fmt.Errorf("gtk_init failed (reason unknown; TODO)") } - initDone <- nil // thanks to tristan in irc.gimp.net/#gtk gdk_threads_add_idle(func() bool { @@ -29,5 +27,9 @@ func ui(initDone chan error) { } return true // don't destroy the callback }) + + go main() + gtk_main() + return nil } -- cgit v1.2.3