Beispiel #1
0
func (r *Region) GetDockRegion() xproto.Rectangle {
	initShape()
	defer func() {
		if err := recover(); err != nil {
			logger.Warning("Region::GetDockRegion", err)
		}
	}()

	var dockRegion xproto.Rectangle
	dockWindow, err := r.getDockWindow()
	if err != nil {
		logger.Warning(err)
		return dockRegion
	}
	cookie := shape.GetRectangles(XU.Conn(), dockWindow, shape.SkInput)
	rep, err := cookie.Reply()
	if err != nil {
		logger.Warning("get rectangles failed:", err)
		return dockRegion
	}

	firstRect := rep.Rectangles[0]
	dockRegion.X = firstRect.X
	dockRegion.Y = firstRect.Y
	dockRegion.Width = firstRect.Width
	dockRegion.Height = firstRect.Height

	for i, rect := range rep.Rectangles {
		logger.Debugf("dock region %d: (%d,%d)->(%d,%d)",
			i, rect.X, rect.Y,
			int32(rect.X)+int32(rect.Width),
			int32(rect.Y)+int32(rect.Height),
		)

		if i == 0 {
			continue
		}

		if dockRegion.X > rect.X {
			dockRegion.X = rect.X
			dockRegion.Width = rect.Width
		}
		if dockRegion.Y > rect.Y {
			dockRegion.Y = rect.Y
		}

		dockRegion.Height += rect.Height
	}

	logger.Debugf("Dock region: (%d, %d)->(%d, %d)",
		dockRegion.X, dockRegion.Y,
		int32(dockRegion.X)+int32(dockRegion.Width),
		int32(dockRegion.Y)+int32(dockRegion.Height),
	)

	return dockRegion
}
Beispiel #2
0
func (w *window) configure() {
	mask, values := uint16(0), []uint32(nil)
	r := xp.Rectangle{X: offscreenXY, Y: offscreenXY, Width: w.rect.Width, Height: w.rect.Height}
	if w.frame != nil && w.frame.workspace.screen != nil {
		k := w.frame.workspace
		if k.listing == listWorkspaces ||
			(k.listing == listWindows && k.focusedFrame == w.frame) {
			// No-op; r is offscreen.
		} else if k.fullscreen {
			if k.focusedFrame == w.frame {
				r.X = k.mainFrame.rect.X
				r.Y = k.mainFrame.rect.Y
				r.Width = k.mainFrame.rect.Width + 1
				r.Height = k.mainFrame.rect.Height + 1
			}
		} else {
			r.X = w.frame.rect.X + 2
			r.Y = w.frame.rect.Y + 2
			r.Width = w.frame.rect.Width - 3
			r.Height = w.frame.rect.Height - 3
		}
	}
	if w.seen && w.rect == r {
		return
	}
	w.rect = r
	if r.X != offscreenXY {
		w.seen = true
		mask = xp.ConfigWindowX |
			xp.ConfigWindowY |
			xp.ConfigWindowWidth |
			xp.ConfigWindowHeight |
			xp.ConfigWindowBorderWidth
		values = []uint32{
			uint32(uint16(r.X)),
			uint32(uint16(r.Y)),
			uint32(r.Width),
			uint32(r.Height),
			0,
		}
	} else {
		w.offscreenSeqNum = nextOffscreenSeqNum
		nextOffscreenSeqNum++
		mask = xp.ConfigWindowX | xp.ConfigWindowY
		values = []uint32{
			uint32(uint16(r.X)),
			uint32(uint16(r.Y)),
		}
	}
	check(xp.ConfigureWindowChecked(xConn, w.xWin, mask, values))
}