Exemple #1
0
// Loop runs the main X loop.
func (dpy *Display) Loop(uwin ui.Win) {
	win := uwin.(*Window)
	awaitEvent := make(chan bool)
	go func() {
		xfd := int(C.XConnectionNumber(dpy.dpy))
		for {
			<-awaitEvent
			err := waitUntilReadable(xfd)
			if err != nil {
				log.Fatalf("select %#v", err)
			}
			dpy.eventReady <- true
		}
	}()

	C.XFlush(dpy.dpy)
	awaitEvent <- true
	draw := false
	for {
		nextFrame := dpy.anims.NextFrame(draw)
		select {
		case <-dpy.eventReady:
			dpy.processXEvents(win)
			awaitEvent <- true
		case <-dpy.drawReady:
			draw = true
		case t := <-nextFrame:
			dpy.anims.Run()
			// log.Printf("draw %s", t)
			t = t
			cr := cairo.Create(win.bufSurface.Surface)
			win.delegate.Draw(cr)
			win.repaint(0, 0, win.width, win.height)
			C.XSync(dpy.dpy, 0)
			draw = false
		case f := <-dpy.funcs:
			f()
		case <-dpy.quit:
			return
		}
	}
}
Exemple #2
0
func setStatus(status string) {
	C.XStoreName(dpy, C.XDefaultRootWindow(dpy), C.CString(status))
	C.XSync(dpy, 1)
}
Exemple #3
0
// Flush and wait for X requests completion
func (x *X) XSync() {
	C.XSync(x.dpy, 0)
}
Exemple #4
0
func setStatus(s *C.char) {
	C.XStoreName(dpy, C.XDefaultRootWindow(dpy), s)
	C.XSync(dpy, 1)
}