wm

package
v0.0.0-...-0455b59 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MouseModeGround indicates unset
	// mousemode (i.e. not selected).
	MouseModeGround = uint8(0)

	// MouseModeMove indicates mouse
	// currently being used to move window.
	MouseModeMove = uint8(1)

	// MouseModeResize indicates mouse
	// currently being used to resize window.
	MouseModeResize = uint8(2)
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Atom

type Atom struct {
	// Atom is the numeric atom ID
	Atom xproto.Atom

	// Name is the string representation of this atom
	Name string
}

func (*Atom) Intern

func (a *Atom) Intern(conn *xgb.XConn, name string) error

Intern fetches this atom with name's ID from X and sets this along with the name.

type Config

type Config struct {
	// MinWindowWidth is the minimum
	// window width (px) to support.
	MinWindowWidth uint32

	// MinWindowHeight is the minimum
	// window height (px) to support.
	MinWindowHeight uint32

	// ScreenPadding is the minimum px of windows
	// to allow on-screen, and the default minimimum
	// px from edges of newly spawned windows.
	ScreenPadding uint32

	// ModKey @TODO
	ModKey uint16

	// KeyBinds @TODO
	KeyBinds KeyBinds
}

type Coord

type Coord struct {
	// X coord in pixels
	// from top-left (0,0).
	X int32

	// Y coord in pixels
	// from top-left (0,0).
	Y int32
}

type Desktop

type Desktop struct {

	// Current
	// workspace.
	Current uint

	// Contained workspaces.
	Workspaces [9]Workspace

	// The randr output
	// this desktop is
	// outputting to.
	Screens []Screen
}

Desktop ...

func (*Desktop) Get

func (d *Desktop) Get() *Workspace

Get returns currently selected workspace.

func (*Desktop) GetIdx

func (d *Desktop) GetIdx(idx uint) *Workspace

GetIdx returns workspace at supplied index.

func (*Desktop) GoTo

func (d *Desktop) GoTo(wm *WM, idx uint)

GoTo will change the current workspace index to given, and toggle layout to redraw.

func (*Desktop) Range

func (d *Desktop) Range(yield func(*Workspace) bool)

Range returns a yield function to range over workspaces in desktop.

func (*Desktop) SendToWorkspace

func (d *Desktop) SendToWorkspace(wm *WM, idx uint) error

SendToWorkspace will send the current focused window to the workspace at index.

type Event

type Event struct {

	// Window is window
	// acted on by event.
	Window xproto.Window

	// Event is actual
	// wrapped X event.
	Event xgb.XEvent
	// contains filtered or unexported fields
}

Event wraps an XEvent to provide easy access to Window ID.

type EventQueue

type EventQueue struct {
	// contains filtered or unexported fields
}

EventQueue is a doubly-linked list of Event objects.

func (*EventQueue) PopBy

func (eq *EventQueue) PopBy(id xproto.Window) *Event

PopBy pops the first Event with given ID from queue, or returns nil.

func (*EventQueue) Push

func (l *EventQueue) Push(elem *Event)

Push pushes the given event to the back of the queue.

type InternedAtoms

type InternedAtoms struct {
	Atom                     Atom
	Supported                Atom
	WMDeleteWindow           Atom
	WMProtocols              Atom
	WMWindowType             Atom
	WMWindowTypeNormal       Atom
	WMWindowTypeDialog       Atom
	WMWindowTypeToolbar      Atom
	WMWindowTypeMenu         Atom
	WMWindowTypePopupMenu    Atom
	WMWindowTypeDropdownMenu Atom
	WMWindowTypeUtility      Atom
	WMWindowTypeSplash       Atom
	WMState                  Atom
}

InternedAtoms is a structure of required interned atoms.

func (*InternedAtoms) InternAll

func (ia *InternedAtoms) InternAll(wm *WM) error

InternAll interns all of the atoms contained within InternedAtoms.

type KeyBind

type KeyBind struct {

	// Mods ...
	Mods uint16

	// Key ...
	Key xproto.Keysym

	// Func ...
	Func func(wm *WM, selected *Window) error
}

KeyBind ...

