From 1d70f5d6bf943474cbff61568cc290e0217627f8 Mon Sep 17 00:00:00 2001 From: Daniel Miguel Date: Wed, 21 Oct 2026 20:02:27 +0200 Subject: [PATCH] M0: default to the system title bar on Linux and preserve saved choices --- ROADMAP.md | 1 + apps/photocraft/src/main.rs | 18 ++++++++++-------- crates/engine/src/prefs.rs | 5 +++-- crates/engine/src/prefs/tests.rs | 16 ++++++++++++++++ crates/ui-egui/src/panels.rs | 5 +++-- crates/ui-egui/src/prefs_ui.rs | 7 ++++--- docs/development.md | 2 +- 7 files changed, 38 insertions(+), 16 deletions(-) diff --git a/ROADMAP.md b/ROADMAP.md index f41b71bfc9..aa6b993ab0 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -122,6 +122,7 @@ Detail and the next releases: [docs/roadmap.md](docs/roadmap.md). | Date | Entry | |---|---| +| 2026-10-21 | Linux defaults to System Title Bar so GNOME/Wayland has window controls. Saved choices and other platform defaults are preserved; startup and preference-dialog regressions cover both choices (#6266). | | 2026-10-10 | Full re-measure against Photoshop 2026 27.11.0 (installed bundle inspected): breadth ~76%, ready ~45%, alpha. Progress docs reorganized to the craftrules standard (`parity.md` → `parity-checklist.md`, `parity-estimate.md` merged into `target-app-parity.md`). 0.6.0 released. | | 2026-10-09 | Remove tool, Rotate View, crop rotation; OpenRaster and Paint.NET; 39 Affinity documents in the corpus | | 2026-10-08 | 0.5.0. Affinity import; Magnetic Lasso, Pattern Stamp, Mixer Brush, Pencil, Patch, Vertical Type on the toolbar | diff --git a/apps/photocraft/src/main.rs b/apps/photocraft/src/main.rs index b0b00a865c..8a1f6d7351 100644 --- a/apps/photocraft/src/main.rs +++ b/apps/photocraft/src/main.rs @@ -83,14 +83,13 @@ use photocraft_ui_egui::PhotocraftApp; /// Matches the `.desktop` file and hicolor icon name, so Wayland docks pick up the icon. const APP_ID: &str = "ai.storyteller.photocraft"; -/// Windows and Linux: no OS title bar; the app's top bar is the title bar, with its own caption -/// buttons and edge resizing (`photocraft_ui_egui::titlebar`), as Photoshop does on Windows. macOS -/// keeps its traffic lights over the integrated title strip. +/// Windows and Linux can use the app's title bar, with its own caption buttons and edge resizing +/// (`photocraft_ui_egui::titlebar`); the preference below selects the mode. macOS always keeps its +/// system traffic lights over the integrated title strip. const CUSTOM_TITLEBAR: bool = !cfg!(target_os = "macos"); -/// Whether this start draws its own title bar: Windows and Linux do, unless Preferences › -/// Interface › System Title Bar asks for the system's (#1271, #1316). Read from the saved -/// preferences before the window opens; a missing or unreadable file keeps the default. +/// Whether this start draws its own title bar. Linux defaults to the system frame; Windows +/// defaults to the in-app title bar. Saved preferences override those defaults (#1271, #1316). fn custom_titlebar(prefs_file: Option<&std::path::Path>) -> bool { let prefs: photocraft_engine::prefs::Preferences = prefs_file.and_then(|p| std::fs::read_to_string(p).ok()).and_then(|t| serde_json::from_str(&t).ok()).unwrap_or_default(); @@ -1027,9 +1026,12 @@ mod tests { let dir = std::env::temp_dir().join(format!("pc-titlebar-{}", std::process::id())); std::fs::create_dir_all(&dir).unwrap(); let file = dir.join("prefs.json"); - assert_eq!(super::custom_titlebar(None), super::CUSTOM_TITLEBAR, "no preferences file: the default"); + let default_custom = super::CUSTOM_TITLEBAR && !cfg!(target_os = "linux"); + assert_eq!(super::custom_titlebar(None), default_custom, "no preferences file: the platform default"); std::fs::write(&file, "not json").unwrap(); - assert_eq!(super::custom_titlebar(Some(&file)), super::CUSTOM_TITLEBAR, "an unreadable file: the default"); + assert_eq!(super::custom_titlebar(Some(&file)), default_custom, "an unreadable file: the platform default"); + std::fs::write(&file, r#"{"interface":{}}"#).unwrap(); + assert_eq!(super::custom_titlebar(Some(&file)), default_custom, "an older preference file: the platform default"); std::fs::write(&file, r#"{"interface":{"systemTitleBar":true}}"#).unwrap(); assert!(!super::custom_titlebar(Some(&file))); assert_eq!(super::native_options(false).viewport.decorations, Some(true)); diff --git a/crates/engine/src/prefs.rs b/crates/engine/src/prefs.rs index 77acd2e346..c2c06d767e 100644 --- a/crates/engine/src/prefs.rs +++ b/crates/engine/src/prefs.rs @@ -284,7 +284,8 @@ pub struct Interface { pub show_bounding_box_when_dragging_layer: bool, /// Windows and Linux: use the system's title bar and window buttons instead of PhotoCraft's /// own one-row title bar (tiling window managers, desktops that draw their own decorations; - /// #1271, #1316). Read when the app starts. macOS always uses the system's. + /// #1271, #1316). Enabled by default on Linux, where GNOME/Wayland needs the client frame. + /// Read when the app starts. macOS always uses the system's. pub system_title_bar: bool, /// Show the active document's file name in the title bar and the OS window title. The tabs /// already name the file, so this can be turned off for a plain "PhotoCraft" title (#5037). @@ -320,7 +321,7 @@ impl Default for Interface { show_tooltips: true, enable_animations: true, show_bounding_box_when_dragging_layer: false, - system_title_bar: false, + system_title_bar: cfg!(target_os = "linux"), show_file_name_in_title: true, notification_auto_hide: true, notification_duration_seconds: 6, diff --git a/crates/engine/src/prefs/tests.rs b/crates/engine/src/prefs/tests.rs index 55e41949b9..e9fedd4800 100644 --- a/crates/engine/src/prefs/tests.rs +++ b/crates/engine/src/prefs/tests.rs @@ -1,5 +1,21 @@ use super::*; +#[test] +fn system_title_bar_defaults_by_platform_and_preserves_saved_choices() { + let default = cfg!(target_os = "linux"); + assert_eq!(Interface::default().system_title_bar, default); + for saved in [json!({}), json!({"interface": {}})] { + let prefs: Preferences = serde_json::from_value(saved).unwrap(); + assert_eq!(prefs.interface.system_title_bar, default); + } + for saved in [false, true] { + let prefs: Preferences = serde_json::from_value(json!({"interface": {"systemTitleBar": saved}})).unwrap(); + assert_eq!(prefs.interface.system_title_bar, saved); + let restored: Preferences = serde_json::from_value(prefs.to_json()).unwrap(); + assert_eq!(restored.interface.system_title_bar, saved); + } +} + fn session() -> Session { let mut s = Session::new(); s.execute("file.new", json!({"width": 32, "height": 32})).unwrap(); diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rs index 04e775439e..5af5b96183 100644 --- a/crates/ui-egui/src/panels.rs +++ b/crates/ui-egui/src/panels.rs @@ -801,8 +801,9 @@ mod title_tests { #[test] fn without_the_preference_the_mark_stays() { - // The default (e.g. the web build or the snapshot example): no custom bar, no preference. - let app = crate::PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default()); + // An explicit choice to keep the app's title, independent of the platform default. + let mut app = crate::PhotocraftApp::new(photocraft_engine::Session::new(), crate::Services::default()); + app.session.edit_prefs(|p| p.interface.system_title_bar = false); assert!(!system_title_bar(&app)); } diff --git a/crates/ui-egui/src/prefs_ui.rs b/crates/ui-egui/src/prefs_ui.rs index d808ae32f4..5bf06fe971 100644 --- a/crates/ui-egui/src/prefs_ui.rs +++ b/crates/ui-egui/src/prefs_ui.rs @@ -3795,6 +3795,7 @@ mod tests { let (mut app, store) = app_with_store(); app.run("prefs.set", json!({"values": {"interface.language": "en"}})).unwrap(); + let initial = app.session.prefs().interface.system_title_bar; app.custom_titlebar = true; let id = open_preferences(&mut app, "interface"); let mut h = Harness::builder().with_size(vec2(1280.0, 800.0)).build_eframe(move |cc| { @@ -3805,7 +3806,7 @@ mod tests { h.get_by_label("System title bar").scroll_to_me(); h.run_steps(4); h.get_by_label("Applies at next launch."); - for desired in [true, false] { + for desired in [!initial, initial] { h.get_by_label("System title bar").click(); h.run_steps(4); assert_eq!(h.state().ui.dialogs.iter().find(|d| d.id == id).unwrap().fields["values"]["interface"]["systemTitleBar"], desired); @@ -3825,8 +3826,8 @@ mod tests { h.get_by_label("Cancel").click(); h.run_steps(4); assert!(h.state().ui.dialogs.iter().all(|d| d.id != id)); - assert!(!h.state().session.prefs().interface.system_title_bar); - assert_eq!(stored(&store)["interface"]["systemTitleBar"], false); + assert_eq!(h.state().session.prefs().interface.system_title_bar, initial); + assert_eq!(stored(&store)["interface"]["systemTitleBar"], initial); assert!(h.state().custom_titlebar); } diff --git a/docs/development.md b/docs/development.md index fcf3339b7d..fcab7b7fc1 100644 --- a/docs/development.md +++ b/docs/development.md @@ -34,7 +34,7 @@ building locally; the downloaded app is still subject to Windows application-con ## Build and run -On GNOME/Wayland, **System Title Bar** uses winit's font-free Adwaita controls; existing custom-title-bar preferences and defaults are unchanged. +On Linux, **System Title Bar** is enabled by default. GNOME/Wayland uses winit's font-free Adwaita controls; X11 uses the window manager's frame. Saved choices still override the default, and other platforms keep their existing defaults. Changes in Preferences apply at the next launch. ```sh cargo run --release -p photocraft -- path/to/image.psd # desktop app