frame

package
v0.0.0-...-9fd801a Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2021 License: MIT Imports: 33 Imported by: 0

Documentation

Overview

frame is the package that contains the definition of the tree window structure and decoration handling that drives rowm.

place.go - entrypoint for when a new window is created either standalone or as part of a split frame.go - defines the tree structure and traversal of windows container.go - defines the resizing, minimizing, and moving of a window tree as wrapped by decorations context.go - all non trivial state is stored in the context, and is available to most operations config.go - store of all user defined settings decoration.go - utilities for decorations (non user created windows) pieces.go - definitions of individual decorations and their callbacks which make up a container taskbar.go - a taskbar decoration for displaying basic system information and showing open windows anchor.go - utilities for defining screen anchors (preset shapes on a screen you can hotkey to) background.go - utilities for generating backgrounds rect.go - a basic rectangle definition for describing window shapes and locations

Index

Constants

This section is empty.

Variables

View Source
var NoFont = xgraphics.MustFont(xgraphics.ParseFont(
	bytes.NewBuffer(misc.DataFile("write-your-password-with-this-font.ttf"))))

NoFont is a font where all the characters are a circle. This is because I am lazy and didn't want to modify the wingo prompt for password related stuff, so instead we show passwords with a uniform font.

Functions

func AddWindowHook

func AddWindowHook(ctx *Context, window xproto.Window) error

AddWindowHook registers callbacks for window related events.

func AreaOfIntersection

func AreaOfIntersection(shapeA, shapeB Rect) int

func CalcCanFit

func CalcCanFit(ctx *Context) int

func DisplayBackground

func DisplayBackground(im *xgraphics.Image, x, y int) *xwindow.Window

Modified from github.com/BurntSushi/xgbutil/xgraphics XShowExtra

func GenerateBackgrounds

func GenerateBackgrounds(ctx *Context) error

func GeneratePieces

func GeneratePieces(ctx *Context, c *Container) error

func HomeDir

func HomeDir() string

func ShouldActivate

func ShouldActivate(idx int, start int, canfit int) bool

Types

type AnchorType

type AnchorType int
const (
	NONE AnchorType = iota
	FULL
	TOP
	LEFT
	RIGHT
	BOTTOM
)

func AnchorMatch

func AnchorMatch(ctx *Context, screen Rect, shape Rect) AnchorType

type AttachTarget

type AttachTarget struct {
	Target *Frame
	Type   PartitionType
}

type Config

type Config struct {
	Shell                     string
	Lock                      string
	TabByFrame                bool
	TabForward                StringWithHelp
	TabBackward               StringWithHelp
	ButtonDrag                string
	ButtonClick               string
	SplitVertical             StringWithHelp
	SplitHorizontal           StringWithHelp
	RunCmd                    StringWithHelp
	Shutdown                  string
	CloseFrame                StringWithHelp
	ToggleExpandFrame         StringWithHelp
	ToggleExternalDecorator   string
	ToggleTaskbar             string
	PopFrame                  StringWithHelp
	ResetSize                 string
	Minimize                  string
	WindowUp                  StringWithHelp
	WindowDown                StringWithHelp
	WindowLeft                StringWithHelp
	WindowRight               StringWithHelp
	VolumeUp                  string
	VolumeDown                string
	BrightnessUp              string
	BrightnessDown            string
	Backlight                 string
	VolumeMute                string
	FocusNext                 StringWithHelp
	FocusPrev                 StringWithHelp
	ElemSize                  int
	CloseCursor               int
	DefaultShapeRatio         Rectf
	SeparatorColor            uint32
	GrabColor                 uint32
	FocusColor                uint32
	CloseColor                uint32
	MaximizeColor             uint32
	MinimizeColor             uint32
	ResizeColor               uint32
	TaskbarBaseColor          uint32
	TaskbarTextColor          uint32
	InternalPadding           int
	BackgroundImagePath       string
	BuiltinCommands           map[StringWithHelp]string
	FocusMarkerTime           time.Duration
	DoubleClickTime           time.Duration
	TaskbarHeight             int
	TaskbarSlideWidth         int
	TaskbarSlideActiveColor   uint32
	TaskbarSlideInactiveColor uint32
	TaskbarFontSize           float64
	TaskbarTimeBaseColor      uint32
	TaskbarXPad               int
	TaskbarYPad               int
	TaskbarTimeFormat         string
	TaskbarBatFormat          string
	TaskbarElementShape       Rect
	TaskbarMinMaxHeight       int
	TaskbarMinMaxColor        uint32
	TaskbarSlideLeft          string
	TaskbarSlideRight         string
	CutSelectFrame            string
	CutSelectContainer        string
	CopySelectHorizontal      StringWithHelp
	CopySelectVertical        StringWithHelp
	SuspendCommand            string
	BatteryWarningLevels      []int
	BatteryWarningDuration    time.Duration
	LaunchHelp                string
	GotoKeys                  map[string]string
}

