Beispiel #1
0
// guiLoop runs the main GUI thread event loop in C++ land.
func guiLoop() {
	runtime.LockOSThread()
	guiLoopRef = tref.Ref()
	C.newGuiApplication()
	C.idleTimerInit(&hookWaiting)
	guiLoopReady.Unlock()
	C.applicationExec()
}
Beispiel #2
0
// guiLoop runs the main GUI thread event loop in C++ land.
func guiLoop() {
	// This is not an option in Init to avoid forcing people to patch
	// and recompile an application just so it runs on Ubuntu Touch.
	deskfile := os.Getenv("DESKTOP_FILE_HINT")
	cdeskfile := (*C.char)(nil)
	if deskfile != "" {
		os.Setenv("DESKTOP_FILE_HINT", "")
		cdeskfile = C.CString("--desktop_file_hint=" + deskfile)
	}

	runtime.LockOSThread()
	guiLoopRef = tref.Ref()
	C.newGuiApplication(cdeskfile)
	C.idleTimerInit(&hookWaiting)
	guiLoopReady.Unlock()
	C.applicationExec()
}
Beispiel #3
0
// Run runs the main QML event loop, runs f, and then terminates the
// event loop once f returns.
//
// Most functions from the qml package block until Run is called.
//
// The Run function must necessarily be called from the same goroutine as
// the main function or the application may fail when running on Mac OS.
func Run(f func() error) error {
	if cdata.Ref() != guiMainRef {
		panic("Run must be called on the initial goroutine so apps are portable to Mac OS")
	}
	if !atomic.CompareAndSwapInt32(&initialized, 0, 1) {
		panic("qml.Run called more than once")
	}
	C.newGuiApplication()
	C.idleTimerInit((*C.int32_t)(&guiIdleRun))
	done := make(chan error, 1)
	go func() {
		RunMain(func() {}) // Block until the event loop is running.
		done <- f()
		C.applicationExit()
	}()
	C.applicationExec()
	return <-done
}