Ejemplo n.º 1
0
Archivo: mouse.go Proyecto: justjake/j3
// translate an X, Y value from one window to the euclidean space of another. Useful for translating
// the arbitrary position of some window's (0,0) point into root window space
func TranslateCoordinatesSync(X *xgbutil.XUtil, src, dest xproto.Window, x, y int) (dest_x, dest_y int, err error) {
	Xx, Xy := int16(x), int16(y)
	cookie := xproto.TranslateCoordinates(X.Conn(), src, dest, Xx, Xy)
	reply, err := cookie.Reply()
	if err != nil {
		return 0, 0, err
	}
	dest_x, dest_y = int(reply.DstX), int(reply.DstY)
	return
}
Ejemplo n.º 2
0
func Focused(c *xgb.Conn) uint32 {
	incookie := xproto.GetInputFocus(c)
	rep, err := incookie.Reply()
	if err != nil {
		return 0
	}
	win := rep.Focus

	trcookie := xproto.TranslateCoordinates(c, win,
		xproto.Setup(c).DefaultScreen(c).Root,
		0, 0)
	att, err := trcookie.Reply()
	if err != nil {
		return 0
	}
	x, y := int32(att.DstX), int32(att.DstY)

	for i, size := range sizes {
		if size.X <= x && size.X+size.W >= x && size.Y <= y && size.Y+size.H >= y {
			return uint32(i)
		}
	}
	return 0
}