type KeyBinds

type KeyBinds []KeyBind

KeyBinds ...

func (KeyBinds) Get

func (kbs KeyBinds) Get(mods uint16, key xproto.Keysym) func(*WM, *Window) error

Get ...

type KeyboardMap

type KeyboardMap struct {
	// contains filtered or unexported fields
}

KeyboardMap stores a map of X keycodes to possible keysyms.

func (*KeyboardMap) GetKeycode

func (km *KeyboardMap) GetKeycode(ks xproto.Keysym) []xproto.Keycode

GetKeycode fetches a mapped list of possible keycodes for given keysym.

func (*KeyboardMap) GetKeysym

func (km *KeyboardMap) GetKeysym(kc xproto.Keycode) xproto.Keysym

GetKeysym fetches the keysym mapped to provided keycode.

func (*KeyboardMap) Update

func (km *KeyboardMap) Update(kmin xproto.Keycode, kbmap xproto.GetKeyboardMappingReply)

Update will update the keyboard mappings stored with the values in provided reply.

type Rectangle

type Rectangle struct {
	Coord

	// Width in pixels
	// from Coord{X,Y}.
	Width uint32

	// Height in pixels
	// from Coord{X,Y}.
	Height uint32
}

func (Rectangle) Centre

func (r Rectangle) Centre() Coord

Centre returns the centre coord of this rectangle.

func (Rectangle) Contains

func (r Rectangle) Contains(root Rectangle, pos Coord) bool

Contains returns whether receiving rectangle contains the given coords, given the total containing root rectangle.

func (Rectangle) Size

func (r Rectangle) Size() uint64

Size returns the size of this rectangle.

func (Rectangle) X_Max

func (r Rectangle) X_Max() int32

X_Max returns the maximum X coord of this rectangle.

func (Rectangle) Y_Max

func (r Rectangle) Y_Max() int32

Y_Max returns the maximum Y coord of this rectangle.

type Root

type Root struct {
	ID xproto.Window
	Rectangle
}

Root contains details about the root window.

type Screen

type Screen struct {
	Monitor xproto.Atom
	Rectangle
}

Screen ...

type WM

type WM struct {
	// Configuration data.
	Config Config

	// Desktop ...
	Desktop Desktop

	// Root window.
	Root Root

	// Interned X atoms.
	Atoms InternedAtoms

	// Last mouse pos + mode.
	LastMouse Coord
	MouseMode uint8

	// Currrently selected X window.
	Selected xproto.Window

	// Map of keycodes
	// to keyboard syms.
	KBMap KeyboardMap

	// XSetup contains X
	// connection setup info.
	XSetup *xproto.SetupInfo

	// EvQueue stores queued events
	// for windows not yet mapped
	EvQueue EventQueue

	// XConn is underlying
	// X server connection.
	XConn *xgb.XConn

	// XProp provides xprop
	// conn helper methods.
	XProp *xprop.XPropConn
}

func (*WM) Init

func (wm *WM) Init(display string) error

func (*WM) Run

func (wm *WM) Run() error

func (*WM) Stop

func (wm *WM) Stop()

type Window

type Window struct {
	// X window ID.
	ID xproto.Window

	// Represented by
	// a rectangle.
	Rectangle

	Workspace *Workspace

	// Protocols is the list of
	// protocols this window supports.
	Protocols []xproto.Atom

	// Tracks Window
	// fullscreen status.
	Fullscreen bool
}

func CreateWindow

func CreateWindow(wm *WM, id xproto.Window) (Window, error)

CreateWindow attemps to create and populate a Window object for given X window ID.

func (*Window) Capture

func (w *Window) Capture(wm *WM) (*image.RGBA, error)

Capture will return an RGBA image object representing the current image of this window on-display.

func (*Window) GetGeometry

func (w *Window) GetGeometry(wm *WM) error

GetGeometry fetches updated geometry from X.

func (*Window) GetSupportedProtocols

func (w *Window) GetSupportedProtocols(wm *WM) error

GetSupportedProtocols fetches the supported WM protocols for this w.

func (*Window) Kill

func (w *Window) Kill(wm *WM) error

