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 ¶
- Variables
- func BackgroundCapture[T any](ctx context.Context, g *Gate, capture func() (T, error)) (T, error)
- func OpenSession[T any](ctx context.Context, g *Gate, invoke func(func()), frames Frames, ...) (T, error)
- func OpenSurface(a *app.Application, out *app.Output, namespace string, root widget.Widget, ...) (*app.LayerWindow, error)
- type Frames
- type Gate
- type Monitor
- type Overlay
- type Picked
- type Selection
- type Window
- type WindowPick
Constants ¶
This section is empty.
Variables ¶
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
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.
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 ¶
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.
type Picked ¶ added in v0.3.14
type Picked struct {
// Window is the clicked window's ID, "" when Enter chose the screen.
Window string
// Screen is the output Enter shared.
Screen string
}
Picked is a window pick's answer: the window clicked, or the screen Enter shares.
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.
type Window ¶ added in v0.3.14
Window is a window a click can pick, (ssiiii): its identifier, the output that shows it, and its global logical rectangle.
type WindowPick ¶ added in v0.3.14
type WindowPick struct {
// contains filtered or unexported fields
}
WindowPick is the click-to-pick overlay: a layer surface on every monitor dims the desktop and outlines the windows a click can pick, the one under the pointer cleared and outlined in the accent. A click picks it, Enter shares the screen where the request offers one, and Escape gives up. Request is its only entry point; everything else runs on the lys-ui loop goroutine.
func NewWindowPick ¶ added in v0.3.14
func NewWindowPick(a *app.Application, gate *Gate, outputs func() []*app.Output, font render.Font, sheet *widget.Stylesheet) *WindowPick
NewWindowPick builds the overlay on the application, on the shell's one capture gate; outputs lists the monitors to cover at each request.
func (*WindowPick) Hovered ¶ added in v0.3.14
func (o *WindowPick) Hovered() (Window, bool)
Hovered is the window under the pointer, on the loop.
func (*WindowPick) Request ¶ added in v0.3.14
func (o *WindowPick) Request(ctx context.Context, windows []Window, screen string) (Picked, bool, error)
Request opens the overlay over windows, listed front to back on each output, and blocks until a click picks one or Enter shares screen ("" offers no screen): ok. Escape, or ctx ending, answers not ok without an error; another capture session holding the gate answers ErrBusy. Call it from any goroutine but the loop's.