示例#1
0
文件: state.go 项目: pascience/foci
func WorkspaceToHead(headIndex int, wrk *workspace.Workspace) {
	if headIndex == Heads.VisibleIndex(wrk) {
		return
	}

	// If headIndex is the currently active head, then just activate 'wrk'
	// greedily.
	if headIndex == Heads.VisibleIndex(Workspace()) {
		SetWorkspace(wrk, true)
		return
	}

	// Now we know that we're setting the workspace of a head that isn't
	// active. The last special case to check for is whether the workspace
	// we're setting is the currently activate workspace. If it is, then we
	// simply activate the workspace at headIndex greedily.
	if wrk.IsActive() {
		Heads.WithVisibleWorkspace(headIndex, func(w *workspace.Workspace) {
			SetWorkspace(w, true)
		})
		return
	}

	// Finally, we can just swap workspaces now without worrying about the
	// active workspace changing.
	Heads.WithVisibleWorkspace(headIndex, func(w *workspace.Workspace) {
		Heads.SwitchWorkspaces(wrk, w)
	})
	ewmhVisibleDesktops()
	ewmhCurrentDesktop()
	Heads.EwmhWorkarea()
}