Package heads

import "github.com/BurntSushi/wingo/heads"
Overview
Index

Overview ▾

package heads manages state and geometry information for each physical active head detected by Xinerama. This package is also responsible for tracking which workspaces are visible and which are hidden.

Index ▾

func Convert(rect, src, dest xrect.Rect) xrect.Rect
type Client
type Clients
type Heads
    func NewHeads(X *xgbutil.XUtil, defaultLayout string) *Heads
    func (hds *Heads) ActivateWorkspace(wk *workspace.Workspace)
    func (hds *Heads) ActiveWorkspace() *workspace.Workspace
    func (hds *Heads) AddWorkspace(wk *workspace.Workspace)
    func (hds *Heads) ApplyStruts(clients Clients)
    func (hds *Heads) EwmhWorkarea()
    func (hds *Heads) FindMostOverlap(needle xrect.Rect) *workspace.Workspace
    func (hds *Heads) Geom(wrk *workspace.Workspace) xrect.Rect
    func (hds *Heads) GlobalIndex(wkNeedle *workspace.Workspace) int
    func (hds *Heads) HeadGeom(wrk *workspace.Workspace) xrect.Rect
    func (hds *Heads) Initialize(clients Clients)
    func (hds *Heads) IsActive(wrk *workspace.Workspace) bool
    func (hds *Heads) NewWorkspace(name string) *workspace.Workspace
    func (hds *Heads) NextWorkspace() *workspace.Workspace
    func (hds *Heads) NumConnected() int
    func (hds *Heads) NumHeads() int
    func (hds *Heads) PrevWorkspace() *workspace.Workspace
    func (hds *Heads) Reload(clients Clients)
    func (hds *Heads) RemoveWorkspace(wk *workspace.Workspace)
    func (hds *Heads) SwitchWorkspaces(wk1, wk2 *workspace.Workspace)
    func (hds *Heads) VisibleIndex(wk *workspace.Workspace) int
    func (hds *Heads) VisibleWorkspaces() []*workspace.Workspace
    func (hds *Heads) WithVisibleWorkspace(i int, f func(w *workspace.Workspace))

Package files

client.go doc.go heads.go workspace.go

func Convert

func Convert(rect, src, dest xrect.Rect) xrect.Rect

Convert takes a source and a destination rect, along with a rect in the source's rectangle, and returns a new rect translated into the destination rect.

type Client

type Client interface {
    Id() xproto.Window
    IsMaximized() bool
    Remaximize()
}

type Clients

type Clients interface {
    Get(i int) Client
    Len() int
}

type Heads

type Heads struct {
    X *xgbutil.XUtil

    Workspaces *workspace.Workspaces // Slice of all available workspaces.
    // contains filtered or unexported fields
}

func NewHeads

func NewHeads(X *xgbutil.XUtil, defaultLayout string) *Heads

func (*Heads) ActivateWorkspace

func (hds *Heads) ActivateWorkspace(wk *workspace.Workspace)

ActivateWorkspace will "focus" or "activate" the workspace provided. This only works when "wk" is visible. To activate a hidden workspace, please use SwitchWorkspaces.

func (*Heads) ActiveWorkspace

func (hds *Heads) ActiveWorkspace() *workspace.Workspace

func (*Heads) AddWorkspace

func (hds *Heads) AddWorkspace(wk *workspace.Workspace)

func (*Heads) ApplyStruts

func (hds *Heads) ApplyStruts(clients Clients)

func (*Heads) EwmhWorkarea

func (hds *Heads) EwmhWorkarea()

EwmhWorkarea sets the _NET_WORKAREA property. Generally, this property doesn't make much sense since multiple workspaces can be viewable at one time, and each workspace might have different workareas.

However, if the EWMH is read loosely, we can update _NET_WORKAREA not just when the struts change, but also when the configuration of visible workspaces changes. Namely, only the visible workspaces have a valid geometry set in _NET_WORKAREA, while the rest are zeroed out.

N.B. Fuck that. This interpretation of _NET_WORKAREA makes KDE go absolutely bonkers. I'm not sure if there is another sensible interpretation, so just don't set it.

func (*Heads) FindMostOverlap

func (hds *Heads) FindMostOverlap(needle xrect.Rect) *workspace.Workspace

func (*Heads) Geom

func (hds *Heads) Geom(wrk *workspace.Workspace) xrect.Rect

func (*Heads) GlobalIndex

func (hds *Heads) GlobalIndex(wkNeedle *workspace.Workspace) int

func (*Heads) HeadGeom

func (hds *Heads) HeadGeom(wrk *workspace.Workspace) xrect.Rect

func (*Heads) Initialize

func (hds *Heads) Initialize(clients Clients)

func (*Heads) IsActive

func (hds *Heads) IsActive(wrk *workspace.Workspace) bool

func (*Heads) NewWorkspace

func (hds *Heads) NewWorkspace(name string) *workspace.Workspace

func (*Heads) NextWorkspace

func (hds *Heads) NextWorkspace() *workspace.Workspace

func (*Heads) NumConnected

func (hds *Heads) NumConnected() int

NumConnected pings the Xinerama extension for a fresh tally of the number of heads currently active.

func (*Heads) NumHeads

func (hds *Heads) NumHeads() int

NumHeads returns the current number of heads that Wingo is using.

func (*Heads) PrevWorkspace

func (hds *Heads) PrevWorkspace() *workspace.Workspace

func (*Heads) Reload

func (hds *Heads) Reload(clients Clients)

func (*Heads) RemoveWorkspace

func (hds *Heads) RemoveWorkspace(wk *workspace.Workspace)

func (*Heads) SwitchWorkspaces

func (hds *Heads) SwitchWorkspaces(wk1, wk2 *workspace.Workspace)

func (*Heads) VisibleIndex

func (hds *Heads) VisibleIndex(wk *workspace.Workspace) int

func (*Heads) VisibleWorkspaces

func (hds *Heads) VisibleWorkspaces() []*workspace.Workspace

func (*Heads) WithVisibleWorkspace

func (hds *Heads) WithVisibleWorkspace(i int, f func(w *workspace.Workspace))

WithVisibleWorkspace takes a head number and a closure and executes the closure safely with the workspace corresponding to head number i.

This approach is necessary for safety, since the user can send commands with arbitrary head numbers. We need to make sure we don't crash if we get an invalid head number.