Пример #1
0
func (hds *Heads) RemoveWorkspace(wk *workspace.Workspace) {
	// Don't allow it if this would result in fewer workspaces than there
	// are active physical heads.
	if len(hds.geom) == len(hds.Workspaces.Wrks) {
		panic("Cannot have fewer workspaces than active monitors.")
	}

	// A non-empty workspace cannot be removed.
	if len(wk.Clients) > 0 {
		panic(fmt.Sprintf("Non-empty workspace '%s' cannot be removed.", wk))
	}

	if wk.IsVisible() {
		// Find the last-most hidden workspace that is not itself and switch.
		for i := len(hds.Workspaces.Wrks) - 1; i >= 0; i-- {
			work := hds.Workspaces.Wrks[i]
			if work != wk && !work.IsVisible() {
				hds.SwitchWorkspaces(wk, work)
				break
			}
		}
	}
	hds.Workspaces.Remove(wk)
}