regionoverlay

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 17 Imported by: 1 module, 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 regionoverlay is the region selection overlay: a layer surface on every monitor, a dim wash with a transparent hole where the selection overlaps that monitor, an accent border with resize handles, and a "W × H" size label. A drag draws the selection and a plain click picks the window (else the output) under the pointer; the selection is then moved, resized from its edges and corners or nudged with the arrow keys until Enter or a double-click confirms it. Everything is tracked in global (compositor-layout) logical coordinates, so a selection can span monitors. The screenshot host passes frozen per-output frames, which the surfaces paint behind the wash (freeze-frame) with a magnifier at the pointer; the share picker passes none, so the live screen shows through.

Index

Constants

This section is empty.

Variables

View Source
var ErrBusy = errors.New("another capture is in progress")

ErrBusy answers a request made while a capture overlay session is open, or an overlay request made during an instant capture. The request opened nothing and captured nothing, and what was running goes on untouched.

Functions

func BackgroundCapture added in v0.3.3

func BackgroundCapture[T any](ctx context.Context, g *Gate, capture func() (T, error)) (T, error)

BackgroundCapture runs capture so that what it returns shows no overlay, for a capture nobody asked for by hand. It neither refuses nor is refused: it waits out an open session, and a session admitted while it runs takes precedence, discarding its result to capture again once that session ended. So a capture runs again only for a session someone opened. It ends with ctx's error while waiting.

func OpenSession added in v0.3.3

func OpenSession[T any](ctx context.Context, g *Gate, invoke func(func()), frames Frames, show func(map[string]render.StillImage, chan T), cancel func(chan T)) (T, error)

OpenSession is the one way into a capture overlay: it holds g for the whole session, refusing with ErrBusy before anything else happens. Admitted, it takes the frames (nil Frames for none), runs show on the loop through invoke, and blocks for the answer show's overlay sends on the channel it was given. ctx ending takes down this session alone, through cancel on the loop: the overlay answers as the user's cancel does, and cancel ignores a channel that is no longer the open one. A ctx already ended once the frames are in answers the zero T without showing anything.

func OpenSurface added in v0.3.3

func OpenSurface(a *app.Application, out *app.Output, namespace string, root widget.Widget, onKey func(*widget.Router, uint32, app.Mods)) (*app.LayerWindow, error)

OpenSurface maps one capture overlay's surface over out: above everything, covering the output and holding the keyboard. It plays no exit motion whatever the application's surface motion, so Close ends its painting: the requester frees the frozen frames the surface paints once it has its answer.

Types

type Frames added in v0.3.3

type Frames func() (map[string]render.StillImage, error)

Frames captures the frozen frames of one overlay session, keyed by connector. A session runs it once it holds the gate, so it takes no capture for a refused request.

type Gate added in v0.3.3

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

Gate admits one capture overlay session at a time across every overlay sharing it. An instant capture is admitted only while no session is open, so an overlay never lands in a shot.

func (*Gate) Instant added in v0.3.3

func (g *Gate) Instant() (func(), error)

Instant admits a capture that opens no overlay, ErrBusy while a session is open; the returned func ends it. Instant captures do not exclude each other.

func (*Gate) Open added in v0.3.4

func (g *Gate) Open() bool

Open reports whether a session is open. It takes no part in admission, so asking never refuses a request, as Instant can.

type Monitor

type Monitor struct {
	Connector           string
	X, Y, Width, Height int
}

Monitor is one output's connector name and global logical geometry.

func MonitorOf

func MonitorOf(o *app.Output) Monitor

MonitorOf reads an output's logical geometry: the xdg-output position and size, falling back to the mode divided by the scale when the compositor reported no logical size.

type Overlay

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

Overlay is the overlay component. Request is its only entry point; everything else runs on the lys-ui loop goroutine.

func New

func New(a *app.Application, gate *Gate, outputs func() []*app.Output, windows func() []image.Rectangle, font render.Font, sheet *widget.Stylesheet) *Overlay

New builds the overlay on the application; gate is the shell's one capture gate, outputs lists the monitors to cover at each request, windows (nil for none) the windows a click can pick.

func (*Overlay) Request

func (o *Overlay) Request(ctx context.Context, frames Frames) (Selection, bool, error)

Request opens the overlay and blocks until the user confirms a region (ok), or cancels with Escape or ctx ends (not ok, no error). frames runs once the gate admits the request and before any surface maps; what it returns is painted behind the wash, and nil or a missing connector leaves that surface transparent over the live screen. While another session holds the gate the request opens nothing, takes no frames, leaves that session and its selection as they are, and answers ErrBusy. Call it from any goroutine but the loop's.

func (*Overlay) Selected added in v0.3.5

func (o *Overlay) Selected() image.Rectangle

Selected is the region drawn so far, on the loop.

type Selection

type Selection struct {
	// Output is the connector name of the output the selection is
	// relative to.
	Output              string
	X, Y, Width, Height int
}

Selection is a region the user dragged, in logical pixels relative to Output: slurp's `<output>@x,y,w,h` and the screencopy region semantics.

Jump to

Keyboard shortcuts

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