Skip to main content

Crate wlr_capture

Crate wlr_capture 

Source
Expand description

wlr-capture — the reusable bricks behind the wlr-utils tools.

Always available (headless-friendly, no egui/EGL display deps):

  • wl: native Wayland client that enumerates foreign toplevels + outputs and captures them (full-resolution, zero-copy GPU dma-buf path) via ext-image-copy-capture.
  • clipboard: put a captured blob on the wlroots clipboard (data-control).
  • gl: EGL/GL dma-buf import + headless readback (gl::GpuReadback).
  • sink: the sink::FrameSink seam shared by screenshot/record/timelapse, with GPU dma-buf readback under the default path.
  • stream: the shared live-capture session driver (arm/poll/reopen/give-up), used by the mirror, recorder and change monitor.
  • diff: a frame-difference metric for change detection.

Behind the compose feature (resamples with image):

  • capture: resolve a source (output/window/region) to a wl::CapturedImage, compositing across mixed-scale outputs. Shared by wlr-shot and wlr-peek.

Behind the video feature (links system FFmpeg via ffmpeg-next, headless):

  • video: a sink::FrameSink that encodes a capture stream to a file with a pluggable hardware/software backend (NVENC / VAAPI / libx264).

Behind the focus feature (compositor IPC, pulls serde_json):

  • focus: “the active window” / “the current output” via the compositor’s own IPC (Sway today). Wayland gives no portable way to query focus.

Always available — UI text via the tr! macro:

  • i18n: localisation. With the i18n feature (default) it uses Fluent; without it, tr! returns the English text generated from the en catalog at build time, pulling no Fluent dependency. So every module (core or toolkit) can call tr!.

Behind the toolkit feature (on by default) — the egui/EGL overlay toolkit:

  • render: egui → egui_glow rendering on an EGL context bound to a surface.
  • icons / theme: shared overlay UI helpers.

Consumers (wlr-chooser, wlr-pip, …) build their own windowing host on top and reuse this engine for the heavy lifting; a future headless recorder can use the capture engine + readback without pulling in the toolkit.

Modules§

capturecompose
High-level capture: resolve a source (output, window, logical region) to a ready-to-use CapturedImage, compositing across outputs when a region spans several (possibly mixed-scale) monitors.
clipboard
Native Wayland clipboard copy via zwlr_data_control_v1 (the wlroots clipboard-manager protocol, the same one wl-copy and grim use).
diff
Frame-difference metric for change detection.
focusfocus
Focus-aware capture helpers: “the active window” and “the current output”.
gl
EGL/GLES core: dma-buf → GL texture import and headless readback.
i18n
Internationalisation.
iconstoolkit
Resolve an application icon from its app-id and rasterize it to RGBA8 (unmultiplied alpha), for display next to window names. PNG/JPEG via image, SVG via resvg.
mirrormirror
xdg-toplevel windowing host for the live mirror.
overlayoverlay
Interactive frozen-screen overlay: a wlr-layer-shell surface per output showing that output’s frozen capture, shared by several interactions (Mode): select_region (drag a rectangle), pick_point (the wlr-peek colour picker, with a loupe) and magnify (a full-screen zoom that follows the cursor). Coordinates are tracked in the global logical space so they span outputs. Rendered with egui on the shared render::Gpu, like the chooser’s overlay — one surface (and GL context) per output.
rendertoolkit
Shared egui → egui_glow rendering core on an EGL/GLES context bound to a Wayland surface, plus zero-copy dma-buf → GL texture import.
sink
Common output seam for capture-consuming tools (screenshot, record, timelapse).
stream
Shared driver for a live capture session over one source.
themetoolkit
Colour & font theme. Sensible generic-dark defaults, overridable from ~/.config/wlr-chooser/theme.toml (or $XDG_CONFIG_HOME/wlr-chooser/theme.toml).
videovideo
Video encoding sink: turn a capture stream into a file via FFmpeg.
wl
Native Wayland client: enumerate foreign toplevels and outputs, and capture them via ext-image-copy-capture-v1.

Macros§

tri18n
Look up a UI message, optionally with name = value arguments.

Structs§

Connection
The Wayland connection