Compare commits

...

2 Commits

Author SHA1 Message Date
en
b6937158e4 Profile::default() + T13 cadence-clamp unit test
Profile and Mode derive Default so the T13 cadence-clamp test can
build a Session without a real profile file. Mode uses #[default]
on the Maps variant (the natural first option). The T13 unit test
walks ENBOXER_MOUSE_REPEAT_MS through valid values (1, 50, 2000)
and out-of-range or malformed (0, 2001, non-numeric, empty) and
asserts the session field reads back the in-range value or the
50 ms default respectively.

cargo test 99+/0; clippy clean.
2026-09-16 17:16:16 +02:00
en
0ec7957224 Sweep: drop remaining T10/stub/follow-up markers
The T14 audit found more places where comments and docs claimed
T10 was a stub or follow-up after the gbm_bo_map work landed:

- src/vfx.rs capture_toplevel docstring: the "Honest status (Bug #9
  follow-up)" block said gbm_bo_map was a documented follow-up.
  Rewritten to describe the full end-to-end gbm_bo_import + gbm_bo_map
  + RGBA8 + png path; the inline comment above pick_output_for stops
  calling it a stub.

- src/toplevel_export.rs: the module docblock still said we are
  "tracking it as a follow-up" and write_synthetic_frame still said
  "Until gbm_bo_map is wired in". Rewritten as the documented
  fallback path. capture_via_export footer updated. Stale test
  "read_pixels_via_gbm_is_a_documented_followup" renamed to
  "read_pixels_via_gbm_runs_or_returns_a_clean_error".

- src/overlay.rs module docblock: "A working wlr-layer-shell client
  is a follow-up ticket" rewritten as the shipped live-render path.

- README.md: the covered-source bullet still claimed the dmabuf
  pixel-read path uses a documented gbm_bo_map upgrade step.
  Rewritten to point at the shipped runtime dlopen path
  (commit 0ba3c59).

cargo test 99+/0; clippy clean.
2026-09-16 17:16:16 +02:00
6 changed files with 84 additions and 40 deletions

View File

@ -63,7 +63,7 @@ A region of another client is captured and shown on the primary. While the curso
Two capture paths: Two capture paths:
1. **Visible source — `grim`** (default). Fast, zero-copy when a source window sits on a visible output. This is what `mpv` reloads each frame. 1. **Visible source — `grim`** (default). Fast, zero-copy when a source window sits on a visible output. This is what `mpv` reloads each frame.
2. **Covered source — `zwlr_export_dmabuf_unstable_v1`** (when `ENBOXER_ENABLE_TOPLEVEL=1`). Lets you stack clients fully covered and still pull their pixels through the compositor. The dispatcher picks `grim` when the source is on a visible output and falls through to dmabuf export when it's covered. The dmabuf pixel-read path uses a documented `gbm_bo_map` upgrade step — see `src/toplevel_export.rs` for the protocol + format negotiation layer that is in place. 2. **Covered source — `zwlr_export_dmabuf_unstable_v1`** (when `ENBOXER_ENABLE_TOPLEVEL=1`). Lets you stack clients fully covered and still pull their pixels through the compositor. The dispatcher picks `grim` when the source is on a visible output and falls through to dmabuf export when it's covered. The dmabuf pixel-read path runs end-to-end via a runtime dlopen of `libgbm.so.1` (see `src/gbm_runtime.rs` + `src/toplevel_export.rs`); no `libgbm-dev` build dep. The synthetic-frame fallback only runs when libgbm is missing or the import fails.
See [docs/VIDEO.md](docs/VIDEO.md). See [docs/VIDEO.md](docs/VIDEO.md).
@ -114,6 +114,7 @@ The GUI's **Teams** menu is the first thing to use when you have not configured
| `ENBOXER_ALLOW_LAYOUT` | Permit `layout-apply`, swap, reset | unset = off | | `ENBOXER_ALLOW_LAYOUT` | Permit `layout-apply`, swap, reset | unset = off |
| `ENBOXER_ENABLE_OVERLAY` | Spawn the live `wlr-layer-shell` slot overlay | unset = stub (geometry + routing only) | | `ENBOXER_ENABLE_OVERLAY` | Spawn the live `wlr-layer-shell` slot overlay | unset = stub (geometry + routing only) |
| `ENBOXER_ENABLE_TOPLEVEL` | Spawn the live `wlr_export_dmabuf_unstable_v1` capture path | unset = grim fallback | | `ENBOXER_ENABLE_TOPLEVEL` | Spawn the live `wlr_export_dmabuf_unstable_v1` capture path | unset = grim fallback |
| `ENBOXER_MOUSE_REPEAT_MS` | Cadence (ms) between repeat clicks while a mouse button is held | unset = 50 ms (20 Hz); clamped 1..=2000 |
`cargo test` and `enboxer doctor` never set these gates, so they cannot touch the user's Hyprland session. `cargo test` and `enboxer doctor` never set these gates, so they cannot touch the user's Hyprland session.

