本文整理匯總了Golang中github.com/BurntSushi/wingo/workspace.Workspace類的典型用法代碼示例。如果您正苦於以下問題:Golang Workspace類的具體用法?Golang Workspace怎麽用?Golang Workspace使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Workspace類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: WorkspaceToHead
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()
}
示例2: SetWorkspace
func SetWorkspace(wrk *workspace.Workspace, greedy bool) {
old := Workspace()
wrk.Activate(greedy)
if old != Workspace() {
FYI("%s", wrk)
}
ewmhCurrentDesktop()
ewmhVisibleDesktops()
Heads.EwmhWorkarea()
}
示例3: RenameWorkspace
func RenameWorkspace(wrk *workspace.Workspace, newName string) error {
if len(newName) == 0 {
return fmt.Errorf("workspaces must have a name of length at least one.")
}
if Heads.Workspaces.Find(newName) != nil {
return fmt.Errorf("a workspace with name '%s' already exists.", newName)
}
wrk.Rename(newName)
ewmhDesktopNames()
return nil
}
示例4: SetWorkspace
func SetWorkspace(wrk *workspace.Workspace, greedy bool) {
mousebind.GrabPointer(X, Root.Id, Root.Id, 0)
old := Workspace()
wrk.Activate(greedy)
if old != Workspace() {
FYI("%s", wrk)
}
ewmhVisibleDesktops()
ewmhCurrentDesktop()
Heads.EwmhWorkarea()
mousebind.UngrabPointer(X)
}
示例5: CheckNewWorkspace
func (c *Client) CheckNewWorkspace() {
var newWrk *workspace.Workspace = nil
curWrk := c.Workspace()
if dragGeom := c.DragGeom(); dragGeom != nil {
newWrk = wm.Heads.FindMostOverlap(dragGeom)
} else {
newWrk = wm.Heads.FindMostOverlap(c.frame.Geom())
}
if newWrk == nil || curWrk == newWrk {
return
}
newWrk.Add(c)
// If this is the active window, switch to this workspace too.
if c.IsActive() {
wm.SetWorkspace(newWrk, false)
}
}
示例6: 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)
}
示例7: 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) {
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)
}
示例8: SwitchWorkspaces
func (hds *Heads) SwitchWorkspaces(wk1, wk2 *workspace.Workspace) {
v1, v2 := hds.visibleIndex(wk1), hds.visibleIndex(wk2)
switch {
case v1 > -1 && v2 > -1:
hds.visibles[v1], hds.visibles[v2] = hds.visibles[v2], hds.visibles[v1]
wk1.Place()
wk2.Place()
case v1 > -1 && v2 == -1:
hds.visibles[v1] = wk2
wk1.Hide()
wk2.Show()
case v1 == -1 && v2 > -1:
hds.visibles[v2] = wk1
wk2.Hide()
wk1.Show()
case v1 == -1 && v2 == -1:
// Meaningless
default:
panic("unreachable")
}
}