Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

Support automatic monitor ICC profiles on Linux X11 (#2963)

Sir Starchb4a949225dcd
diff --git a/apps/photocraft/src/main.rs b/apps/photocraft/src/main.rs
index 33efd4baf..a267673aa 100644
--- a/apps/photocraft/src/main.rs
+++ b/apps/photocraft/src/main.rs
@@ -230,6 +230,8 @@ fn main() -> eframe::Result {
// The display server to open the window on: Xwayland for a pen on Wayland, which gives this
// app no pen input (#639).
#[cfg(target_os = "linux")]
+ let native_session = linux_libs::session_from_env(|name| std::env::var(name).ok());
+ #[cfg(target_os = "linux")]
let session = tablet::display_session();
// Preferences › Performance › Linux display server = X11: Xwayland on a Wayland session too,
// where native file drops work (winit 0.30 has none on Wayland, #386). Only when Xwayland can
@@ -297,6 +299,9 @@ fn main() -> eframe::Result {
// Read the displays' ICC profiles while the window opens (colour-managed canvas; `None`
// where the platform has no reader).
+ #[cfg(target_os = "linux")]
+ let monitor = monitor_profile::detect_async_for_session(native_session);
+ #[cfg(not(target_os = "linux"))]
let monitor = monitor_profile::detect_async();
// Brush presets load in the background; the app attaches them when they arrive.
let presets = services::presets_dir().map(photocraft_engine::preset_store::open_dir_async);
@@ -379,7 +384,14 @@ fn main() -> eframe::Result {
// the right profile; a slower reading is applied when it arrives, and the shell reads
// again when the displays may have changed.
if let Some(rx) = monitor {
- app.services.read_displays = Some(std::sync::Arc::new(monitor_profile::detect_async));
+ #[cfg(target_os = "linux")]
+ {
+ app.services.read_displays = Some(std::sync::Arc::new(move || monitor_profile::detect_async_for_session(native_session)));
+ }
+ #[cfg(not(target_os = "linux"))]
+ {
+ app.services.read_displays = Some(std::sync::Arc::new(monitor_profile::detect_async));
+ }
match rx.recv_timeout(std::time::Duration::from_secs(2)) {
Ok(r) => photocraft_ui_egui::monitor_status::apply(&mut app, r),
Err(std::sync::mpsc::RecvTimeoutError::Timeout) => photocraft_ui_egui::monitor_status::pending(&mut app, rx),
diff --git a/apps/photocraft/src/monitor_profile.rs b/apps/photocraft/src/monitor_profile.rs
index c7a7c0489..8e3386969 100644
--- a/apps/photocraft/src/monitor_profile.rs
+++ b/apps/photocraft/src/monitor_profile.rs
@@ -6,7 +6,12 @@
//! AppleScriptObjC) so the app needs no `unsafe` FFI. A read takes about 0.4 s on a background
//! thread; the shell starts one at launch and again when the displays may have changed
//! (`photocraft_ui_egui::monitor_status`), and each window then uses the profile of the display
-//! it is on. Other platforms report no displays (sRGB, or the profile chosen in Color Settings).
+//! it is on. Linux X11: RandR output names and CRTC frames are matched to colord display devices
+//! by the exact `XRANDR_name` metadata; cloned outputs get a profile only when every output has
+//! the same ICC bytes. Native Wayland, including Xwayland windows opened from a Wayland session,
+//! reports no display profiles: eframe/winit has no safe way to set the app surface's Wayland
+//! image description, so applying the output ICC in PhotoCraft could double-transform it.
+//! Other platforms report no displays (sRGB, or the profile chosen in Color Settings).
use std::sync::mpsc::Receiver;
@@ -16,15 +21,33 @@ use photocraft_engine::display_color::Display;
pub type Detection = Result<Vec<Display>, String>;
/// Starts reading the displays in the background; `None` when the platform has no reader.
+#[cfg(not(target_os = "linux"))]
pub fn detect_async() -> Option<Receiver<Detection>> {
- if !cfg!(target_os = "macos") {
- return None;
+ #[cfg(target_os = "macos")]
+ {
+ Some(spawn_reader(detect))
}
+ #[cfg(not(target_os = "macos"))]
+ {
+ None
+ }
+}
+
+/// Linux display profile reads are supported only for an X11 session. In particular, an app
+/// window opened through Xwayland still belongs to the Wayland desktop and must not apply a
+/// compositor-managed output profile a second time.
+#[cfg(target_os = "linux")]
+pub fn detect_async_for_session(session: crate::linux_libs::DisplaySession) -> Option<Receiver<Detection>> {
+ (session == crate::linux_libs::DisplaySession::X11).then(|| spawn_reader(detect))
+}
+
+#[cfg(any(target_os = "macos", target_os = "linux"))]
+fn spawn_reader(detect: fn() -> Detection) -> Receiver<Detection> {
let (tx, rx) = std::sync::mpsc::channel();
std::thread::spawn(move || {
let _ = tx.send(detect());
});
- Some(rx)
+ rx
}
/// One line per screen, primary (menu-bar) screen first: id, frame (x, y, width, height in
@@ -110,9 +133,225 @@ fn run_helper(cmd: &mut std::process::Command, timeout: std::time::Duration) ->
Ok(String::from_utf8_lossy(&out).into_owned())
}
-#[cfg(not(target_os = "macos"))]
+#[cfg(target_os = "linux")]
fn detect() -> Detection {
- Err("this platform doesn't report display profiles".into())
+ linux::detect()
+}
+
+#[cfg(target_os = "linux")]
+mod linux {
+ use std::collections::{BTreeMap, HashMap};
+ use std::io::Read as _;
+ use std::path::Path;
+ use std::sync::Arc;
+ use std::time::Duration;
+
+ use photocraft_engine::display_color::Display;
+ use x11rb::connection::Connection as _;
+ use x11rb::protocol::randr;
+ use zbus::blocking::{connection::Builder, proxy::Proxy};
+ use zbus::zvariant::OwnedObjectPath;
+
+ use super::Detection;
+
+ const MAX_ICC_BYTES: usize = 64 * 1024 * 1024;
+ const COLORD: &str = "org.freedesktop.ColorManager";
+ const COLORD_ROOT: &str = "/org/freedesktop/ColorManager";
+ const COLORD_MANAGER: &str = "org.freedesktop.ColorManager";
+ const COLORD_DEVICE: &str = "org.freedesktop.ColorManager.Device";
+ const COLORD_PROFILE: &str = "org.freedesktop.ColorManager.Profile";
+
+ struct IccProfile {
+ name: String,
+ bytes: Arc<Vec<u8>>,
+ }
+
+ pub(super) fn detect() -> Detection {
+ let (connection, screen) = x11rb::connect(None).map_err(|e| format!("couldn't connect to the X11 display: {e}"))?;
+ let root = connection.setup().roots.get(screen).ok_or_else(|| "the X11 server didn't provide a screen".to_string())?.root;
+ let resources = randr::get_screen_resources_current(&connection, root)
+ .map_err(|e| format!("couldn't request XRandR outputs: {e}"))?
+ .reply()
+ .map_err(|e| format!("couldn't read XRandR outputs: {e}"))?;
+
+ let mut output_names = HashMap::new();
+ let mut active_crtcs = BTreeMap::new();
+ for output in resources.outputs {
+ let info = match randr::get_output_info(&connection, output, resources.config_timestamp) {
+ Ok(cookie) => match cookie.reply() {
+ Ok(info) => info,
+ Err(e) => {
+ log::debug!("couldn't read one XRandR output: {e}");
+ continue;
+ }
+ },
+ Err(e) => {
+ log::debug!("couldn't request one XRandR output: {e}");
+ continue;
+ }
+ };
+ if info.connection != randr::Connection::CONNECTED || info.crtc == 0 {
+ continue;
+ }
+ let Ok(name) = String::from_utf8(info.name) else {
+ log::debug!("skipping an XRandR output with a non-UTF-8 name");
+ continue;
+ };
+ if !name.is_empty() {
+ output_names.insert(output, name);
+ active_crtcs.insert(info.crtc, ());
+ }
+ }
+
+ let profiles = match colord_profiles() {
+ Ok(profiles) => profiles,
+ Err(e) => {
+ log::warn!("couldn't read X11 display profiles from colord: {e}");
+ HashMap::new()
+ }
+ };
+ let mut displays = Vec::with_capacity(active_crtcs.len());
+ for crtc in active_crtcs.into_keys() {
+ let crtc_info = match randr::get_crtc_info(&connection, crtc, resources.config_timestamp) {
+ Ok(cookie) => match cookie.reply() {
+ Ok(info) if info.status == randr::SetConfig::SUCCESS && info.width > 0 && info.height > 0 => info,
+ Ok(_) => continue,
+ Err(e) => {
+ log::debug!("couldn't read XRandR CRTC {crtc}: {e}");
+ continue;
+ }
+ },
+ Err(e) => {
+ log::debug!("couldn't request XRandR CRTC {crtc}: {e}");
+ continue;
+ }
+ };
+ let Some(output_names) = crtc_info.outputs.iter().map(|output| output_names.get(output).cloned()).collect::<Option<Vec<_>>>() else { continue };
+ let Some(primary_name) = output_names.first() else { continue };
+ let profile = unambiguous_clone_profile(&output_names, &profiles);
+ displays.push(Display {
+ id: crtc,
+ name: primary_name.clone(),
+ frame: [f64::from(crtc_info.x), f64::from(crtc_info.y), f64::from(crtc_info.width), f64::from(crtc_info.height)],
+ profile_name: profile.as_ref().map(|p| p.name.clone()),
+ icc: profile.map(|p| p.bytes),
+ });
+ }
+ if displays.is_empty() {
+ return Err("X11 reported no active RandR outputs".into());
+ }
+ Ok(displays)
+ }
+
+ fn colord_profiles() -> Result<HashMap<String, Vec<IccProfile>>, String> {
+ let connection = Builder::system()
+ .map_err(|e| format!("couldn't connect to the system bus: {e}"))?
+ .method_timeout(Duration::from_secs(2))
+ .build()
+ .map_err(|e| format!("couldn't connect to the system bus: {e}"))?;
+ let manager = Proxy::new(&connection, COLORD, COLORD_ROOT, COLORD_MANAGER).map_err(|e| format!("couldn't access colord: {e}"))?;
+ let devices: Vec<OwnedObjectPath> =
+ manager.call("GetDevicesByKind", &("display",)).map_err(|e| format!("colord couldn't list display devices: {e}"))?;
+ let mut profiles: HashMap<String, Vec<IccProfile>> = HashMap::new();
+ for device_path in devices {
+ let device = Proxy::new(&connection, COLORD, &device_path, COLORD_DEVICE).map_err(|e| format!("couldn't access a colord display device: {e}"))?;
+ let metadata: HashMap<String, String> = device.get_property("Metadata").map_err(|e| format!("couldn't read colord display metadata: {e}"))?;
+ let Some(output_name) = metadata.get("XRANDR_name").filter(|name| !name.is_empty()) else { continue };
+ // `*` is colord's default profile qualifier. A display without one is kept, with no
+ // ICC, so the engine reports the normal sRGB fallback.
+ let profile_path: OwnedObjectPath = match device.call("GetProfileForQualifiers", &(vec!["*"],)) {
+ Ok(path) => path,
+ Err(_) => continue,
+ };
+ let profile = Proxy::new(&connection, COLORD, &profile_path, COLORD_PROFILE).map_err(|e| format!("couldn't access a colord ICC profile: {e}"))?;
+ let filename: String = match profile.get_property::<String>("Filename") {
+ Ok(filename) if !filename.is_empty() => filename,
+ _ => continue,
+ };
+ let Some(profile) = read_icc(Path::new(&filename)) else {
+ log::warn!("couldn't read a valid ICC profile assigned to X11 output {output_name}");
+ continue;
+ };
+ profiles.entry(output_name.clone()).or_default().push(profile);
+ }
+ Ok(profiles)
+ }
+
+ fn read_icc(path: &Path) -> Option<IccProfile> {
+ let mut bytes = Vec::new();
+ std::fs::File::open(path).ok()?.take((MAX_ICC_BYTES + 1) as u64).read_to_end(&mut bytes).ok()?;
+ let bytes = checked_icc_bytes(bytes)?;
+ let name = path.file_name()?.to_str()?.to_owned();
+ Some(IccProfile { name, bytes: Arc::new(bytes) })
+ }
+
+ fn checked_icc_bytes(mut bytes: Vec<u8>) -> Option<Vec<u8>> {
+ if bytes.len() > MAX_ICC_BYTES || bytes.len() < 132 || bytes.get(36..40) != Some(b"acsp") {
+ return None;
+ }
+ let declared = u32::from_be_bytes(bytes.get(0..4)?.try_into().ok()?) as usize;
+ if declared < 132 || declared > bytes.len() {
+ return None;
+ }
+ bytes.truncate(declared);
+ let profile = photocraft_cms::Profile::parse(&bytes).ok()?;
+ (profile.color_space == photocraft_cms::ColorSpace::Rgb).then_some(bytes)
+ }
+
+ fn unambiguous_clone_profile(output_names: &[String], profiles: &HashMap<String, Vec<IccProfile>>) -> Option<IccProfile> {
+ let mut selected: Option<&IccProfile> = None;
+ for output in output_names {
+ let candidates = profiles.get(output)?;
+ let first = candidates.first()?;
+ if candidates.iter().any(|candidate| candidate.bytes != first.bytes) {
+ return None;
+ }
+ if selected.is_some_and(|profile| profile.bytes != first.bytes) {
+ return None;
+ }
+ selected = Some(first);
+ }
+ selected.map(|profile| IccProfile { name: profile.name.clone(), bytes: profile.bytes.clone() })
+ }
+
+ #[cfg(test)]
+ mod tests {
+ use super::*;
+
+ #[test]
+ fn checked_icc_bytes_require_a_bounded_parseable_rgb_profile() {
+ let rgb = photocraft_cms::Builtin::Srgb.profile().to_bytes();
+ let bytes = rgb.as_ref().clone();
+ assert_eq!(checked_icc_bytes(bytes.clone()), Some(bytes));
+
+ let cmyk = photocraft_cms::Builtin::CoatedCmyk.profile().to_bytes();
+ assert!(checked_icc_bytes(cmyk.as_ref().clone()).is_none());
+ assert!(checked_icc_bytes(vec![0; 132]).is_none());
+ assert!(checked_icc_bytes(vec![0; MAX_ICC_BYTES + 1]).is_none());
+ }
+
+ #[test]
+ fn cloned_outputs_use_only_one_unambiguous_profile() {
+ let srgb = photocraft_cms::Builtin::Srgb.profile().to_bytes();
+ let p3 = photocraft_cms::Builtin::DisplayP3.profile().to_bytes();
+ let profile = |name: &str, bytes: std::sync::Arc<Vec<u8>>| IccProfile { name: name.into(), bytes };
+ let outputs = ["DP-1".to_owned(), "HDMI-1".to_owned()];
+
+ let matching =
+ HashMap::from([("DP-1".to_owned(), vec![profile("sRGB", srgb.clone())]), ("HDMI-1".to_owned(), vec![profile("sRGB", srgb.clone())])]);
+ assert_eq!(unambiguous_clone_profile(&outputs, &matching).map(|p| p.name), Some("sRGB".into()));
+
+ let differing =
+ HashMap::from([("DP-1".to_owned(), vec![profile("sRGB", srgb.clone())]), ("HDMI-1".to_owned(), vec![profile("Display P3", p3.clone())])]);
+ assert!(unambiguous_clone_profile(&outputs, &differing).is_none());
+
+ let missing = HashMap::from([("DP-1".to_owned(), vec![profile("sRGB", srgb.clone())])]);
+ assert!(unambiguous_clone_profile(&outputs, &missing).is_none());
+
+ let conflicting = HashMap::from([("DP-1".to_owned(), vec![profile("sRGB", srgb), profile("Display P3", p3)])]);
+ assert!(unambiguous_clone_profile(&["DP-1".to_owned()], &conflicting).is_none());
+ }
+ }
}
/// The helper's reply ([`SCRIPT`]) → displays, frames flipped to a top-left origin with y down
@@ -285,6 +524,7 @@ mod tests {
}
/// On a Mac, every display is read, and the profiles parse as RGB profiles.
+ #[cfg(any(target_os = "macos", target_os = "linux"))]
#[test]
fn detected_displays_parse() {
if let Ok(displays) = detect() {
diff --git a/crates/ui-egui/src/lib.rs b/crates/ui-egui/src/lib.rs
index bacb7bb0e..9d80288b6 100644
--- a/crates/ui-egui/src/lib.rs
+++ b/crates/ui-egui/src/lib.rs
@@ -1542,7 +1542,7 @@ impl eframe::App for PhotocraftApp {
self.collect_screenshots(ctx);
self.issue_screenshots(ctx);
prefs_ui::tick(self, ctx);
- monitor_status::poll(self, ctx);
+ monitor_status::poll_frame(self, ctx, frame);
// Control requests and persisted preferences can change the language in this frame.
i18n::sync_context(ctx, &self.session.prefs().interface.language);
type_tool::sync_font_names(ctx, self.session.prefs().type_.show_font_names_in_english);
diff --git a/crates/ui-egui/src/monitor_status.rs b/crates/ui-egui/src/monitor_status.rs
index 1f0d03a5d..8e29b8c2f 100644
--- a/crates/ui-egui/src/monitor_status.rs
+++ b/crates/ui-egui/src/monitor_status.rs
@@ -36,6 +36,8 @@ pub const REREAD_SECS: f64 = 30.0;
#[derive(Default)]
pub struct State {
pending: Option<Receiver<Detection>>,
+ #[cfg(target_os = "linux")]
+ root_output_name: Option<String>,
/// Another reading is wanted once the pending one is done or the interval has passed.
again: bool,
/// A reading is wanted at once (ignores the interval).
@@ -64,6 +66,22 @@ pub fn pending(app: &mut PhotocraftApp, rx: Receiver<Detection>) {
/// Per-frame (main window): apply a reading that arrived, track the main window's display, and
/// start a new reading when the displays may have changed.
pub fn poll(app: &mut PhotocraftApp, ctx: &egui::Context) {
+ poll_with_output_name(app, ctx, None);
+}
+
+#[cfg(target_os = "linux")]
+pub fn poll_frame(app: &mut PhotocraftApp, ctx: &egui::Context, frame: &eframe::Frame) {
+ let output_name = frame.winit_window().and_then(|window| window.current_monitor()).and_then(|monitor| monitor.name());
+ poll_with_output_name(app, ctx, output_name);
+}
+
+#[cfg(not(target_os = "linux"))]
+pub fn poll_frame(app: &mut PhotocraftApp, ctx: &egui::Context, _frame: &eframe::Frame) {
+ poll(app, ctx);
+}
+
+fn poll_with_output_name(app: &mut PhotocraftApp, ctx: &egui::Context, output_name: Option<String>) {
+ set_root_output_name(app, output_name);
if let Some(rx) = &app.monitors.pending {
let r = match rx.try_recv() {
Ok(r) => Some(r),
@@ -228,17 +246,60 @@ fn window_frame(ctx: &egui::Context) -> Option<[f64; 4]> {
/// The display showing most of the window `ctx` draws (`None`: unknown, e.g. no displays read
/// or no window position, as on Wayland).
pub fn view_display(app: &PhotocraftApp, ctx: &egui::Context) -> Option<u32> {
+ display_for_view(app, ctx)
+}
+
+fn display_for_view(app: &PhotocraftApp, ctx: &egui::Context) -> Option<u32> {
+ if let Some(display) = root_output_display(app, ctx) {
+ return display;
+ }
display_at(&app.session.color.displays, window_frame(ctx)?)
}
+#[cfg(target_os = "linux")]
+fn set_root_output_name(app: &mut PhotocraftApp, name: Option<String>) {
+ app.monitors.root_output_name = name;
+}
+
+#[cfg(not(target_os = "linux"))]
+fn set_root_output_name(_app: &mut PhotocraftApp, _name: Option<String>) {}
+
+#[cfg(target_os = "linux")]
+fn root_output_display(app: &PhotocraftApp, ctx: &egui::Context) -> Option<Option<u32>> {
+ if ctx.viewport_id() != egui::ViewportId::ROOT {
+ return None;
+ }
+ let name = app.monitors.root_output_name.as_deref()?;
+ Some(app.session.color.displays.iter().find(|display| display.name == name).map(|display| display.id))
+}
+
+#[cfg(not(target_os = "linux"))]
+fn root_output_display(_app: &PhotocraftApp, _ctx: &egui::Context) -> Option<Option<u32>> {
+ None
+}
+
+#[cfg(target_os = "linux")]
+fn root_output_name_known(app: &PhotocraftApp, ctx: &egui::Context) -> bool {
+ ctx.viewport_id() == egui::ViewportId::ROOT && app.monitors.root_output_name.is_some()
+}
+
+#[cfg(not(target_os = "linux"))]
+fn root_output_name_known(_app: &PhotocraftApp, _ctx: &egui::Context) -> bool {
+ false
+}
+
/// The window is on no display we know, or on one whose size differs from what was read.
fn displays_changed(app: &PhotocraftApp, ctx: &egui::Context) -> bool {
let c = &app.session.color;
if c.displays.is_empty() || !matches!(c.monitor_detection, MonitorDetection::Found | MonitorDetection::Retained { .. }) {
return false;
}
- let Some(frame) = window_frame(ctx) else { return false };
- let Some(d) = display_at(&c.displays, frame).and_then(|id| c.displays.iter().find(|d| d.id == id)) else { return true };
+ let Some(d) = display_for_view(app, ctx).and_then(|id| c.displays.iter().find(|d| d.id == id)) else {
+ if root_output_name_known(app, ctx) {
+ return true;
+ }
+ return window_frame(ctx).is_some();
+ };
// egui's monitor size is the window's display (winit's rule, AppKit's on macOS).
let size = ctx.input(|i| i.viewport().monitor_size);
let native = ctx.input(|i| i.viewport().native_pixels_per_point).filter(|n| *n > 0.0);
@@ -531,4 +592,20 @@ mod tests {
assert!(app.ui.notices.is_empty());
assert!(summary_lines(&app).iter().all(|l| l.contains("(manual)")), "{:?}", summary_lines(&app));
}
+
+ #[cfg(target_os = "linux")]
+ #[test]
+ fn root_window_uses_winit_monitor_name_to_select_its_profile() {
+ let mut app = app();
+ app.session.color.set_displays(Ok(vec![
+ Display { id: 1, name: "DP-1".into(), frame: [0.0, 0.0, 1920.0, 1080.0], profile_name: None, icc: None },
+ Display { id: 2, name: "HDMI-1".into(), frame: [1920.0, 0.0, 1920.0, 1080.0], profile_name: None, icc: None },
+ ]));
+ app.monitors.root_output_name = Some("HDMI-1".into());
+ let ctx = egui::Context::default();
+
+ assert_eq!(view_display(&app, &ctx), Some(2));
+ app.monitors.root_output_name = Some("DP-3".into());
+ assert_eq!(view_display(&app, &ctx), None);
+ }
}
diff --git a/docs/architecture.md b/docs/architecture.md
index 893617a92..7856636cc 100644
--- a/docs/architecture.md
+++ b/docs/architecture.md
@@ -349,7 +349,7 @@ Both backends consume the same plan. This is the only place that encodes Photosh
- Blending happens in document space by default, which is Photoshop-compatible. A per-document "linear light blending" option is also available.
- **Display transform** (`engine/src/display_color.rs`): the canvas is always colour-managed, document profile → monitor profile (relative colorimetric + BPC), cached per (document profile, mode, monitor). On the GPU canvas the transform, plus Proof Colors / Gamut Warning / 32-bit preview, is baked into a 33³ 3D LUT the canvas shader's final pass applies; the CPU canvas runs an 8-bit `photocraft-cms` transform on the composite. When the document profile matches the monitor (sRGB on sRGB) there is no LUT and no transform. Linear composites (EXR/HDR, tagged linear sRGB on import) are stored sRGB-encoded in the 8-bit canvas texture. CMYK documents are read through their embedded CMYK profile (`photocraft_color::convert::with_cmyk_space`, entered by the compositors and composite exports).
-- **Monitor profile:** Edit › Color Settings › Monitor Profile: `auto`, a built-in RGB profile or an `.icc` path. In `auto` each window uses the profile of the display it is on (#569): the desktop app reads every display's id, name, frame and ICC profile (macOS: AppKit `NSScreen` through `osascript`, no FFI) at launch and again when the app comes back to the front, when any window is on an unknown or resized display (at most every 30 s; a trigger inside that window is deferred) and when Edit › Color Settings opens (`ui-egui/src/monitor_status.rs`; the helper is stopped after 10 s). There is deliberately no periodic re-read (#569 decision: a read costs about 0.2 s of CPU), so a profile reassigned while PhotoCraft stays in front with no window moving is picked up at the next return to the front or Color Settings, and each window picks the display it overlaps most (`display_color::display_at`, AppKit's `NSWindow.screen` rule). Elsewhere `auto` is sRGB. The GPU canvas keeps one texture per document and a display LUT per (document, display); CPU canvas textures are per (document, display). `ColorState::monitor_status_for` says what is applied per display: `auto`, `manual`, or `fallback` to sRGB with the reason (missing, unreadable, non-RGB or unusable as a destination), and whether the reading is an earlier one kept after a failed re-read; `edit.colorSettings` (`monitorStatus`, `displays`), Help › System Info and the Color Settings dialog show it, and a fallback in `auto` posts a notice. Letting macOS colour-match the canvas instead is #581 (an architecture decision).
+- **Monitor profile:** Edit › Color Settings › Monitor Profile: `auto`, a built-in RGB profile or an `.icc` path. In `auto` each window uses the profile of the display it is on (#569): the desktop app reads every display's id, name, frame and ICC profile at launch and again when the app comes back to the front, when any window is on an unknown or resized display (at most every 30 s; a trigger inside that window is deferred) and when Edit › Color Settings opens (`ui-egui/src/monitor_status.rs`). macOS reads AppKit `NSScreen` through `osascript` (no FFI); X11 reads RandR outputs and the default colord profile matched by exact `XRANDR_name`; native Wayland and Xwayland windows from a Wayland session stay on sRGB because eframe/winit cannot safely set the app surface's Wayland image description. The macOS helper is stopped after 10 s. There is deliberately no periodic re-read (#569 decision: a read costs about 0.2 s of CPU), so a profile reassigned while PhotoCraft stays in front with no window moving is picked up at the next return to the front or Color Settings. X11 selects the root window's RandR output by winit's current-monitor name and other windows by their overlapping RandR frame; macOS follows `NSWindow.screen`. Elsewhere `auto` is sRGB. The GPU canvas keeps one texture per document and a display LUT per (document, display); CPU canvas textures are per (document, display). `ColorState::monitor_status_for` says what is applied per display: `auto`, `manual`, or `fallback` to sRGB with the reason (missing, unreadable, non-RGB or unusable as a destination), and whether the reading is an earlier one kept after a failed re-read; `edit.colorSettings` (`monitorStatus`, `displays`), Help › System Info and the Color Settings dialog show it, and a fallback in `auto` posts a notice. Letting macOS colour-match the canvas instead is #581 (an architecture decision).
- **HDR/EDR output** (an `rgba16float` surface with an extended-range colorspace) is a later-phase feature. The interfaces already carry `f32` pixels.
### 7.4 Oracle