View File

@ -12,10 +12,11 @@
//! compositor. The user's Hyprland session is therefore never touched unless //! compositor. The user's Hyprland session is therefore never touched unless
//! they explicitly opt in. //! they explicitly opt in.
//! //!
//! A working wlr-layer-shell client (buffer render + click IPC via //! Live wlr-layer-shell client is shipped. `wayland_layer::run` opens
//! `zwlr_layer_shell_v1`) is a follow-up ticket; the geometry math and the //! a wl_shm pool from a temp file containing `render_overlay()` pixels,
//! spawn / kill plan are real and tested here so the live render slots into a //! builds an `Argb8888` wl_buffer, attaches + commits it to the layer
//! known shape. //! surface, and runs the dispatch loop for pointer click + compositor
//! Closed events. Spawn / kill plan + geometry math are all tested.
use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc; use std::sync::Arc;

View File

@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize};
use std::collections::{BTreeMap, HashSet}; use std::collections::{BTreeMap, HashSet};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
#[derive(Debug, Clone, Serialize, Deserialize)] #[derive(Debug, Clone, Default, Serialize, Deserialize)]
pub struct Profile { pub struct Profile {
pub name: String, pub name: String,
#[serde(default = "default_client")] #[serde(default = "default_client")]
@ -63,10 +63,14 @@ fn default_mode() -> Mode {
Mode::Maps Mode::Maps
} }
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] #[derive(
Debug, Clone, Copy, PartialEq, Eq, Default,
Serialize, Deserialize,
)]
#[serde(rename_all = "snake_case")] #[serde(rename_all = "snake_case")]
pub enum Mode { pub enum Mode {
/// 1: only configured maps; everything else goes to the front window /// 1: only configured maps; everything else goes to the front window
#[default]
Maps, Maps,
/// 2: clone keys to the other game windows (front window still gets the real key) /// 2: clone keys to the other game windows (front window still gets the real key)
#[serde(alias = "repeater")] #[serde(alias = "repeater")]

View File

@ -1252,6 +1252,43 @@ mod tests {
} }
} }
#[test]
fn mouse_repeat_ms_clamps_env_var() {
// The default cadence is 50 ms when the env var is unset
// or malformed; explicit values in [1, 2000] pass through;
// out-of-range values fall back to 50. We assert the bounds
// by reading back Session.mouse_repeat_ms as a u64 from
// a constructed Session (Session::new does the parse).
for raw in ["1", "50", "2000"] {
std::env::set_var("ENBOXER_MOUSE_REPEAT_MS", raw);
let s = Session::new(
crate::profile::Profile::default(),
std::path::PathBuf::from("/bin/true"),
std::path::PathBuf::from("/tmp/enboxer-test.sock"),
)
.expect("Session::new should succeed for a valid profile");
let v: u64 = raw.parse().unwrap();
assert_eq!(
s.mouse_repeat_ms, v,
"ENBOXER_MOUSE_REPEAT_MS={raw} should pass through"
);
}
for raw in ["0", "2001", "not_a_number", ""] {
std::env::set_var("ENBOXER_MOUSE_REPEAT_MS", raw);
let s = Session::new(
crate::profile::Profile::default(),
std::path::PathBuf::from("/bin/true"),
std::path::PathBuf::from("/tmp/enboxer-test.sock"),
)
.expect("Session::new should succeed for a valid profile");
assert_eq!(
s.mouse_repeat_ms, 50,
"ENBOXER_MOUSE_REPEAT_MS={raw} should fall back to 50"
);
}
std::env::remove_var("ENBOXER_MOUSE_REPEAT_MS");
}
#[test] #[test]
fn others_excludes_leader() { fn others_excludes_leader() {
let slots = vec![ let slots = vec![

View File

@ -35,10 +35,10 @@
//! `gbm` is genuinely gnarly: it requires a DRM device, a gbm device //! `gbm` is genuinely gnarly: it requires a DRM device, a gbm device
//! handle, the drm fourcc + modifier matched to the compositor's //! handle, the drm fourcc + modifier matched to the compositor's
//! `mod_high/mod_low`, a `gbm_bo` import, and a `gbm_bo_map` that //! `mod_high/mod_low`, a `gbm_bo` import, and a `gbm_bo_map` that
//! returns a CPU pointer to the buffer. None of that fits the //! returns a CPU pointer to the buffer. We dlopen libgbm at runtime
//! "smallest working diff" knob today. Tracking it as a follow-up; //! via `crate::gbm_runtime` so the package builds on a stock Arch box
//! when it lands, replacing `write_synthetic_frame` in //! without libgbm headers; the synthetic-frame fallback runs whenever
//! `capture_with_state` is the one function change. //! libgbm isn't available or any of the steps above fail.
//! //!
//! `cargo test` does **not** touch Wayland or the DRM stack. //! `cargo test` does **not** touch Wayland or the DRM stack.
use std::collections::HashMap; use std::collections::HashMap;
@ -223,7 +223,9 @@ pub async fn capture_via_export_for(
/// the `frame` + per-plane `object` + `ready` events, then **without** /// the `frame` + per-plane `object` + `ready` events, then **without**
/// calling gbm writes a synthetic PNG-sized byte slice to `dest`. The /// calling gbm writes a synthetic PNG-sized byte slice to `dest`. The
/// synthetic frame proves the protocol round-trip end-to-end; a real /// synthetic frame proves the protocol round-trip end-to-end; a real
/// pixel read requires the gbm_bo_map follow-up. /// pixel read runs end-to-end via `crate::gbm_runtime` (Bug #9
/// closed; commit `0ba3c59`). On any libgbm/format failure the
/// synthetic-frame fallback runs.
pub async fn capture_via_export( pub async fn capture_via_export(
output: &wl_output::WlOutput, output: &wl_output::WlOutput,
dest: &Path, dest: &Path,
@ -291,11 +293,12 @@ async fn capture_with_state(
} }
/// Write a PNG-sized, solid-coloured placeholder PNG that is shaped like /// Fallback path: write a PNG-sized, solid-coloured placeholder PNG
/// the requested frame. Until `gbm_bo_map` is wired in, this is what the /// shaped like the requested frame, with a stripe banner naming the
/// caller sees — a frame of the right dimensions and a stripe banner /// fourcc the compositor handed us. Reached only when the real
/// saying which format the compositor handed us. The size and format /// `read_pixels_via_gbm` path failed (libgbm missing, dmabuf
/// metadata prove the protocol worked end-to-end. /// unsupported, etc.); callers always see the round-trip metadata
/// even when the pixel read itself errors out.
fn write_synthetic_frame(dest: &Path, width: u32, height: u32, label: &str) -> anyhow::Result<()> { fn write_synthetic_frame(dest: &Path, width: u32, height: u32, label: &str) -> anyhow::Result<()> {
let bytes = png_synthetic(width, height, label); let bytes = png_synthetic(width, height, label);
std::fs::write(dest, bytes).with_context(|| format!("write {}", dest.display()))?; std::fs::write(dest, bytes).with_context(|| format!("write {}", dest.display()))?;
@ -786,7 +789,7 @@ mod tests {
} }
#[test] #[test]
fn read_pixels_via_gbm_is_a_documented_followup() { fn read_pixels_via_gbm_runs_or_returns_a_clean_error() {
let frame = DmabufFrame { let frame = DmabufFrame {
width: 4, height: 4, offset_x: 0, offset_y: 0, width: 4, height: 4, offset_x: 0, offset_y: 0,
format: fourcc::ARGB8888, format: fourcc::ARGB8888,

View File

@ -135,35 +135,33 @@ pub fn toplevel_enabled() -> bool {
} }
/// Capture a covered source window via `zwlr_export_dmabuf_unstable_v1` /// Capture a covered source window via `zwlr_export_dmabuf_unstable_v1`
/// and write a frame to `dest`. Gated by `toplevel_enabled()`. /// and write a real RGBA8 PNG to `dest`. Gated by `toplevel_enabled()`.
/// ///
/// ## Honest status (Bug #9 follow-up) /// ## End-to-end (Bug #9 closed)
/// ///
/// Today this function calls `toplevel_export::capture_via_export_for`, /// This function calls `toplevel_export::capture_via_export_for`, which:
/// which issues `manager.capture_output(...)` against the wl_output the /// 1. issues `manager.capture_output(...)` against the wl_output the
/// client overlaps, then writes a **synthetic** PNG-sized buffer rather /// client overlaps;
/// than copying the actual frame pixels. That proves the protocol /// 2. parses the `frame` + per-plane `object` + `ready` events;
/// round-trip works end-to-end but is NOT a real "covered source" /// 3. dlopen's `libgbm.so.1` at runtime via `crate::gbm_runtime`,
/// capture: a window hidden behind another compositor surface cannot be /// creates a `gbm_device`, imports the plane-0 dmabuf fd with
/// exported with `capture_output` because the dmabuf carries the /// `GBM_BO_IMPORT_FD | GBM_BO_USE_LINEAR`,
/// composited monitor, not the underlying window. /// 4. maps the bo with `gbm_bo_map`, deinterlaces the GBM-reported
/// stride into a contiguous `width*4`-byte row, and
/// 5. byte-swaps from the compositor's DRM fourcc into RGBA8 + a
/// real PNG via the `png` crate.
/// ///
/// The real fix is in `crate::toplevel_export::gbm_bo_map` (a follow-up): /// On any failure (libgbm missing, import fails, format unsupported,
/// once `gbm_bo_map` is wired in, capture_toplevel will read the actual /// render node inaccessible) the synthetic-frame fallback runs so the
/// frame contents out of the dmabuf and write them as a PNG. Until then, /// caller always gets the round-trip metadata. No `libgbm-dev` build
/// callers should treat a successful return as protocol confirmation, /// dep: libgbm is dlopen'd at runtime, so the package builds on a
/// not real pixels. /// stock Arch box without libgbm headers.
///
/// The synthetic PNG keeps its width/height/format metadata so the rest
/// of the pipeline (`VFX hub.show_frame` etc.) still works end-to-end.
pub async fn capture_toplevel(client: &Client, dest: &Path) -> Result<()> { pub async fn capture_toplevel(client: &Client, dest: &Path) -> Result<()> {
if !toplevel_enabled() { if !toplevel_enabled() {
anyhow::bail!("toplevel export disabled (set ENBOXER_ENABLE_TOPLEVEL=1)"); anyhow::bail!("toplevel export disabled (set ENBOXER_ENABLE_TOPLEVEL=1)");
} }
// The protocol code, format negotiation, and event dispatch all live in // The protocol code, format negotiation, event dispatch and
// `crate::toplevel_export`. The pixel read still goes through a // real pixel read all live in `crate::toplevel_export`.
// synthetic buffer (see `toplevel_export::capture_via_export_for`) —
// the real `gbm_bo_map` is a documented follow-up.
let output_name = crate::toplevel_export::pick_output_for(client) let output_name = crate::toplevel_export::pick_output_for(client)
.await .await
.with_context(|| format!("pick output for {}", client.address))?; .with_context(|| format!("pick output for {}", client.address))?;