本文整理匯總了Golang中github.com/BurntSushi/wingo/workspace.Workspace.RemoveAllAndAdd方法的典型用法代碼示例。如果您正苦於以下問題:Golang Workspace.RemoveAllAndAdd方法的具體用法?Golang Workspace.RemoveAllAndAdd怎麽用?Golang Workspace.RemoveAllAndAdd使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/BurntSushi/wingo/workspace.Workspace
的用法示例。
在下文中一共展示了Workspace.RemoveAllAndAdd方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: RemoveWorkspace
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) {
return
}
// There's a bit of complexity in choosing where to move the clients to.
// Namely, if we're removing a hidden workspace, it's a simple matter of
// moving the clients. However, if we're removing a visible workspace,
// we have to make sure to make another workspace that is hidden take
// its place. (Such a workspace is guaranteed to exist because we have at
// least one more workspace than there are active physical heads.)
if !wk.IsVisible() {
moveClientsTo := hds.workspaces.Wrks[len(hds.workspaces.Wrks)-1]
if moveClientsTo == wk {
moveClientsTo = hds.workspaces.Wrks[len(hds.workspaces.Wrks)-2]
}
wk.RemoveAllAndAdd(moveClientsTo)
} else {
// Find the last-most hidden workspace that is not itself.
for i := len(hds.workspaces.Wrks) - 1; i >= 0; i-- {
work := hds.workspaces.Wrks[i]
if work != wk && !work.IsVisible() {
hds.SwitchWorkspaces(wk, work)
wk.RemoveAllAndAdd(work)
break
}
}
}
hds.workspaces.Remove(wk)
}