displays

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT, MIT Imports: 14 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package displays reads and applies the compositor's output layout over wlr-output-management, and arranges outputs on a plane: the logical rectangles the Displays page drags, snaps and normalizes.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoOutputManagement = errors.New("displays: the compositor offers no " + managerIface)

ErrNoOutputManagement is a compositor without wlr-output-management.

View Source
var ErrRefused = errors.New("displays: the compositor refused the layout")

ErrRefused is a configuration the compositor would not take.

View Source
var ErrSuperseded = errors.New("displays: the outputs changed before the layout was applied")

ErrSuperseded is a configuration the compositor cancelled because the outputs changed while it was being made.

Functions

func Match

func Match(h Head) string

Match is the outputs-rule match that names h: its description when the compositor knows one beyond the connector, so the rule follows the monitor across ports, else its connector.

func ModeText

func ModeText(m Mode) string

ModeText is a mode as an outputs rule writes it.

func Rules

func Rules(existing []any, heads []Head, settings []Setting) []any

Rules is existing with each head's rule carrying its setting's mode, position, scale and enabled state: a rule that names the head is updated in place and keeps its other keys, a head no rule names gets one, and rules for other outputs stay as they are.

func ScaleValue

func ScaleValue(s float64) float64

ScaleValue is a scale on lys-wm's 1/120 grid.

Types

type Head struct {
	Name, Description   string
	Make, Model, Serial string
	Enabled             bool
	Modes               []Mode
	Current             int
	X, Y                int
	Scale               float64
}

Head is one output as the compositor describes it.

func (Head) CurrentMode

func (h Head) CurrentMode() (Mode, bool)

CurrentMode is the head's current mode, false while it has none.

type Manager

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

Manager is a connection of its own to the compositor that follows its heads. One goroutine reads the connection; requests go out from any goroutine under mu.

func Connect

func Connect(onHeads func([]Head)) (*Manager, error)

Connect connects to the compositor named by WAYLAND_DISPLAY; onHeads hears every complete set of heads, the first before Connect returns, on the connection's goroutine.

func (*Manager) Apply

func (m *Manager) Apply(settings []Setting) error

Apply applies settings as one configuration.

func (*Manager) Close

func (m *Manager) Close()

Close closes the connection once a final sync comes back.

func (*Manager) HandleCallbackDone

func (m *Manager) HandleCallbackDone(wl.CallbackDoneEvent)

HandleCallbackDone is Close's final sync: the read loop stops.

func (*Manager) HandleRegistryGlobal

func (m *Manager) HandleRegistryGlobal(ev wl.RegistryGlobalEvent)

HandleRegistryGlobal binds the output manager.

func (*Manager) HandleRegistryGlobalRemove

func (m *Manager) HandleRegistryGlobalRemove(wl.RegistryGlobalRemoveEvent)

HandleRegistryGlobalRemove ignores globals going away; a head leaving is the manager's to tell.

func (*Manager) HandleZwlrOutputManagerV1Done

func (m *Manager) HandleZwlrOutputManagerV1Done(ev wlr.ZwlrOutputManagerV1DoneEvent)

HandleZwlrOutputManagerV1Done publishes the heads as they now are.

func (*Manager) HandleZwlrOutputManagerV1Finished

func (m *Manager) HandleZwlrOutputManagerV1Finished(wlr.ZwlrOutputManagerV1FinishedEvent)

HandleZwlrOutputManagerV1Finished drops the manager the compositor let go.

func (*Manager) HandleZwlrOutputManagerV1Head

func (m *Manager) HandleZwlrOutputManagerV1Head(ev wlr.ZwlrOutputManagerV1HeadEvent)

HandleZwlrOutputManagerV1Head follows a new head.

func (*Manager) Test

func (m *Manager) Test(settings []Setting) error

Test asks whether the compositor would take settings, changing nothing.

type Mode

type Mode struct {
	Width, Height int
	RefreshMHz    int
	Preferred     bool
}

Mode is one mode a head offers.

type Rect

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

Rect is an output's logical rectangle on the plane.

func Logical

func Logical(s Setting) Rect

Logical is the rectangle an enabled setting covers: its mode in logical pixels at its position.

func NextEdge

func NextEdge(rects []Rect, i, dx, dy int) (Rect, bool)

NextEdge is the nearest position past rects[i] along one axis, in the direction of the sign of dx or dy, at which one of its edges meets an edge of another rectangle; false when there is none.

func Normalize

func Normalize(rects []Rect) []Rect

Normalize shifts the rectangles so the top-left one sits at 0,0.

func Settle

func Settle(rects []Rect, i int) []Rect

Settle places rects[i] where it touches another rectangle without overlapping any, the nearest such place to where it is, then does the same for any rectangle left floating apart from it, and normalizes.

func Snap

func Snap(rects []Rect, i, threshold int) Rect

Snap moves rects[i] so an edge within threshold of another rectangle's edge lines up with it, on each axis on its own.

type Setting

type Setting struct {
	Name    string
	Enabled bool
	Mode    Mode
	X, Y    int
	Scale   float64
}

Setting is what a configuration asks of one head.

func Settings

func Settings(heads []Head) []Setting

Settings is the layout the heads have now.

Jump to

Keyboard shortcuts

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