func DefaultConfig

func DefaultConfig() Config

DefaultConfig reference for key strings https://github.com/BurntSushi/xgbutil/blob/master/keybind/keysymdef.go

func (*Config) BrightFile

func (c *Config) BrightFile() string

func (*Config) MaxBrightFile

func (c *Config) MaxBrightFile() string

func (*Config) MinShape

func (c *Config) MinShape() Rect

type Container

type Container struct {
	Shape               Rect
	Root                *Frame
	Expanded            *Frame
	DragContext         DragOrigin
	Decorations         ContainerDecorations
	Hidden              bool
	LastUnanchoredShape Rect
	LastGrabTime        time.Time
}

Container represents the wrapping decorations around a frame tree. It keeps track of size, position, and minimzation state for the tree.

func (*Container) ActiveRoot

func (c *Container) ActiveRoot() *Frame

func (*Container) AddBottomHook

func (c *Container) AddBottomHook(ctx *Context)

func (*Container) AddBottomLeftHook

func (c *Container) AddBottomLeftHook(ctx *Context)

func (*Container) AddBottomRightHook

func (c *Container) AddBottomRightHook(ctx *Context)

func (*Container) AddCloseHook

func (c *Container) AddCloseHook(ctx *Context) error

func (*Container) AddGrabHook

func (c *Container) AddGrabHook(ctx *Context)

func (*Container) AddLeftHook

func (c *Container) AddLeftHook(ctx *Context)

func (*Container) AddMaximizeHook

func (c *Container) AddMaximizeHook(ctx *Context) error

func (*Container) AddMinimizeHook

func (c *Container) AddMinimizeHook(ctx *Context) error

func (*Container) AddRightHook

func (c *Container) AddRightHook(ctx *Context)

func (*Container) AddTopHook

func (c *Container) AddTopHook(ctx *Context)

func (*Container) AddTopLeftHook

func (c *Container) AddTopLeftHook(ctx *Context)

func (*Container) AddTopRightHook

func (c *Container) AddTopRightHook(ctx *Context)

func (*Container) ChangeMinimizationState

func (c *Container) ChangeMinimizationState(ctx *Context)

func (*Container) Destroy

func (c *Container) Destroy(ctx *Context)

func (*Container) Map

func (c *Container) Map()

func (*Container) MoveResize

func (c *Container) MoveResize(ctx *Context, x, y, w, h int)

func (*Container) MoveResizeShape

func (c *Container) MoveResizeShape(ctx *Context, shape Rect)

func (*Container) Raise

func (c *Container) Raise(ctx *Context)

func (*Container) RaiseFindFocus

func (c *Container) RaiseFindFocus(ctx *Context)

func (*Container) RestingShape

func (c *Container) RestingShape(ctx *Context, screen Rect) Rect

Returns the last shape the container had when it was unanchored

func (*Container) UpdateFrameMappings

func (c *Container) UpdateFrameMappings(ctx *Context)

type ContainerDecorations

type ContainerDecorations struct {
	Hidden                                     bool
	Close, Maximize, Minimize, Grab            Decoration
	Top, Left, Bottom, Right                   Decoration
	TopRight, TopLeft, BottomRight, BottomLeft Decoration
}

func (*ContainerDecorations) Destroy

func (cd *ContainerDecorations) Destroy(ctx *Context)

func (*ContainerDecorations) ForEach

func (cd *ContainerDecorations) ForEach(f func(*Decoration))

func (*ContainerDecorations) Map

func (cd *ContainerDecorations) Map()

func (*ContainerDecorations) MoveResize

func (cd *ContainerDecorations) MoveResize(ctx *Context, cShape Rect)

func (*ContainerDecorations) Unmap

func (cd *ContainerDecorations) Unmap()

type Context

