Files
DarkRoom/platform/dr-plat/examples/display_probe.rs
T
dtourolleandClaude Opus 5 e4875498ca Ask the platform what colour the screen actually is
FR-DSP-8's acquisition half. `dr_plat::display` surveys the session's
displays and reduces each one's profile to an output space the pipeline
can encode into, stating the mechanism per display server as
FR-PLAT-LIN-2 requires:

  - X11 reads the `_ICC_PROFILE` / `_ICC_PROFILE_<n>` root-window
    properties, enumerating and numbering the outputs through RandR,
    which also yields the rectangles a window move is measured against.
  - Wayland binds `wp_color_manager_v1` and asks each `wl_output` for
    its image description, accepting either an ICC profile on a file
    descriptor or primaries stated as chromaticities.
  - Where neither answers, sRGB is assumed and the reason travels with
    it as data rather than into a log, so the About page can say which
    path the session is on.

A display profile is a measurement of one panel and is none of the four
spaces the pipeline knows. Rather than grow an ICC engine, the profile
is reduced to D50-adapted colorants and matched against the four; a
match that is merely nearest is marked as such and shown as such.

Verified on this machine: mutter 50 advertises the colour-management
global and reports eDP-1 as sRGB, and the same session forced onto X11
enumerates the output through RandR and correctly finds no atom.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-27 18:20:28 +02:00

37 lines
1.4 KiB
Rust
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
//! What this machine's display server will say about its monitors.
//!
//! The same probe the application runs at startup, printed instead of used.
//! It exists for the reason `keyring_check` does: the answer depends entirely
//! on the desktop the code is running on, so the only way to know which
//! acquisition path a given machine takes is to ask it there.
//!
//! cargo run -p dr-plat --example display_probe
fn main() {
env_logger::init();
let survey = dr_plat::DisplaySurvey::probe();
println!("display server: {}", survey.server.label());
println!();
for (index, display) in survey.displays.iter().enumerate() {
println!("[{index}] {}", display.name);
println!(" space: {}", display.profile.space.label());
println!(" reading: {}", display.profile.describe());
println!(
" source: {:?} measured: {} approximated: {}",
display.profile.source,
display.profile.source.is_measured(),
display.profile.approximated
);
match display.bounds {
Some(b) => println!(
" bounds: {}×{} at ({}, {})",
b.width, b.height, b.x, b.y
),
// Expected on Wayland; see `DisplaySurvey::containing`.
None => println!(" bounds: not stated by this display server"),
}
println!();
}
}