Ejemplo n.º 1
0
func (w *Window) Move(x uint32, y uint32) {
	var mask uint16 = xproto.ConfigWindowX | xproto.ConfigWindowY
	values := make([]uint32, 2)
	values[0] = x
	values[1] = y
	xproto.ConfigureWindow(w.conn, w.id, mask, values)

	w.geom.X = int32(x)
	w.geom.Y = int32(y)
}
Ejemplo n.º 2
0
func newGradientWindow(width, height int) {
	win := createWindow()
	xproto.ConfigureWindow(
		X.Conn(), win, xproto.ConfigWindowWidth|xproto.ConfigWindowHeight,
		[]uint32{uint32(width), uint32(height)})
	xwindow.Listen(X, win, xproto.EventMaskStructureNotify)

	xproto.MapWindow(X.Conn(), win)

	xgraphics.PaintImg(X, win, gradient(width, height))

	xevent.ConfigureNotifyFun(
		func(X *xgbutil.XUtil, ev xevent.ConfigureNotifyEvent) {
			img := gradient(int(ev.Width), int(ev.Height))
			log.Printf("Painting new image (%d, %d)", ev.Width, ev.Height)
			xgraphics.PaintImg(X, win, img)
		}).Connect(X, win)
}
Ejemplo n.º 3
0
// Configure issues a raw Configure request with the parameters given and
// updates the geometry of the window.
// This should probably only be used when passing along ConfigureNotify events
// (from the perspective of the window manager). In other cases, one should
// opt for [WM][Move][Resize] or Stack[Sibling].
func (win *Window) Configure(flags, x, y, w, h int,
	sibling xproto.Window, stackMode byte) {

	if win == nil {
		return
	}

	vals := []uint32{}

	if xproto.ConfigWindowX&flags > 0 {
		vals = append(vals, uint32(x))
		win.Geom.XSet(x)
	}
	if xproto.ConfigWindowY&flags > 0 {
		vals = append(vals, uint32(y))
		win.Geom.YSet(y)
	}
	if xproto.ConfigWindowWidth&flags > 0 {
		if int16(w) <= 0 {
			w = 1
		}
		vals = append(vals, uint32(w))
		win.Geom.WidthSet(w)
	}
	if xproto.ConfigWindowHeight&flags > 0 {
		if int16(h) <= 0 {
			h = 1
		}
		vals = append(vals, uint32(h))
		win.Geom.HeightSet(h)
	}
	if xproto.ConfigWindowSibling&flags > 0 {
		vals = append(vals, uint32(sibling))
	}
	if xproto.ConfigWindowStackMode&flags > 0 {
		vals = append(vals, uint32(stackMode))
	}

	// Nobody should be setting border widths any more.
	// We toss it out since `vals` must have length equal to the number
	// of bits set in `flags`.
	flags &= ^xproto.ConfigWindowBorderWidth
	xproto.ConfigureWindow(win.X.Conn(), win.Id, uint16(flags), vals)
}
Ejemplo n.º 4
0
func (w *Window) Redraw() {
	/* Hide X11 borders */
	var mask uint16 = xproto.ConfigWindowBorderWidth
	values := make([]uint32, 1)
	values[0] = 0
	xproto.ConfigureWindow(w.conn, w.id, mask, values)

	wdt, hgh := int16(w.geom.W), int16(w.geom.H)
	/* Drawing background */
	bg := xproto.Rectangle{0, 0, uint16(wdt), uint16(hgh)}
	bgs := make([]xproto.Rectangle, 1)
	bgs[0] = bg
	xproto.PolyFillRectangle(w.conn, xproto.Drawable(w.id), w.gc.bg, bgs)

	/* Drawing borders */
	vertices := make([]xproto.Point, 5)
	vertices[0].X = 0
	vertices[0].Y = 0
	vertices[1].X = wdt
	vertices[1].Y = 0
	vertices[2].X = wdt
	vertices[2].Y = hgh
	vertices[3].X = 0
	vertices[3].Y = hgh
	vertices[4].X = 0
	vertices[4].Y = 0
	xproto.PolyLine(w.conn, xproto.CoordModeOrigin, xproto.Drawable(w.id), w.gc.bc, vertices)

	/* Drawing text */
	hline := int16(w.gc.fontHeight)
	x, y := int16(w.gc.border), int16(w.gc.border+w.gc.fontUp)
	for _, line := range w.lines {
		xproto.ImageText8(w.conn, byte(len(line)), xproto.Drawable(w.id),
			w.gc.fg, x, y, line)
		y += hline
	}
}
Ejemplo n.º 5
0
// Configure issues a raw Configure request with the parameters given and
// updates the geometry of the window.
// This should probably only be used when passing along ConfigureNotify events
// (from the perspective of the window manager). In other cases, one should
// opt for [WM][Move][Resize] or Stack[Sibling].
func (win *Window) Configure(flags, x, y, w, h int,
	sibling xproto.Window, stackMode byte) {

	vals := []uint32{}

	if xproto.ConfigWindowX&flags > 0 {
		vals = append(vals, uint32(x))
		win.Geom.XSet(x)
	}
	if xproto.ConfigWindowY&flags > 0 {
		vals = append(vals, uint32(y))
		win.Geom.YSet(y)
	}
	if xproto.ConfigWindowWidth&flags > 0 {
		if int16(w) <= 0 {
			w = 1
		}
		vals = append(vals, uint32(w))
		win.Geom.WidthSet(w)
	}
	if xproto.ConfigWindowHeight&flags > 0 {
		if int16(h) <= 0 {
			h = 1
		}
		vals = append(vals, uint32(h))
		win.Geom.HeightSet(h)
	}
	if xproto.ConfigWindowSibling&flags > 0 {
		vals = append(vals, uint32(sibling))
	}
	if xproto.ConfigWindowStackMode&flags > 0 {
		vals = append(vals, uint32(stackMode))
	}

	xproto.ConfigureWindow(win.X.Conn(), win.Id, uint16(flags), vals)
}
Ejemplo n.º 6
0
// StackSibling issues a configure request to change the sibling and stack mode
// of Window.
// If you're using a window manager that supports EWMH, you may want to try
// and use ewmh.RestackWindowExtra instead. Although this should still work.
// 'mode' values can be found as constants in xgb/xproto with the prefix
// StackMode.
// 'sibling' refers to the sibling window in the stacking order through which
// 'mode' is interpreted. Note that 'sibling' should be taken literally. A
// window can only be stacked with respect to a *sibling* in the window tree.
// This means that a client window that has been wrapped in decorations cannot
// be stacked with respect to another client window. (This is why you should
// use ewmh.RestackWindowExtra instead.)
func (w *Window) StackSibling(sibling xproto.Window, mode byte) {
	xproto.ConfigureWindow(w.X.Conn(), w.Id,
		xproto.ConfigWindowSibling|xproto.ConfigWindowStackMode,
		[]uint32{uint32(sibling), uint32(mode)})
}
Ejemplo n.º 7
0
// Stack issues a configure request to change the stack mode of Window.
// If you're using a window manager that supports EWMH, you may want to try
// and use ewmh.RestackWindow instead. Although this should still work.
// 'mode' values can be found as constants in xgb/xproto with the prefix
// StackMode.
// A value of xproto.StackModeAbove will put the window to the top of the stack,
// while a value of xproto.StackMoveBelow will put the window to the
// bottom of the stack.
// Remember that stacking is at the discretion of the window manager, and
// therefore may not always work as one would expect.
func (w *Window) Stack(mode byte) {
	xproto.ConfigureWindow(w.X.Conn(), w.Id,
		xproto.ConfigWindowStackMode, []uint32{uint32(mode)})
}