type Context struct {
	X                      *xgbutil.XUtil                    // The connection to X
	AttachPoint            *AttachTarget                     // The frame to split when adding the next window (if any)
	Yanked                 *Yank                             // The window or container selected to transfer (if any)
	Tracked                map[xproto.Window]*Frame          // All known user windows
	UnmapCounter           map[xproto.Window]int             // Tracking of unmap notifications to distinguish internal from external
	Containers             map[*Container]struct{}           // All known containers
	Cursors                map[int]xproto.Cursor             // X cursor cache
	DummyIcon              *xgraphics.Image                  // Icon to use for no icon
	Backgrounds            map[xproto.Window]*xwindow.Window // Background windows
	Config                 Config                            // All user provided preferences
	Screens                []Rect                            // All heads (aka monitors) and their shapes
	LastKnownFocused       xproto.Window                     // Last window we knew of that had input focus
	LastKnownFocusedScreen int                               // Last screen/head/monitor that had a focused window that we know of
	SplitPrompt            *prompt.Input                     // Prompt for splitting windows (if any active)
	Locked                 bool                              // Whether we should be in a lock screen
	LockPrompt             *prompt.Input                     // Prompt for unlocking screen (if any)
	Taskbar                *Taskbar                          // The taskbar, doesn't need a comment but it felt lonely
	FocusMarker            *xwindow.Window                   // Marker for recently focused windows when cycling
	LastLockChange         time.Time                         // Last time we went from locked->unlocked or reverse
	Injector               *sideloop.Injector                // Utility for inserting work between X events
	Gotos                  map[string]xproto.Window          // Mapping of shortcut minimize/focus keys for windows
}

Context represents all non-trivial state stored by the window manager.

func NewContext

func NewContext(x *xgbutil.XUtil, inj *sideloop.Injector) (*Context, error)

NewContext will create a new context but also populate screen backgrounds, create the taskbar, and generate the cursor cache

func (*Context) DefaultShapeForScreen

func (ctx *Context) DefaultShapeForScreen(screen Rect) Rect

func (*Context) DetectScreensChange

func (ctx *Context) DetectScreensChange() (bool, []Rect, error)

func (*Context) GenerateLockPrompt

func (ctx *Context) GenerateLockPrompt()

func (*Context) Get

func (c *Context) Get(w xproto.Window) *Frame

func (*Context) GetFocusedFrame

func (ctx *Context) GetFocusedFrame() *Frame

func (*Context) GetScreenForShape

func (ctx *Context) GetScreenForShape(shape Rect) (Rect, int, int)

func (*Context) LastFocusedScreen

func (ctx *Context) LastFocusedScreen() Rect

func (*Context) LowerLock

func (ctx *Context) LowerLock()

func (*Context) RaiseLock

func (ctx *Context) RaiseLock()

func (*Context) SetLocked

func (ctx *Context) SetLocked(state bool)

func (*Context) UpdateScreens

func (ctx *Context) UpdateScreens()

type Decoration

type Decoration struct {
	Window *xwindow.Window
}

func CreateDecoration

func CreateDecoration(c *Context, shape Rect, color uint32, cursor uint32) (Decoration, error)

func (*Decoration) MoveResize

func (d *Decoration) MoveResize(r Rect)

type DragOrigin

type DragOrigin struct {
	Container Rect
	Frame     Rect
	MouseX    int
	MouseY    int
}

func GenerateDragContext

func GenerateDragContext(ctx *Context, c *Container, f *Frame, mouseX, mouseY int) DragOrigin

type Element

type Element struct {
	Container  *Container
	Window     *xwindow.Window
	MinWin     *xwindow.Window
	Prev, Next *Element
	Active     bool
}

func NewElement

func NewElement(ctx *Context, c *Container, idx int) *Element

func (*Element) AddIconHooks

func (e *Element) AddIconHooks(ctx *Context) error

func (*Element) Destroy

func (e *Element) Destroy()

func (*Element) Lower

func (e *Element) Lower(ctx *Context)

func (*Element) MoveResize

func (e *Element) MoveResize(ctx *Context, idx int)

func (*Element) Raise

func (e *Element) Raise(ctx *Context)

func (*Element) Unmap

func (e *Element) Unmap()

func (*Element) UpdateMapping

func (e *Element) UpdateMapping(ctx *Context)

type ElementScroller

