workspace

package
v0.0.0-...-5f9e87e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 26, 2020 License: BSD-3-Clause Imports: 10 Imported by: 4

Documentation

Overview

Package workspace is responsible for maintaining the state for the workspaces used in Wingo. It's responsible for showing or hiding a workspace, activating a workspace, adding/removing workspaces, adding clients to workspaces, and managing the state of all layouts for each workspace.

Heads

Most of the invariants surrounding attached physical heads are maintained in the heads package. Chief among these invariants: 1) There must be at least as many workspaces as there are heads. 2) There must be precisely N visible workspaces where N is the number of active physical heads. 3) There must always be one and only one active workspace.

The heads package maintains these invariants by 1) adding workspaces when there aren't enough, 2) showing/hiding workspaces as appropriate the number of active physical heads has changed, and 3) checking to make sure one workspace is active after the number of physical heads has changed and being the only one responsible for "switching" workspaces.

Namely, information about which workspace is active and which are visible/hidden is maintained in the heads package.

Layout

Every layout is responsible for maintaining a list of clients that *may* use that particular layout to be placed. In essence, this allows quick access to all clients in a particular layout for a single workspace.

The list contains clients that *may* be in the particular layout because a client's layout is determined by two factors: 1) if a client *must* not be tiled, it will always use a floating layout and 2) the client's layout is the default layout currently in use by the client's workspace.

Since a layout only maintains a list of potential clients, it is possible to allow layouts to maintain state even when they are not active. That is, when a workspace is in tiling mode, there could be clients in that workspace's floating layout that are currently being tiled. So that if a floating layout needs to access all of its clients, one could do:

for _, client := range floatingLayout.clients {
	if _, ok := client.Layout().(layout.Floater); ok {
		// client is currently part of floatingLayout
	}
}

For tiling layouts, this works a little differently since clients can only be in a tiling layout if they aren't forced into a floating layout. Thus, clients in a tiling layout's state can always be assumed to be using that tiler as a layout.

This last point is only possible because layouts are not responsible for knowing whether they are "active" or not. The workspace manages the activity of layouts, and knows when to call "Place" on any particular layout.

(Note that iconified clients are removed from all layouts.)

Index

Constants

View Source
const (
	Floating = iota
	AutoTiling
	ManualTiling
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Id() xproto.Window
	String() string
	Workspace() Workspacer
	WorkspaceSet(wrk Workspacer)
	Layout() layout.Layout
	Map()
	Unmap()
	ShouldForceFloating() bool
	Focus()
	Raise()
	Geom() xrect.Rect
	DragGeom() xrect.Rect

	Iconified() bool
	IconifiedSet(iconified bool)
	IsSticky() bool
	IsActive() bool

	HasState(name string) bool
	SaveState(name string)
	CopyState(src, dest string)
	LoadState(name string)
	DeleteState(name string)

	MROpt(validate bool, flags, x, y, width, height int)
	MoveResize(x, y, width, height int)
	MoveResizeValid(x, y, width, height int)
	Move(x, y int)
	Resize(validate bool, width, height int)

	FrameTile()
}

type Heads

type Heads interface {
	ActiveWorkspace() *Workspace
	VisibleWorkspaces() []*Workspace
	IsActive(wrk *Workspace) bool
	Geom(wrk *Workspace) xrect.Rect
	HeadGeom(wrk *Workspace) xrect.Rect

	ActivateWorkspace(wrk *Workspace)
	SwitchWorkspaces(wrk1, wrk2 *Workspace)
}

type SelectData

type SelectData struct {
	Selected    func(wrk *Workspace)
	Highlighted func(wrk *Workspace)
}

type Sticky

type Sticky struct {
	X *xgbutil.XUtil
	// contains filtered or unexported fields
}

func (*Sticky) Add

func (wrk *Sticky) Add(c Client)

func (*Sticky) Geom

func (wrk *Sticky) Geom() xrect.Rect

func (*Sticky) HeadGeom

func (wrk *Sticky) HeadGeom() xrect.Rect

func (*Sticky) IconifyToggle

func (wrk *Sticky) IconifyToggle(c Client)

func (*Sticky) IsActive

func (wrk *Sticky) IsActive() bool

func (*Sticky) IsVisible

func (wrk *Sticky) IsVisible() bool

func (*Sticky) Layout

func (wrk *Sticky) Layout(c Client) layout.Layout

func (*Sticky) LayoutName

func (wrk *Sticky) LayoutName() string

func (*Sticky) Remove

func (wrk *Sticky) Remove(c Client)

func (*Sticky) String

func (wrk *Sticky) String() string

type Workspace

