コード例 #1
0
ファイル: compositor.go プロジェクト: romovs/viscum
func (c *Compositor) Compose() {

	for {
		<-c.InvMsgPipe

		<-c.MouseWait

		// render desktop, windows, and child elements
		for v := c.WindowList.Back(); v != nil; v = v.Prev() {
			e := v.Value.(*base.Element)
			gfx.DrawSrc(c.fb, e, e.X, e.Y, e.Width, e.Height)
		}

		// render mouse pointer
		if c.mousePointer != nil {
			gfx.DrawOver(c.fb, c.mousePointer, c.mousePointer.X, c.mousePointer.Y, c.mousePointer.Width, c.mousePointer.Height)
		}

		flush(c)

		c.CompositorRelease <- false
	}
}
コード例 #2
0
ファイル: mousepointer.go プロジェクト: romovs/viscum
func (ms *Mouse) CreatePointer(fb *fbdev.Framebuffer, imp chan int64) *MousePointer {

	f, err := os.Open("data/cursor/arrow.png")
	if err != nil {
		log.Critical(err)
		return nil
	}
	defer f.Close()

	img, _, err := image.Decode(bufio.NewReader(f))
	if err != nil {
		log.Critical(err)
		return nil
	}

	mp := &MousePointer{
		fb: fb,
	}

	w := img.Bounds().Max.X
	h := img.Bounds().Max.Y

	mp.Element = base.Element{
		X:          int(fb.Vinfo.Xres / 2),
		Y:          int(fb.Vinfo.Yres / 2),
		Width:      w,
		Height:     h,
		Buffer:     make([]byte, w*h*4),
		InvMsgPipe: imp,
	}

	ms.RegisterMousePointer(mp.mouse)

	gfx.DrawSrc(&mp.Element, img, 0, 0, w, h)

	return mp
}