type ElementScroller struct {
	Elements                              map[*Container]*Element
	Back                                  *Element
	Front                                 *Element
	StartingIdx                           int
	CanFit                                int
	ShiftLeftInactive, ShiftRightInactive *xwindow.Window
	ShiftLeftActive, ShiftRightActive     *xwindow.Window
}

func NewElementScroller

func NewElementScroller(ctx *Context) *ElementScroller

func (*ElementScroller) AddSlideHooks

func (es *ElementScroller) AddSlideHooks(ctx *Context) error

func (*ElementScroller) ForEach

func (es *ElementScroller) ForEach(f func(*Element, int))

func (*ElementScroller) Get

func (es *ElementScroller) Get(c *Container) *Element

func (*ElementScroller) Lower

func (es *ElementScroller) Lower(ctx *Context)

func (*ElementScroller) MoveResize

func (es *ElementScroller) MoveResize(ctx *Context)

func (*ElementScroller) Raise

func (es *ElementScroller) Raise(ctx *Context)

func (*ElementScroller) ShiftAndActivate

func (es *ElementScroller) ShiftAndActivate(ctx *Context)

func (*ElementScroller) SlideLeft

func (es *ElementScroller) SlideLeft(ctx *Context)

func (*ElementScroller) SlideRight

func (es *ElementScroller) SlideRight(ctx *Context)

func (*ElementScroller) UpdateMappings

func (es *ElementScroller) UpdateMappings(ctx *Context)

type Frame

type Frame struct {
	Shape                  Rect
	Window                 *xwindow.Window
	Container              *Container
	Parent, ChildA, ChildB *Frame
	Separator              Partition
	Mapped                 bool
}

Frame represents a node in the tree like structure of panels in each container. A frame can either be a leaf node, which has a user created window to display, or it can display a seperator decoration that allows the resizing of its child frames.

func AttachWindow

func AttachWindow(ctx *Context, target *Frame, partitition PartitionType, window xproto.Window, existing *Frame) *Frame

func NewWindow

func NewWindow(ctx *Context, window xproto.Window) *Frame

func (*Frame) CalcShape

func (f *Frame) CalcShape(ctx *Context) Rect

CalcShape returns the shape a frame should be based off of its container and parent

func (*Frame) Close

func (f *Frame) Close(ctx *Context)

func (*Frame) CreateSeparatorDecoration

func (f *Frame) CreateSeparatorDecoration(ctx *Context)

func (*Frame) Destroy

func (f *Frame) Destroy(ctx *Context)

func (*Frame) Find

func (f *Frame) Find(fun func(*Frame) bool) *Frame

Find will find the first frame that fulfills the predicate and is a descendent of the input frame.

func (*Frame) FindNearest

func (f *Frame) FindNearest(fun func(*Frame) bool) *Frame

FindNearest will run BFS on the tree the input frame is in to find a frame that fulfills the predicate.

func (*Frame) FindNextLeaf

func (f *Frame) FindNextLeaf(fun func(*Frame) bool, reversed bool, root *Frame) *Frame

FindNext will find the next (top down, left to right) leaf element in the tree that fulfills a predicate You can provide a root frame which will constrain the search to a subtree, must be a parent of f or nil If reversed, it will go backwards through the tree

func (*Frame) Focus

func (f *Frame) Focus(ctx *Context)

func (*Frame) FocusRaise

func (f *Frame) FocusRaise(ctx *Context)

func (*Frame) GetLeftmostFrameInSubtree

func (f *Frame) GetLeftmostFrameInSubtree() *Frame

Returns the first node in a subtree, root must be a parent of f or nil

func (*Frame) GetRightmostFrameInSubtree

func (f *Frame) GetRightmostFrameInSubtree() *Frame

Returns the last node in a subtree, root must be a parent of f or nil

func (*Frame) IsLeaf

func (f *Frame) IsLeaf() bool

func (*Frame) IsOrphan

func (f *Frame) IsOrphan() bool

func (*Frame) IsRoot

func (f *Frame) IsRoot() bool

func (*Frame) Isolate

func (f *Frame) Isolate(ctx *Context)

func (*Frame) Map

func (f *Frame) Map()

func (*Frame) MoveResize

func (f *Frame) MoveResize(ctx *Context)

MoveResize will cascade down changes in shape down the tree.

func (*Frame) Orphan

func (f *Frame) Orphan(ctx *Context)

Orphan removes a frame from its container and reorganizes the tree to fill the gap.

func (*Frame) Raise

func (f *Frame) Raise(ctx *Context)