type Workspace struct {
	X *xgbutil.XUtil

	Name    string
	State   int
	Clients []Client

	PromptSlctGroup *prompt.SelectGroupItem
	PromptSlctItem  *prompt.SelectItem
	// contains filtered or unexported fields
}

func (*Workspace) Activate

func (wrk *Workspace) Activate(greedy bool)

func (*Workspace) Add

func (wrk *Workspace) Add(c Client)

func (*Workspace) AutoCycle

func (wrk *Workspace) AutoCycle()

func (*Workspace) CheckFloatingStatus

func (wrk *Workspace) CheckFloatingStatus(c Client)

CheckFloatingStatus queries the Floating method of a client, and if it's different than what the workspace believes it should be, the proper state transition will be invoked. Namely, if Client.Floating is true, but workspace thinks it's false, the workspace will remove it from its list of tilable clients and re-tile. Otherwise, if Client.Floating is false, but workspace thinks it's true, the workspace will add the client to its list of tilable clients and re-tile.

func (*Workspace) Destroy

func (wrk *Workspace) Destroy()

func (*Workspace) Geom

func (wrk *Workspace) Geom() xrect.Rect

func (*Workspace) HeadGeom

func (wrk *Workspace) HeadGeom() xrect.Rect

func (*Workspace) Hide

func (wrk *Workspace) Hide()

func (*Workspace) IconifyToggle

func (wrk *Workspace) IconifyToggle(c Client)

func (*Workspace) IsActive

func (wrk *Workspace) IsActive() bool

func (*Workspace) IsVisible

func (wrk *Workspace) IsVisible() bool

func (*Workspace) Layout

func (wrk *Workspace) Layout(c Client) layout.Layout

func (*Workspace) LayoutAutoTiler

func (wrk *Workspace) LayoutAutoTiler() layout.AutoTiler

func (*Workspace) LayoutFloater

func (wrk *Workspace) LayoutFloater() layout.Floater

func (*Workspace) LayoutName

func (wrk *Workspace) LayoutName() string

func (*Workspace) LayoutStateSet

func (wrk *Workspace) LayoutStateSet(state int)

func (*Workspace) Place

func (wrk *Workspace) Place()

func (*Workspace) Remove

func (wrk *Workspace) Remove(c Client)

func (*Workspace) RemoveAllAndAdd

func (wrk *Workspace) RemoveAllAndAdd(newWk *Workspace)

func (*Workspace) Rename

func (wrk *Workspace) Rename(newName string)

func (*Workspace) SelectGroupText

func (wrk *Workspace) SelectGroupText() string

func (*Workspace) SelectHighlighted

func (wrk *Workspace) SelectHighlighted(data interface{})

func (*Workspace) SelectSelected

func (wrk *Workspace) SelectSelected(data interface{})

func (*Workspace) SelectText

func (wrk *Workspace) SelectText() string

func (*Workspace) SetLayout

func (wrk *Workspace) SetLayout(name string)

func (*Workspace) Show

func (wrk *Workspace) Show()

func (*Workspace) String

func (wrk *Workspace) String() string

type Workspacer

type Workspacer interface {
	String() string
	LayoutName() string
	Geom() xrect.Rect
	HeadGeom() xrect.Rect
	IsActive() bool
	IsVisible() bool
	Add(c Client)
	Remove(c Client)
	IconifyToggle(c Client)
	Layout(c Client) layout.Layout
}

type Workspaces

type Workspaces struct {
	X    *xgbutil.XUtil
	Wrks []*Workspace
	// contains filtered or unexported fields
}

func NewWorkspaces

func NewWorkspaces(
	X *xgbutil.XUtil, heads Heads, defaultLayout string) *Workspaces

func (*Workspaces) Active

func (wrks *Workspaces) Active() *Workspace

func (*Workspaces) Add

func (wrks *Workspaces) Add(wrk *Workspace)

Add adds a new workspace to the set. Add will panic if a workspace with the same case-insensitive name as wrk already exists. Add will also panic if the workspace has a zero-length name.

func (*Workspaces) Find

func (wrks *Workspaces) Find(name string) *Workspace

func (*Workspaces) Get

func (wrks *Workspaces) Get(i int) *Workspace

func (*Workspaces) NewSticky

func (wrks *Workspaces) NewSticky() *Sticky

func (*Workspaces) NewWorkspace

func (wrks *Workspaces) NewWorkspace(name string) *Workspace

func (*Workspaces) Remove

func (wrks *Workspaces) Remove(wrk *Workspace)

func (*Workspaces) Visibles

func (wrks *Workspaces) Visibles() []*Workspace

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL