wlr_capture/lib.rs
1//! `wlr-capture` — the reusable bricks behind the wlr-utils tools.
2//!
3//! Always available (headless-friendly, no egui/EGL display deps):
4//! - [`wl`]: native Wayland client that enumerates foreign toplevels + outputs and
5//! captures them (full-resolution, zero-copy GPU dma-buf path) via
6//! `ext-image-copy-capture`.
7//! - [`clipboard`]: put a captured blob on the wlroots clipboard (`data-control`).
8//! - [`gl`]: EGL/GL dma-buf import + headless readback ([`gl::GpuReadback`]).
9//! - [`sink`]: the [`sink::FrameSink`] seam shared by screenshot/record/timelapse,
10//! with GPU dma-buf readback under the default path.
11//! - [`stream`]: the shared live-capture session driver (arm/poll/reopen/give-up),
12//! used by the mirror, recorder and change monitor.
13//! - [`diff`]: a frame-difference metric for change detection.
14//!
15//! Behind the `compose` feature (resamples with `image`):
16//! - [`capture`]: resolve a source (output/window/region) to a [`wl::CapturedImage`],
17//! compositing across mixed-scale outputs. Shared by `wlr-shot` and `wlr-peek`.
18//!
19//! Behind the `video` feature (links system FFmpeg via `ffmpeg-next`, headless):
20//! - [`video`]: a [`sink::FrameSink`] that encodes a capture stream to a file with a
21//! pluggable hardware/software backend (NVENC / VAAPI / libx264).
22//!
23//! Behind the `focus` feature (compositor IPC, pulls `serde_json`):
24//! - [`focus`]: "the active window" / "the current output" via the compositor's own
25//! IPC (Sway today). Wayland gives no portable way to query focus.
26//!
27//! Always available — UI text via the [`tr!`] macro:
28//! - [`i18n`]: localisation. With the `i18n` feature (default) it uses Fluent; without
29//! it, `tr!` returns the English text generated from the `en` catalog at build time,
30//! pulling no Fluent dependency. So every module (core or toolkit) can call `tr!`.
31//!
32//! Behind the `toolkit` feature (on by default) — the egui/EGL overlay toolkit:
33//! - [`render`]: egui → `egui_glow` rendering on an EGL context bound to a surface.
34//! - `icons` / `theme`: shared overlay UI helpers.
35//!
36//! Consumers (`wlr-chooser`, `wlr-pip`, …) build their own windowing host on top
37//! and reuse this engine for the heavy lifting; a future headless recorder can use
38//! the capture engine + readback without pulling in the toolkit.
39
40// `doc_cfg` renders the "Available on crate feature X" badges on docs.rs (nightly-only,
41// so guarded by the `docsrs` cfg that docs.rs sets via rustdoc-args).
42#![cfg_attr(docsrs, feature(doc_cfg))]
43// Keep the public API fully documented (the whole surface ships on docs.rs).
44#![warn(missing_docs)]
45
46// Re-exported so consumers can own a single `Connection` and pass it to several
47// overlays in one process (e.g. the region selector then a live mirror), sharing one
48// `EGLDisplay` instead of opening a second one. See `overlay::select_region_on`.
49pub use wayland_client::Connection;
50
51pub mod clipboard;
52pub mod diff;
53pub mod gl;
54pub mod i18n;
55pub mod sink;
56pub mod stream;
57pub mod wl;
58
59#[cfg(feature = "compose")]
60#[cfg_attr(docsrs, doc(cfg(feature = "compose")))]
61pub mod capture;
62
63#[cfg(feature = "focus")]
64#[cfg_attr(docsrs, doc(cfg(feature = "focus")))]
65pub mod focus;
66
67#[cfg(feature = "overlay")]
68#[cfg_attr(docsrs, doc(cfg(feature = "overlay")))]
69pub mod overlay;
70
71#[cfg(feature = "mirror")]
72#[cfg_attr(docsrs, doc(cfg(feature = "mirror")))]
73pub mod mirror;
74
75#[cfg(feature = "video")]
76#[cfg_attr(docsrs, doc(cfg(feature = "video")))]
77pub mod video;
78
79#[cfg(feature = "audio")]
80#[cfg_attr(docsrs, doc(cfg(feature = "audio")))]
81pub mod audio;
82
83#[cfg(feature = "toolkit")]
84#[cfg_attr(docsrs, doc(cfg(feature = "toolkit")))]
85pub mod icons;
86#[cfg(feature = "toolkit")]
87#[cfg_attr(docsrs, doc(cfg(feature = "toolkit")))]
88pub mod render;
89#[cfg(feature = "toolkit")]
90#[cfg_attr(docsrs, doc(cfg(feature = "toolkit")))]
91pub mod theme;