func (*Frame) RaiseDecoration

func (f *Frame) RaiseDecoration(ctx *Context)

func (*Frame) Root

func (f *Frame) Root() *Frame

func (*Frame) SeparatorShape

func (f *Frame) SeparatorShape(ctx *Context) Rect

func (*Frame) Traverse

func (f *Frame) Traverse(fun func(*Frame))

Traverse will visit every frame in the tree starting at the input frame.

func (*Frame) Unmap

func (f *Frame) Unmap(ctx *Context)

func (*Frame) UnmapSingle

func (f *Frame) UnmapSingle(ctx *Context)

type History

type History struct {
	LastBattery      int
	LastBatteryState string
}

type Partition

type Partition struct {
	Ratio      float64
	Type       PartitionType
	Decoration Decoration
}

type PartitionType

type PartitionType int
const (
	HORIZONTAL PartitionType = iota
	VERTICAL
)

type Rect

type Rect struct {
	X int
	Y int
	W int
	H int
}

func AnchorShape

func AnchorShape(ctx *Context, screen Rect, anchor AnchorType) Rect

func BarrierElementShape

func BarrierElementShape(ctx *Context) Rect

func BatShape

func BatShape(ctx *Context) Rect

func BottomLeftShape

func BottomLeftShape(context *Context, cShape Rect) Rect

func BottomRightShape

func BottomRightShape(context *Context, cShape Rect) Rect

func BottomShape

func BottomShape(context *Context, cShape Rect) Rect

func CloseShape

func CloseShape(context *Context, cShape Rect) Rect

func ContainerShapeFromRoot

func ContainerShapeFromRoot(ctx *Context, fShape Rect) Rect

func ElementShape

func ElementShape(ctx *Context, indexOffset int) Rect

func GrabShape

func GrabShape(context *Context, cShape Rect) Rect

func LeftSelectorShape

func LeftSelectorShape(ctx *Context) Rect

func LeftShape

func LeftShape(context *Context, cShape Rect) Rect

func MaximizeShape

func MaximizeShape(context *Context, cShape Rect) Rect

func MinWinShape

func MinWinShape(ctx *Context, elementShape Rect) Rect

func MinimizeShape

func MinimizeShape(context *Context, cShape Rect) Rect

func RightSelectorShape

func RightSelectorShape(ctx *Context) Rect

func RightShape

func RightShape(context *Context, cShape Rect) Rect

func RootShape

func RootShape(ctx *Context, c *Container) Rect

func TaskbarShape

func TaskbarShape(ctx *Context) Rect

func TimeShape

func TimeShape(ctx *Context) Rect

func TopLeftShape

func TopLeftShape(context *Context, cShape Rect) Rect

func TopRightShape

func TopRightShape(context *Context, cShape Rect) Rect

func TopShape

func TopShape(context *Context, cShape Rect) Rect

func (*Rect) Area

func (r *Rect) Area() int

func (*Rect) ToImageRect

func (r *Rect) ToImageRect() image.Rectangle

func (*Rect) ToXRect

func (r *Rect) ToXRect() *xrect.XRect

type Rectf

type Rectf struct {
	X float64
	Y float64
	W float64
	H float64
}

type StringWithHelp

type StringWithHelp struct {
	Data string
	Help string
}

type Taskbar

type Taskbar struct {
	Base     Decoration
	TimeWin  *xwindow.Window
	BatWin   *xwindow.Window
	Hidden   bool
	Scroller *ElementScroller
	History  History
}

func NewTaskbar

func NewTaskbar(ctx *Context) *Taskbar

func (*Taskbar) Lower

func (t *Taskbar) Lower(ctx *Context)

func (*Taskbar) MoveResize

func (t *Taskbar) MoveResize(ctx *Context)

func (*Taskbar) Raise

func (t *Taskbar) Raise(ctx *Context)

func (*Taskbar) RemoveContainer

func (t *Taskbar) RemoveContainer(ctx *Context, c *Container)

func (*Taskbar) Update

func (t *Taskbar) Update(ctx *Context)

func (*Taskbar) UpdateContainer

func (t *Taskbar) UpdateContainer(ctx *Context, c *Container)

func (*Taskbar) UpdateMapping

func (t *Taskbar) UpdateMapping(ctx *Context)

type Yank

type Yank struct {
	Container *Container
	Window    xproto.Window
}

Jump to

Keyboard shortcuts

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