Kill will close this window (either via client message, or destroy).

func (*Window) Move

func (w *Window) Move(wm *WM, dx int32, dy int32) error

Move will move this window's x,y coords by given dx,dy.

func (*Window) Resize

func (w *Window) Resize(wm *WM, dx int32, dy int32) error

Resize will resize this window's width,height by given dx,dy.

func (*Window) SetFullscreen

func (w *Window) SetFullscreen(wm *WM) error

SetFullscreen sets the window as fullscreen updating the relevant flag, and sending a configure window request to X with current root window dimensions.

func (*Window) SetGeometry

func (w *Window) SetGeometry(wm *WM, rect Rectangle) error

SetGeometry will bound check the given geometry against current configuration and root window dimensions, then send a configure window request to X with updatee dimensions.

func (*Window) SupportsProtocol

func (w *Window) SupportsProtocol(proto xproto.Atom) bool

SupportsProtocol returns whether this window supports given X protocol.

func (*Window) ToggleFullscreen

func (w *Window) ToggleFullscreen(wm *WM) error

ToggleFullscreen toggles the window's fullscreen status.

func (*Window) UpdateGeometry

func (w *Window) UpdateGeometry(wm *WM, rect Rectangle) error

UpdateGeometry will call SetGeometry only on the condition that window is NOT currently fullscreen, and that updated geometry is actually changed from existing.

type WindowList

type WindowList struct {
	W []Window
}

Windows represents a list of windows.

func (*WindowList) Back

func (w *WindowList) Back() *Window

Back fetches the Window at the back of the list.

func (*WindowList) Front

func (w *WindowList) Front() *Window

Front fetches the Window at the front of the list.

func (*WindowList) Get

func (w *WindowList) Get(id xproto.Window) *Window

Get will fetch the Window with ID.

func (*WindowList) Has

func (w *WindowList) Has(id xproto.Window) bool

Has checks if Windows contains a Window with ID.

func (*WindowList) MoveBack

func (w *WindowList) MoveBack(id xproto.Window) (bool, xproto.Window)

MoveFront attempts to move window with ID to front of stack, returning bool success state and ID of the previous front window if move occurred.

func (*WindowList) MoveFront

func (w *WindowList) MoveFront(id xproto.Window) (bool, xproto.Window)

MoveFront attempts to move window with ID to front of stack, returning bool success state and ID of the previous front window if move occurred.

func (*WindowList) Pop

func (w *WindowList) Pop(id xproto.Window) *Window

Pop will attempt to remove Window with ID from the list.

func (*WindowList) PopBack

func (w *WindowList) PopBack() *Window

PopBack will remove the Window from the back of the list.

func (*WindowList) PopFront

func (w *WindowList) PopFront() *Window

PopFront will remove the Window from the front of the list.

func (*WindowList) PushBack

func (w *WindowList) PushBack(ww Window)

PushBack will add the supplied Window to the back of the list.

func (*WindowList) PushFront

func (w *WindowList) PushFront(ww Window)

PushFront will add the supplied Window to the front of the list.

type Workspace

type Workspace struct{ WindowList }

Workspace represents a single workspace of windows.

func (*Workspace) Activate

func (ws *Workspace) Activate(wm *WM) error

func (*Workspace) Add

func (ws *Workspace) Add(wm *WM, window Window) error

func (*Workspace) AddNew

func (ws *Workspace) AddNew(wm *WM, id xproto.Window) (*Window, error)

func (*Workspace) Deactivate

func (ws *Workspace) Deactivate(wm *WM) error

func (*Workspace) Focus

func (ws *Workspace) Focus(wm *WM, id xproto.Window) (bool, error)

func (*Workspace) MoveBottom

func (ws *Workspace) MoveBottom(wm *WM, id xproto.Window) bool

func (*Workspace) MoveTop

func (ws *Workspace) MoveTop(wm *WM, id xproto.Window) bool

func (*Workspace) Range

func (ws *Workspace) Range(yield func(*Window) bool)

func (*Workspace) RangeRev

func (ws *Workspace) RangeRev(yield func(*Window) bool)

Jump to

Keyboard shortcuts

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