headless

package
v0.1.0-alpha.4 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: Apache-2.0 Imports: 8 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 headless is a shell.Window that has no display: it applies each Present(frame, damage) to an in-memory "screen", records timing, and replays scripted input events. It is the test harness for the whole GUI stack and produces the screenshots used to verify rendering without X11.

The screen only changes inside the damage rectangle the app reports, so a test that compares Screen() with the compositor's frame catches any missing damage.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func KeyEvents

func KeyEvents(chord string) []shell.Event

KeyEvents expands a chord like "ctrl+shift+t" or "Enter" into the KeyDown/KeyUp pair a native shell would send.

func Open

func Open(cfg shell.Config) (shell.Window, error)

Open satisfies the shell registration signature.

func TypeEvents

func TypeEvents(text string) []shell.Event

TypeEvents returns one EvText per rune sequence (committed text input).

Types

type Window

type Window struct {

	// OnPresent, when set, is called after each Present (no locks held).
	OnPresent func(damage image.Rectangle)
	// contains filtered or unexported fields
}

Window implements shell.Window.

func New

func New(w, h int, scale float64) *Window

New creates a headless window of w x h logical pixels at the given scale.

func (*Window) At

func (w *Window) At(x, y int) color.RGBA

At returns one pixel of the current screen (cheap; no copy of the frame).

func (*Window) Clipboard

func (w *Window) Clipboard() string

func (*Window) ClipboardHTML

func (w *Window) ClipboardHTML() string

func (*Window) Close

func (w *Window) Close()

Close ends the event stream.

func (*Window) Cursor

func (w *Window) Cursor() shell.Cursor

func (*Window) Damages

func (w *Window) Damages() []image.Rectangle

Damages returns the damage rectangle of each presented frame.

func (*Window) Events

func (w *Window) Events() <-chan shell.Event

func (*Window) Fullscreen

func (w *Window) Fullscreen() bool

func (*Window) LastPresent

func (w *Window) LastPresent() time.Time

LastPresent returns the time of the last Present.

func (*Window) OpenURL

func (w *Window) OpenURL(u string) error

func (*Window) Opened

func (w *Window) Opened() []string

func (*Window) Present

func (w *Window) Present(frame *image.RGBA, damage image.Rectangle)

func (*Window) PresentTimes

func (w *Window) PresentTimes() []time.Time

PresentTimes returns the time of every Present so far (capped at 65536).

func (*Window) Presents

func (w *Window) Presents() int

Presents returns how many frames were presented.

func (*Window) Push

func (w *Window) Push(ev shell.Event)

Push delivers an event to the app (non-blocking beyond the buffer).

func (*Window) PushAndMeasure

func (w *Window) PushAndMeasure(ev shell.Event, timeout time.Duration) (time.Duration, bool)

PushAndMeasure injects ev and returns the time until the next Present. ok is false if no frame was presented within timeout.

func (*Window) Resize

func (w *Window) Resize(lw, lh int, scale float64)

Resize simulates a window resize.

func (*Window) SavePNG

func (w *Window) SavePNG(path string) error

SavePNG writes the screen to path.

func (*Window) Screen

func (w *Window) Screen() *image.RGBA

Screen returns a copy of the current screen.

func (*Window) SetClipboard

func (w *Window) SetClipboard(s string)

func (*Window) SetClipboardRich

func (w *Window) SetClipboardRich(text, html string)

SetClipboardRich and ClipboardHTML make the headless window a shell.RichClipboard.

func (*Window) SetCursor

func (w *Window) SetCursor(c shell.Cursor)

func (*Window) SetFullscreen

func (w *Window) SetFullscreen(b bool)

func (*Window) SetTitle

func (w *Window) SetTitle(s string)

func (*Window) Size

func (w *Window) Size() (int, int, float64)

func (*Window) Title

func (w *Window) Title() string

func (*Window) WaitPixel

func (w *Window) WaitPixel(start time.Time, x, y int, ok func(color.RGBA) bool, timeout time.Duration) (time.Duration, bool)

WaitPixel blocks until the screen pixel at (x,y) satisfies ok, polling after every Present, and returns the time from start until it did.

func (*Window) WaitPresents

func (w *Window) WaitPresents(n int, timeout time.Duration) bool

WaitPresents blocks until at least n frames were presented.

Jump to

Keyboard shortcuts

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