예제 #1
0
파일: xlib.go 프로젝트: evmar/smash
// 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
		}
	}
}
예제 #2
0
func setStatus(status string) {
	C.XStoreName(dpy, C.XDefaultRootWindow(dpy), C.CString(status))
	C.XSync(dpy, 1)
}
예제 #3
0
// Flush and wait for X requests completion
func (x *X) XSync() {
	C.XSync(x.dpy, 0)
}
예제 #4
0
func setStatus(s *C.char) {
	C.XStoreName(dpy, C.XDefaultRootWindow(dpy), s)
	C.XSync(dpy, 1)
}