Beispiel #1
0
// moveToProperHead is used to make sure a newly managed client is placed on
// the correct monitor.
//
// Before adding the client into our data structures, we should first
// make sure it's located on the right head. We do this by finding where
// it *is* placed and convert it into the coordinate space of where it
// *should* be placed.
//
// Note that presumedWorkspace MUST be visible.
func (c *Client) moveToProperHead(presumedWorkspace workspace.Workspacer) {
	if c.PrimaryType() != TypeNormal {
		return
	}
	if _, ok := presumedWorkspace.(*workspace.Sticky); ok {
		return
	}
	if !presumedWorkspace.IsVisible() {
		return
	}

	oughtHeadGeom := presumedWorkspace.HeadGeom()
	cgeom := c.frame.Geom()
	if wrk := wm.Heads.FindMostOverlap(cgeom); wrk != nil {
		if wrk != presumedWorkspace {
			isHeadGeom := wrk.HeadGeom()
			ngeom := heads.Convert(cgeom, isHeadGeom, oughtHeadGeom)
			c.MoveResizeValid(
				ngeom.X(), ngeom.Y(), ngeom.Width(), ngeom.Height())
		}
	} else {
		// If we're here, that means the client *ought* to belong to a visible
		// workspace but it could not be found to overlap with *any* visible
		// workspace. Therefore, just use a hammer and move it to the root
		// coordinates of the presumed workspace.
		geom := presumedWorkspace.Geom()
		c.Move(geom.X(), geom.Y())
	}
}
Beispiel #2
0
// Don't revert to regular geometry when moving/resizing. We can still revert
// the frame or the maximized state, though.
// Also don't load *ever* when client's workspace isn't visible.
func (c *Client) LoadState(name string) {
	if !c.workspace.IsVisible() {
		return
	}

	s, ok := c.states[name]
	if !ok {
		return
	}

	// We're committed now to at least reverting frame.
	c.frames.set(s.frame)

	// Delete the state entry here. We do this because this state may be
	// re-added when maximizing or moving the window. (Like "last-floating".)
	delete(c.states, name)

	// If the state calls for maximization, maximize the client and be done.
	if s.maximized {
		c.maximize()
		return
	}

	// Finally, if we're here and the client isn't being moved/resized, then
	// we can revert to the geometry specified by the state, adjusted for the
	// head geometry used when capturing that state.
	if c.frame.Moving() || c.frame.Resizing() {
		return
	}

	// We also need to check if the client has just moved via its layout.
	// If so, don't continue.
	if c.moving || c.resizing {
		return
	}

	if s.headGeom != nil && c.workspace.HeadGeom() != s.headGeom {
		s.geom = heads.Convert(s.geom, s.headGeom, c.workspace.HeadGeom())
	}
	c.LayoutMoveResize(s.geom.X(), s.geom.Y(),
		s.geom.Width(), s.geom.Height())
}