From 5d768e79d1d18a7032a133c770149ea2c446d12c Mon Sep 17 00:00:00 2001 From: OneSlips Date: Thu, 22 Oct 2026 16:21:39 +1000 Subject: [PATCH 1/8] WP5-WINDOW: Windows opens a maximized window maximized Built maximized (with_maximized at creation), the window could come up covering about half the screen while Windows took it for maximized; its maximize button then restored it, smaller. On Windows the window is now built at its remembered size and maximized once it shows, on its own screen (window_place::StartPlace, fed each frame by the desktop app's PrefsWriter); if it then says it is maximized but doesn't fill its screen it is restored and maximized again, once. A window remembered larger than the screen it opens on (a display unplugged, a smaller one) is fitted to it, on every platform. LR-BEHAV-WINDOW gets its tracker row (it was only in the revision history). Co-Authored-By: Claude Opus 5.5 (cherry picked from commit d333b8666782c930165deb28d9396063482cb670) --- apps/lightcraft/src/main.rs | 39 +++++++-- crates/ui-egui/src/window_place.rs | 135 +++++++++++++++++++++++++++++ docs/parity-checklist.md | 4 +- 3 files changed, 171 insertions(+), 7 deletions(-) diff --git a/apps/lightcraft/src/main.rs b/apps/lightcraft/src/main.rs index 2193666fd1..8c76de2529 100644 --- a/apps/lightcraft/src/main.rs +++ b/apps/lightcraft/src/main.rs @@ -231,13 +231,24 @@ fn config_dir() -> Option { /// The window at the size it was last used at, zoomed if it was (`window`), or at the usual size /// when nothing is remembered. A zoomed window is given the size it goes back to. Where it /// opens is the system's to say. -fn as_remembered(builder: egui::ViewportBuilder, window: Option) -> egui::ViewportBuilder { +/// +/// Windows: a window built maximized could open covering half the screen while +/// the system took it for maximized, so there (`maximize_later`) it is built at its size and +/// maximized once it shows ([`lightcraft_ui_egui::window_place::StartPlace`]). +fn as_remembered( + builder: egui::ViewportBuilder, + window: Option, + maximize_later: bool, +) -> egui::ViewportBuilder { let builder = builder.with_inner_size(window.map_or(lightcraft_ui_egui::window_place::DEFAULT_SIZE, |w| w.size)); // (only ever asked to zoom: asked not to, macOS un-zooms a window whose size fills the screen // to a size of its own choosing) - if window.is_some_and(|w| w.zoomed) { builder.with_maximized(true) } else { builder } + if window.is_some_and(|w| w.zoomed) && !maximize_later { builder.with_maximized(true) } else { builder } } +/// Windows maximizes a remembered maximized window once it shows (see [`as_remembered`]). +const MAXIMIZE_LATER: bool = cfg!(target_os = "windows"); + /// `/ui.json`, the saved UI state and app settings — `None` when nothing is read or /// written: `LIGHTCRAFT_NO_PREFS` (tests, scripts) or no home folder. fn prefs_path() -> Option { @@ -361,6 +372,9 @@ struct PrefsWriter { /// When the window was first looked at: its watch goes by the clock from then on, not by /// the interface's time, which stands still while the window is hidden. window_since: Option, + /// The window as it first shows: maximized then on Windows, fitted to a smaller screen. + /// `None` once done, and in tests. + start: Option, } impl PrefsWriter { @@ -412,6 +426,15 @@ impl PrefsWriter { // the settings hold is checked first: a script may have set it (`ui.set`) let remembered = app.ui.window.and_then(lightcraft_ui_egui::window_place::WindowPlace::checked); let at = self.window_since.get_or_insert_with(std::time::Instant::now).elapsed().as_secs_f64(); + if let Some(start) = &mut self.start { + for command in start.step(&seen, at) { + ctx.send_viewport_cmd(command); + } + match start.waits() { + Some(wait) => ctx.request_repaint_after(wait), + None => self.start = None, + } + } app.ui.window = self.window.note(remembered, &seen, at); if let Some(wait) = self.window.waits(at) { // (a size is only remembered once the window has rested at it: look again then, though @@ -953,7 +976,7 @@ fn main() -> eframe::Result { let opens_as = prefs.as_ref().and_then(|ui| ui.window).and_then(lightcraft_ui_egui::window_place::WindowPlace::checked); let options = eframe::NativeOptions { renderer, - viewport: as_remembered(egui::ViewportBuilder::default().with_title("LightCraft"), opens_as) + viewport: as_remembered(egui::ViewportBuilder::default().with_title("LightCraft"), opens_as, MAXIMIZE_LATER) .with_min_inner_size(lightcraft_ui_egui::window_place::MIN_SIZE) .with_drag_and_drop(true) .with_fullsize_content_view(true) @@ -1020,6 +1043,7 @@ fn main() -> eframe::Result { written: serde_json::to_vec_pretty(&app.ui).unwrap_or_default(), library: app.ui.settings.library_path.clone(), keep_file: keep_prefs_file, + start: Some(lightcraft_ui_egui::window_place::StartPlace::new(MAXIMIZE_LATER && opens_as.is_some_and(|w| w.zoomed))), ..Default::default() }; // after the snapshot above, so the writer saves the switched-off preference @@ -1498,12 +1522,15 @@ mod tests { #[test] fn the_window_opens_as_it_was() { use lightcraft_ui_egui::window_place::{DEFAULT_SIZE, WindowPlace}; - let fresh = as_remembered(egui::ViewportBuilder::default(), None); + let fresh = as_remembered(egui::ViewportBuilder::default(), None, false); assert_eq!((fresh.inner_size, fresh.position, fresh.maximized), (Some(egui::Vec2::from(DEFAULT_SIZE)), None, None)); - let b = as_remembered(egui::ViewportBuilder::default(), Some(WindowPlace { size: [1300.0, 800.0], zoomed: true })); + let b = as_remembered(egui::ViewportBuilder::default(), Some(WindowPlace { size: [1300.0, 800.0], zoomed: true }), false); assert_eq!((b.inner_size, b.position, b.maximized), (Some(egui::vec2(1300.0, 800.0)), None, Some(true))); + // Windows: built at its size, maximized once it shows + let b = as_remembered(egui::ViewportBuilder::default(), Some(WindowPlace { size: [1300.0, 800.0], zoomed: true }), true); + assert_eq!((b.inner_size, b.maximized), (Some(egui::vec2(1300.0, 800.0)), None)); // (not asked to un-zoom: macOS would then resize a window that fills its screen) - let b = as_remembered(egui::ViewportBuilder::default(), Some(WindowPlace { size: [1300.0, 800.0], zoomed: false })); + let b = as_remembered(egui::ViewportBuilder::default(), Some(WindowPlace { size: [1300.0, 800.0], zoomed: false }), false); assert_eq!((b.inner_size, b.position, b.maximized), (Some(egui::vec2(1300.0, 800.0)), None, None)); } diff --git a/crates/ui-egui/src/window_place.rs b/crates/ui-egui/src/window_place.rs index e88cca9a1e..9968752471 100644 --- a/crates/ui-egui/src/window_place.rs +++ b/crates/ui-egui/src/window_place.rs @@ -318,6 +318,100 @@ impl WindowWatch { } } +/// How long after the window first shows it is maximized (Windows): a frame or two, so that it is on +/// its screen and the system maximizes it to that screen's work area. +const MAXIMIZE_AFTER_SECONDS: f64 = 0.1; +/// How long after asking the window is checked: the system animates a maximize. +const MAXIMIZE_CHECK_SECONDS: f64 = 0.6; +/// A maximized window this much of its screen across, and down, fills it (the taskbar, and the +/// borders Windows keeps off screen, take the rest). +const MAXIMIZED_ACROSS: f32 = 0.9; +const MAXIMIZED_DOWN: f32 = 0.75; +/// A window opened larger than its screen is fitted to this much of it. +const FIT_TO_SCREEN: f32 = 0.9; + +/// The window as it first shows. On Windows a window built maximized could open +/// covering half the screen while the system took it for maximized: its maximize button then +/// restored it, smaller. So there it opens at its remembered size and is maximized once it is on its +/// screen ([`StartPlace::new`] with `maximize_after`); if it then says it is maximized but doesn't +/// fill its screen, it is restored and maximized again, once. A window remembered larger than the +/// screen it opens on (a display unplugged, a smaller one, another scale) is fitted to that screen. +#[derive(Debug)] +pub struct StartPlace { + /// Maximize once the window shows. + maximize: bool, + /// When it was asked to (seconds), and whether it has been asked again. + asked: Option, + retried: bool, + /// When the window first showed. + shown: Option, + done: bool, +} + +impl StartPlace { + /// `maximize_after`: the window was built at its size and should be maximized once it shows. + pub fn new(maximize_after: bool) -> StartPlace { + StartPlace { maximize: maximize_after, asked: None, retried: false, shown: None, done: false } + } + + /// Whether there is nothing more to do. + pub fn done(&self) -> bool { + self.done + } + + /// The window is `seen` at time `now` (seconds): what to tell it. + pub fn step(&mut self, seen: &Seen, now: f64) -> Vec { + if self.done || seen.full_screen || seen.minimized { + return Vec::new(); + } + let (Some(size), Some(screen)) = (seen.size, seen.screen) else { + // (not shown yet, or its screen unknown: wait, but not for ever) + if self.shown.is_some_and(|t| now - t > 5.0) { + self.done = true; + } + return Vec::new(); + }; + let shown = *self.shown.get_or_insert(now); + if !self.maximize { + self.done = true; + // remembered larger than this screen: fitted to it + if !seen.zoomed && (size[0] > screen[0] + SAME_WITHIN || size[1] > screen[1] + SAME_WITHIN) { + let fit = [(screen[0] * FIT_TO_SCREEN).max(MIN_SIZE[0]), (screen[1] * FIT_TO_SCREEN).max(MIN_SIZE[1])]; + return vec![egui::ViewportCommand::InnerSize(egui::vec2(fit[0], fit[1]))]; + } + return Vec::new(); + } + let fills = size[0] >= screen[0] * MAXIMIZED_ACROSS && size[1] >= screen[1] * MAXIMIZED_DOWN; + match self.asked { + None if now - shown >= MAXIMIZE_AFTER_SECONDS => { + self.asked = Some(now); + vec![egui::ViewportCommand::Maximized(true)] + } + None => Vec::new(), + Some(at) if now - at < MAXIMIZE_CHECK_SECONDS => Vec::new(), + Some(_) if seen.zoomed && fills => { + self.done = true; + Vec::new() + } + Some(_) if !self.retried => { + // maximized in name only (or not at all): restore it, and maximize it again + self.retried = true; + self.asked = Some(now); + vec![egui::ViewportCommand::Maximized(false), egui::ViewportCommand::Maximized(true)] + } + Some(_) => { + self.done = true; + Vec::new() + } + } + } + + /// When to look again while it waits (the app may have nothing else to draw). + pub fn waits(&self) -> Option { + (!self.done).then(|| std::time::Duration::from_millis(100)) + } +} + #[cfg(test)] mod tests { use super::*; @@ -916,4 +1010,45 @@ mod tests { assert_eq!(place(size, false).checked(), None, "{size:?}"); } } + + /// Client note 17: on Windows the window opens at its size and is maximized once it shows; a + /// window that says it is maximized but covers half its screen is restored and maximized again, + /// once; a window remembered larger than its screen is fitted to it. + #[test] + fn the_window_is_maximized_once_it_shows_and_again_if_it_only_says_so() { + use egui::ViewportCommand as C; + let mut s = StartPlace::new(true); + assert!(s.step(&Seen::default(), 0.0).is_empty(), "not shown yet"); + assert!(s.step(&window([1300.0, 800.0]), 0.0).is_empty(), "a frame first"); + assert_eq!(s.step(&window([1300.0, 800.0]), 0.2), vec![C::Maximized(true)]); + assert!(s.step(&window([1300.0, 800.0]), 0.3).is_empty(), "the system animates"); + // maximized in name, half the screen: once more + let half = Seen { zoomed: true, ..window([1280.0, 1400.0]) }; + assert_eq!(s.step(&half, 1.0), vec![C::Maximized(false), C::Maximized(true)]); + let full = Seen { zoomed: true, ..window([2560.0, 1392.0]) }; + assert!(s.step(&full, 1.2).is_empty()); + assert!(s.step(&full, 1.7).is_empty() && s.done()); + assert_eq!(s.waits(), None); + // it filled its screen the first time: nothing more + let mut s = StartPlace::new(true); + s.step(&window([1300.0, 800.0]), 0.0); + s.step(&window([1300.0, 800.0]), 0.2); + assert!(s.step(&full, 1.0).is_empty() && s.done()); + // never more than one retry + let mut s = StartPlace::new(true); + s.step(&window([1300.0, 800.0]), 0.0); + s.step(&window([1300.0, 800.0]), 0.2); + assert_eq!(s.step(&half, 1.0).len(), 2); + assert!(s.step(&half, 2.0).is_empty() && s.done()); + // not to be maximized: a window larger than its screen is fitted to it + let mut s = StartPlace::new(false); + let big = Seen { size: Some([3000.0, 2000.0]), screen: Some([1920.0, 1080.0]), ..Default::default() }; + assert_eq!(s.step(&big, 0.0), vec![C::InnerSize(egui::vec2(1728.0, 972.0))]); + assert!(s.done() && s.step(&big, 1.0).is_empty()); + let mut s = StartPlace::new(false); + assert!(s.step(&window([1300.0, 800.0]), 0.0).is_empty() && s.done()); + // full screen or minimized: left alone + let mut s = StartPlace::new(true); + assert!(s.step(&Seen { full_screen: true, ..window([2560.0, 1440.0]) }, 1.0).is_empty()); + } } diff --git a/docs/parity-checklist.md b/docs/parity-checklist.md index 080680b9ff..ca9253787d 100644 --- a/docs/parity-checklist.md +++ b/docs/parity-checklist.md @@ -1,6 +1,6 @@ # Lightroom parity checklist -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-24 · **Change:** minor (KEYC-METADATA, LRC-LIB-KEYWORDS: ⌥0 / ⌥⇧0 go to the next / previous keyword set; LRC-DEV-HISTOGRAM-DRAG: the histogram's five tonal zones — hover for the value, drag to adjust the Basic control the press locked, double-click to reset; LR-VIEW-HISTOGRAM note updated; MENU-BAR: on macOS a menu item that yields its key to a focused text field or to shortcut recording really lets it go; LR-MERGE-HDR / LR-MERGE-PANO: Lanczos-3 warps; LR-IMP-LOCAL: browsing from the sidebar records the folder; LR-VIEW-ZOOM: only a full-size drag within 20 ms clears a slow-drag verdict; LR-IMP-ADD-DIALOG: hierarchical import album destination reconciled with main, #2362; KEY-SLIDER-NUDGE: vertical wheel nudges need a click or drag in the row; leaving it disarms them; LR-EDIT-OPTICS-PROFILE: Fujifilm nine-knot lens tables read at the plain radius; LR-VIEW-ZOOM: only a full-size drag within 20 ms clears a slow-drag verdict; LRC-LIB-LIBFOLDERS, LR-BEHAV-BG-TASKS: Synchronize Folder's scan shows its folder listing and stops it on ✕; LRC-LIB-LIBFOLDERS: Synchronize Folder says a folder is up to date; LR-LIB-STACK: filmstrip stack badge click; LRC-LIB-REFVIEW / CATALOG-SWITCH: Escape preserves edits; catalog-local pins; deleted and malformed references refused; LRC-LIB-COMPARE: the Info panel labels the active photo while culling, #2398; KEYC-RATING: `\` shows / hides the Filter Bar in the grids; LR-VIEW-PHOTOGRID: the grid reads only the photos an import batch or an edit touched, not the whole list; earlier: LRC-PRINT-PAGE: Print Page Options; LR-META-XMP: fewer false unimported-XMP warnings; KEYC-METADATA: ⌘K / Ctrl+K Add Keywords; LRC-DEV-HISTOGRAM-DRAG: the histogram's five tonal zones — hover for the value, drag to adjust the Basic control the press locked, double-click to reset; LR-VIEW-HISTOGRAM note updated; MENU-BAR: on macOS a menu item that yields its key to a focused text field or to shortcut recording really lets it go; LR-MERGE-HDR / LR-MERGE-PANO: Lanczos-3 warps; LR-IMP-LOCAL: browsing from the sidebar records the folder; LR-VIEW-ZOOM: only a full-size drag within 20 ms clears a slow-drag verdict; LR-IMP-ADD-DIALOG: hierarchical import album destination reconciled with main, #2362; KEY-SLIDER-NUDGE: vertical wheel nudges need a click or drag in the row; leaving it disarms them; LR-EDIT-OPTICS-PROFILE: Fujifilm nine-knot lens tables read at the plain radius; LR-VIEW-ZOOM: only a full-size drag within 20 ms clears a slow-drag verdict; LRC-LIB-LIBFOLDERS, LR-BEHAV-BG-TASKS: Synchronize Folder's scan shows its folder listing and stops it on ✕; LRC-LIB-LIBFOLDERS: Synchronize Folder says a folder is up to date; LR-LIB-STACK: filmstrip stack badge click; LRC-LIB-REFVIEW / CATALOG-SWITCH: Escape preserves edits; catalog-local pins; deleted and malformed references refused; LRC-LIB-COMPARE: the Info panel labels the active photo while culling, #2398; KEYC-RATING: `\` shows / hides the Filter Bar in the grids; LR-VIEW-PHOTOGRID: the grid reads only the photos an import batch or an edit touched, not the whole list; earlier: LRC-PRINT-PAGE: Print Page Options; LR-META-XMP: fewer false unimported-XMP warnings) · **Target:** Adobe Lightroom Classic 15.5 / Lightroom 9.6 +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-25 · **Change:** minor (LR-BEHAV-WINDOW: on Windows a maximized window opens maximized, and a window remembered larger than its screen is fitted to it; KEYC-METADATA, LRC-LIB-KEYWORDS: ⌥0 / ⌥⇧0 go to the next / previous keyword set; LRC-DEV-HISTOGRAM-DRAG: the histogram's five tonal zones — hover for the value, drag to adjust the Basic control the press locked, double-click to reset; LR-VIEW-HISTOGRAM note updated; MENU-BAR: on macOS a menu item that yields its key to a focused text field or to shortcut recording really lets it go; LR-MERGE-HDR / LR-MERGE-PANO: Lanczos-3 warps; LR-IMP-LOCAL: browsing from the sidebar records the folder; LR-VIEW-ZOOM: only a full-size drag within 20 ms clears a slow-drag verdict; LR-IMP-ADD-DIALOG: hierarchical import album destination reconciled with main, #2362; KEY-SLIDER-NUDGE: vertical wheel nudges need a click or drag in the row; leaving it disarms them; LR-EDIT-OPTICS-PROFILE: Fujifilm nine-knot lens tables read at the plain radius; LR-VIEW-ZOOM: only a full-size drag within 20 ms clears a slow-drag verdict; LRC-LIB-LIBFOLDERS, LR-BEHAV-BG-TASKS: Synchronize Folder's scan shows its folder listing and stops it on ✕; LRC-LIB-LIBFOLDERS: Synchronize Folder says a folder is up to date; LR-LIB-STACK: filmstrip stack badge click; LRC-LIB-REFVIEW / CATALOG-SWITCH: Escape preserves edits; catalog-local pins; deleted and malformed references refused; LRC-LIB-COMPARE: the Info panel labels the active photo while culling, #2398; KEYC-RATING: `\` shows / hides the Filter Bar in the grids; LR-VIEW-PHOTOGRID: the grid reads only the photos an import batch or an edit touched, not the whole list; earlier: LRC-PRINT-PAGE: Print Page Options; LR-META-XMP: fewer false unimported-XMP warnings; KEYC-METADATA: ⌘K / Ctrl+K Add Keywords; LRC-DEV-HISTOGRAM-DRAG: the histogram's five tonal zones — hover for the value, drag to adjust the Basic control the press locked, double-click to reset; LR-VIEW-HISTOGRAM note updated; MENU-BAR: on macOS a menu item that yields its key to a focused text field or to shortcut recording really lets it go; LR-MERGE-HDR / LR-MERGE-PANO: Lanczos-3 warps; LR-IMP-LOCAL: browsing from the sidebar records the folder; LR-VIEW-ZOOM: only a full-size drag within 20 ms clears a slow-drag verdict; LR-IMP-ADD-DIALOG: hierarchical import album destination reconciled with main, #2362; KEY-SLIDER-NUDGE: vertical wheel nudges need a click or drag in the row; leaving it disarms them; LR-EDIT-OPTICS-PROFILE: Fujifilm nine-knot lens tables read at the plain radius; LR-VIEW-ZOOM: only a full-size drag within 20 ms clears a slow-drag verdict; LRC-LIB-LIBFOLDERS, LR-BEHAV-BG-TASKS: Synchronize Folder's scan shows its folder listing and stops it on ✕; LRC-LIB-LIBFOLDERS: Synchronize Folder says a folder is up to date; LR-LIB-STACK: filmstrip stack badge click; LRC-LIB-REFVIEW / CATALOG-SWITCH: Escape preserves edits; catalog-local pins; deleted and malformed references refused; LRC-LIB-COMPARE: the Info panel labels the active photo while culling, #2398; KEYC-RATING: `\` shows / hides the Filter Bar in the grids; LR-VIEW-PHOTOGRID: the grid reads only the photos an import batch or an edit touched, not the whole list; earlier: LRC-PRINT-PAGE: Print Page Options; LR-META-XMP: fewer false unimported-XMP warnings) · **Target:** Adobe Lightroom Classic 15.5 / Lightroom 9.6 The measured, row-by-row checklist: one row per Lightroom feature, menu item and shortcut, what we have and what is missing. It answers *does the feature exist?* (feature breadth). Whether it is good @@ -486,6 +486,7 @@ differences and missing bindings are in [ui-parity.md](ui-parity.md#shortcuts). | LR-BEHAV-WHATSNEW | What's new | P2 | ✅ | `cmd:app.whatsNew`, `docs/whats-new.md` | Help ▸ What's New: release highlights | | LR-BEHAV-AI-EA | Early-access badges | P2 | ⬜ | | | | LR-BEHAV-TITLEBAR | Title bar drag and double-click zoom (macOS) | P2 | 🟡 | `crates/ui-egui/src/titlebar.rs`, `crates/ui-egui/src/panels/topbar.rs`, `crates/ui-egui/src/tests_titlebar.rs` | the native title bar is hidden on macOS, so the top bar's empty space (including the traffic-light margin) moves the window and a double-click zooms or restores it; buttons and the search field keep their clicks; ignored in full screen, where the traffic lights are gone and the bar's left buttons move into their space (#1763). Zoom is winit's `Maximized`: it does not follow System Settings › “Double-click a window's title bar to” (Fill / Minimize). a press that starts on a button or the search field never moves the window. Known gap: egui-winit reads the zoomed state only at start-up and after our own `Maximized` command, so a window zoomed another way (green button, Window ▸ Zoom, snapping) makes the first double-click a no-op before the toggle catches up. Checked by hand on a real macOS window (drag, zoom, restore) | +| LR-BEHAV-WINDOW | Window size and maximized state remembered | P2 | 🟡 | `crates/ui-egui/src/window_place.rs`, `apps/lightcraft/src/main.rs` | the window opens at the size it was left at, zoomed / maximized if it was; full screen and the place on the desktop are not remembered; Windows: a maximized window is built at its size and maximized once it shows (built maximized it could cover half the screen while Windows took it for maximized), and restored and maximized again once if it only says so; a window remembered larger than its screen is fitted to it. Not verified on several monitors with different scales on hardware | ## Y. Menus @@ -799,6 +800,7 @@ Latin stays upright. Advanced Japanese composition remains open. Regression cove | Date | Change | Summary | |---|---|---| +| 2026-10-25 | minor | LR-BEHAV-WINDOW (new row, 🟡): on Windows a window remembered maximized is built at its size and maximized once it shows (built maximized it could cover half the screen while Windows took it for maximized), and restored and maximized again once if it only says so; a window remembered larger than the screen it opens on is fitted to it, on every platform | | 2026-10-24 | minor | KEYC-METADATA, LRC-LIB-KEYWORDS: ⌥0 / ⌥⇧0 (`keyword.nextSet`, `keyword.previousSet`) go to the next / previous keyword set; status counts unchanged (KEYC-METADATA stays 🟡) | | 2026-10-24 | minor | KEYC-METADATA: ⌘K / Ctrl+K (`panel.addKeywords`, Add Keywords) shows the Keywords panel, opens Keywording and puts the cursor in the Add keyword box; status counts unchanged (KEYC-METADATA stays 🟡) | | 2026-10-24 | patch | LR-LIB-RATING, LR-LIB-DELETE: a slider drag still open when a rating, flag or label takes the photo out of the view, or when the photo is deleted, ends as its own undo step before the selection moves on, as moving to the next photo does; LR-BEHAV-LOCALIZE lists all 18 languages; status unchanged | From babb257f840afb68673bac3b9d27da532f64012b Mon Sep 17 00:00:00 2001 From: OneSlips Date: Mon, 26 Oct 2026 04:59:49 +1000 Subject: [PATCH 2/8] WP5-WINDOW: review fixes (placing gives up after 5 s, fitted size in the interface's points, nothing remembered while placing) Co-Authored-By: Claude Opus 5.5 --- apps/lightcraft/src/main.rs | 8 ++- crates/ui-egui/src/window_place.rs | 82 +++++++++++++++++++----------- 2 files changed, 57 insertions(+), 33 deletions(-) diff --git a/apps/lightcraft/src/main.rs b/apps/lightcraft/src/main.rs index 8c76de2529..3f4355f47d 100644 --- a/apps/lightcraft/src/main.rs +++ b/apps/lightcraft/src/main.rs @@ -426,8 +426,10 @@ impl PrefsWriter { // the settings hold is checked first: a script may have set it (`ui.set`) let remembered = app.ui.window.and_then(lightcraft_ui_egui::window_place::WindowPlace::checked); let at = self.window_since.get_or_insert_with(std::time::Instant::now).elapsed().as_secs_f64(); + // (while the window is being placed it is not remembered: it may not be as it will be) + let placing = self.start.is_some(); if let Some(start) = &mut self.start { - for command in start.step(&seen, at) { + for command in start.step(&seen, at, zoom) { ctx.send_viewport_cmd(command); } match start.waits() { @@ -435,7 +437,9 @@ impl PrefsWriter { None => self.start = None, } } - app.ui.window = self.window.note(remembered, &seen, at); + if !placing { + app.ui.window = self.window.note(remembered, &seen, at); + } if let Some(wait) = self.window.waits(at) { // (a size is only remembered once the window has rested at it: look again then, though // nothing else asks for a frame) diff --git a/crates/ui-egui/src/window_place.rs b/crates/ui-egui/src/window_place.rs index 9968752471..2f29e81e3d 100644 --- a/crates/ui-egui/src/window_place.rs +++ b/crates/ui-egui/src/window_place.rs @@ -329,6 +329,9 @@ const MAXIMIZED_ACROSS: f32 = 0.9; const MAXIMIZED_DOWN: f32 = 0.75; /// A window opened larger than its screen is fitted to this much of it. const FIT_TO_SCREEN: f32 = 0.9; +/// How long after its first frame the window is placed at most: one that stays unseen, full +/// screen or minimized that long is left as it is. +const PLACE_WITHIN_SECONDS: f64 = 5.0; /// The window as it first shows. On Windows a window built maximized could open /// covering half the screen while the system took it for maximized: its maximize button then @@ -343,15 +346,16 @@ pub struct StartPlace { /// When it was asked to (seconds), and whether it has been asked again. asked: Option, retried: bool, - /// When the window first showed. + /// When the window first showed, and when it was first looked at. shown: Option, + first_step: Option, done: bool, } impl StartPlace { /// `maximize_after`: the window was built at its size and should be maximized once it shows. pub fn new(maximize_after: bool) -> StartPlace { - StartPlace { maximize: maximize_after, asked: None, retried: false, shown: None, done: false } + StartPlace { maximize: maximize_after, asked: None, retried: false, shown: None, first_step: None, done: false } } /// Whether there is nothing more to do. @@ -359,25 +363,31 @@ impl StartPlace { self.done } - /// The window is `seen` at time `now` (seconds): what to tell it. - pub fn step(&mut self, seen: &Seen, now: f64) -> Vec { - if self.done || seen.full_screen || seen.minimized { + /// The window is `seen` at time `now` (seconds), with the interface zoomed by `zoom`: what to + /// tell it. + pub fn step(&mut self, seen: &Seen, now: f64, zoom: f32) -> Vec { + if self.done { return Vec::new(); } - let (Some(size), Some(screen)) = (seen.size, seen.screen) else { - // (not shown yet, or its screen unknown: wait, but not for ever) - if self.shown.is_some_and(|t| now - t > 5.0) { - self.done = true; - } + // (not shown yet, its screen unknown, full screen or minimized: wait, but not for ever) + let first = *self.first_step.get_or_insert(now); + if now - first > PLACE_WITHIN_SECONDS { + self.done = true; return Vec::new(); - }; + } + if seen.full_screen || seen.minimized { + return Vec::new(); + } + let (Some(size), Some(screen)) = (seen.size, seen.screen) else { return Vec::new() }; let shown = *self.shown.get_or_insert(now); if !self.maximize { self.done = true; // remembered larger than this screen: fitted to it if !seen.zoomed && (size[0] > screen[0] + SAME_WITHIN || size[1] > screen[1] + SAME_WITHIN) { let fit = [(screen[0] * FIT_TO_SCREEN).max(MIN_SIZE[0]), (screen[1] * FIT_TO_SCREEN).max(MIN_SIZE[1])]; - return vec![egui::ViewportCommand::InnerSize(egui::vec2(fit[0], fit[1]))]; + // (`seen` is in the system's points, the command in the interface's) + let zoom = if zoom.is_finite() && zoom > 0.0 { zoom } else { 1.0 }; + return vec![egui::ViewportCommand::InnerSize(egui::vec2(fit[0] / zoom, fit[1] / zoom))]; } return Vec::new(); } @@ -1011,44 +1021,54 @@ mod tests { } } - /// Client note 17: on Windows the window opens at its size and is maximized once it shows; a + /// On Windows the window opens at its size and is maximized once it shows; a /// window that says it is maximized but covers half its screen is restored and maximized again, /// once; a window remembered larger than its screen is fitted to it. #[test] fn the_window_is_maximized_once_it_shows_and_again_if_it_only_says_so() { use egui::ViewportCommand as C; let mut s = StartPlace::new(true); - assert!(s.step(&Seen::default(), 0.0).is_empty(), "not shown yet"); - assert!(s.step(&window([1300.0, 800.0]), 0.0).is_empty(), "a frame first"); - assert_eq!(s.step(&window([1300.0, 800.0]), 0.2), vec![C::Maximized(true)]); - assert!(s.step(&window([1300.0, 800.0]), 0.3).is_empty(), "the system animates"); + assert!(s.step(&Seen::default(), 0.0, 1.0).is_empty(), "not shown yet"); + assert!(s.step(&window([1300.0, 800.0]), 0.0, 1.0).is_empty(), "a frame first"); + assert_eq!(s.step(&window([1300.0, 800.0]), 0.2, 1.0), vec![C::Maximized(true)]); + assert!(s.step(&window([1300.0, 800.0]), 0.3, 1.0).is_empty(), "the system animates"); // maximized in name, half the screen: once more let half = Seen { zoomed: true, ..window([1280.0, 1400.0]) }; - assert_eq!(s.step(&half, 1.0), vec![C::Maximized(false), C::Maximized(true)]); + assert_eq!(s.step(&half, 1.0, 1.0), vec![C::Maximized(false), C::Maximized(true)]); let full = Seen { zoomed: true, ..window([2560.0, 1392.0]) }; - assert!(s.step(&full, 1.2).is_empty()); - assert!(s.step(&full, 1.7).is_empty() && s.done()); + assert!(s.step(&full, 1.2, 1.0).is_empty()); + assert!(s.step(&full, 1.7, 1.0).is_empty() && s.done()); assert_eq!(s.waits(), None); // it filled its screen the first time: nothing more let mut s = StartPlace::new(true); - s.step(&window([1300.0, 800.0]), 0.0); - s.step(&window([1300.0, 800.0]), 0.2); - assert!(s.step(&full, 1.0).is_empty() && s.done()); + s.step(&window([1300.0, 800.0]), 0.0, 1.0); + s.step(&window([1300.0, 800.0]), 0.2, 1.0); + assert!(s.step(&full, 1.0, 1.0).is_empty() && s.done()); // never more than one retry let mut s = StartPlace::new(true); - s.step(&window([1300.0, 800.0]), 0.0); - s.step(&window([1300.0, 800.0]), 0.2); - assert_eq!(s.step(&half, 1.0).len(), 2); - assert!(s.step(&half, 2.0).is_empty() && s.done()); + s.step(&window([1300.0, 800.0]), 0.0, 1.0); + s.step(&window([1300.0, 800.0]), 0.2, 1.0); + assert_eq!(s.step(&half, 1.0, 1.0).len(), 2); + assert!(s.step(&half, 2.0, 1.0).is_empty() && s.done()); // not to be maximized: a window larger than its screen is fitted to it let mut s = StartPlace::new(false); let big = Seen { size: Some([3000.0, 2000.0]), screen: Some([1920.0, 1080.0]), ..Default::default() }; - assert_eq!(s.step(&big, 0.0), vec![C::InnerSize(egui::vec2(1728.0, 972.0))]); - assert!(s.done() && s.step(&big, 1.0).is_empty()); + assert_eq!(s.step(&big, 0.0, 1.0), vec![C::InnerSize(egui::vec2(1728.0, 972.0))]); + assert!(s.done() && s.step(&big, 1.0, 1.0).is_empty()); let mut s = StartPlace::new(false); - assert!(s.step(&window([1300.0, 800.0]), 0.0).is_empty() && s.done()); + assert!(s.step(&window([1300.0, 800.0]), 0.0, 1.0).is_empty() && s.done()); // full screen or minimized: left alone let mut s = StartPlace::new(true); - assert!(s.step(&Seen { full_screen: true, ..window([2560.0, 1440.0]) }, 1.0).is_empty()); + assert!(s.step(&Seen { full_screen: true, ..window([2560.0, 1440.0]) }, 1.0, 1.0).is_empty()); + // ... but not for ever: it stops asking for frames + assert!(s.step(&Seen { full_screen: true, ..window([2560.0, 1440.0]) }, 6.5, 1.0).is_empty()); + assert!(s.done() && s.waits().is_none()); + // a window that never says its size or screen is given up on too + let mut s = StartPlace::new(true); + assert!(s.step(&Seen::default(), 0.0, 1.0).is_empty()); + assert!(s.step(&Seen::default(), 5.5, 1.0).is_empty() && s.done()); + // the interface zoomed 2×: the fitted size is asked for in its points, half the system's + let mut s = StartPlace::new(false); + assert_eq!(s.step(&big, 0.0, 2.0), vec![C::InnerSize(egui::vec2(864.0, 486.0))]); } } From 32285ae6e8dee7ff4f55d7a41a027a386c0ffad2 Mon Sep 17 00:00:00 2001 From: OneSlips Date: Mon, 26 Oct 2026 15:53:28 +1000 Subject: [PATCH 3/8] LR-BEHAV-WINDOW: refresh the parity summary after the main merge Co-Authored-By: Claude Opus 5.5 --- docs/parity-checklist.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/parity-checklist.md b/docs/parity-checklist.md index e8be1e60e7..b00b16beed 100644 --- a/docs/parity-checklist.md +++ b/docs/parity-checklist.md @@ -49,13 +49,13 @@ cited here still exists. Formerly docs/parity.md. | U. Map & location (MAP) | 0 | 1 | 1 | 0 | — | 0/1 (0%) | | V. Preferences (PREF) | 6 | 2 | 2 | 2 | 1/1 (100%) | 4/5 (80%) | | W. Cloud & AI infrastructure (CLOUD / AI) | 1 | 0 | 1 | 2 | — | — | -| X. Cross-cutting behaviours (BEHAV) | 23 | 6 | 1 | 1 | 8/8 (100%) | 7/10 (70%) | +| X. Cross-cutting behaviours (BEHAV) | 23 | 7 | 1 | 1 | 8/8 (100%) | 7/10 (70%) | | Y. Menus | 85 | 0 | 4 | 8 | 47/47 (100%) | 23/23 (100%) | | Z. Keyboard shortcuts (desktop) | 78 | 4 | 2 | 1 | 49/52 (94%) | 24/26 (92%) | | Lightroom Classic extras | 41 | 25 | 21 | 8 | — | 24/26 (92%) | -| **Total** | 421 | 65 | 57 | 35 | 196/203 (97%) | 146/161 (91%) | +| **Total** | 421 | 66 | 57 | 35 | 196/203 (97%) | 146/161 (91%) | -Weighted completion (✅ = 1, 🟡 = ½, 🚫 left out): **83.5%** of 543 in-scope rows — P0 98.3% of 203 · P1 94.4% of 161 · P2 56.7% of 178. +Weighted completion (✅ = 1, 🟡 = ½, 🚫 left out): **83.5%** of 544 in-scope rows — P0 98.3% of 203 · P1 94.4% of 161 · P2 56.7% of 179. ## Top gaps and shortcut notes From fb4bd21598a1596b7e138f5906585e8215fe0455 Mon Sep 17 00:00:00 2001 From: OneSlips Date: Wed, 28 Oct 2026 07:04:12 +1000 Subject: [PATCH 4/8] LR-BEHAV-WINDOW: a window fitted to a screen smaller than its minimum stays within it Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/window_place.rs | 16 ++++++++++++---- crates/ui-egui/src/window_place/tests.rs | 14 ++++++++++++++ 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/crates/ui-egui/src/window_place.rs b/crates/ui-egui/src/window_place.rs index 7a44d76c08..0a496fdce5 100644 --- a/crates/ui-egui/src/window_place.rs +++ b/crates/ui-egui/src/window_place.rs @@ -382,12 +382,20 @@ impl StartPlace { let shown = *self.shown.get_or_insert(now); if !self.maximize { self.done = true; - // remembered larger than this screen: fitted to it + // remembered larger than this screen: fitted to it, and never larger than it (a screen smaller than + // the window's minimum lowers the minimum to the screen) if !seen.zoomed && (size[0] > screen[0] + SAME_WITHIN || size[1] > screen[1] + SAME_WITHIN) { - let fit = [(screen[0] * FIT_TO_SCREEN).max(MIN_SIZE[0]), (screen[1] * FIT_TO_SCREEN).max(MIN_SIZE[1])]; - // (`seen` is in the system's points, the command in the interface's) + let side = |i: usize| (screen[i] * FIT_TO_SCREEN).max(MIN_SIZE[i]).min(screen[i]); + let fit = [side(0), side(1)]; + // (`seen` is in the system's points, the commands in the interface's) let zoom = if zoom.is_finite() && zoom > 0.0 { zoom } else { 1.0 }; - return vec![egui::ViewportCommand::InnerSize(egui::vec2(fit[0] / zoom, fit[1] / zoom))]; + let mut told = Vec::new(); + if screen[0] < MIN_SIZE[0] || screen[1] < MIN_SIZE[1] { + let min = [MIN_SIZE[0].min(screen[0]), MIN_SIZE[1].min(screen[1])]; + told.push(egui::ViewportCommand::MinInnerSize(egui::vec2(min[0] / zoom, min[1] / zoom))); + } + told.push(egui::ViewportCommand::InnerSize(egui::vec2(fit[0] / zoom, fit[1] / zoom))); + return told; } return Vec::new(); } diff --git a/crates/ui-egui/src/window_place/tests.rs b/crates/ui-egui/src/window_place/tests.rs index 7ac25dbf14..98de3c284d 100644 --- a/crates/ui-egui/src/window_place/tests.rs +++ b/crates/ui-egui/src/window_place/tests.rs @@ -643,3 +643,17 @@ fn the_window_is_maximized_once_it_shows_and_again_if_it_only_says_so() { let mut s = StartPlace::new(false); assert_eq!(s.step(&big, 0.0, 2.0), vec![C::InnerSize(egui::vec2(864.0, 486.0))]); } + +/// A screen smaller than the window's minimum (800 × 600 beside a 900 pt minimum): the window is fitted within it +/// and the minimum is lowered to it, so it never asks for more than the screen (CodeRabbit on #2974). +#[test] +fn a_window_on_a_screen_smaller_than_its_minimum_fits_within_the_screen() { + use egui::ViewportCommand as C; + let mut s = StartPlace::new(false); + let small = Seen { size: Some([900.0, 560.0]), screen: Some([800.0, 600.0]), ..Default::default() }; + assert_eq!(s.step(&small, 0.0, 1.0), vec![C::MinInnerSize(egui::vec2(800.0, 560.0)), C::InnerSize(egui::vec2(800.0, 560.0))]); + // a screen the minimum fits on keeps the minimum + let mut s = StartPlace::new(false); + let big = Seen { size: Some([3000.0, 2000.0]), screen: Some([1920.0, 1080.0]), ..Default::default() }; + assert_eq!(s.step(&big, 0.0, 1.0), vec![C::InnerSize(egui::vec2(1728.0, 972.0))]); +} From 5242e7dba2700598c77d443566c41072d3a03e30 Mon Sep 17 00:00:00 2001 From: OneSlips Date: Thu, 29 Oct 2026 13:57:33 +1000 Subject: [PATCH 5/8] LR-BEHAV-WINDOW: a window remembered larger than its screen is fitted even after eframe clamped it eframe clamps a remembered 1600 x 1000 window to a 1280 x 720 screen before it is first seen, so the seen size alone skipped the 90 % fit and left the window covering the screen. `StartPlace` now keeps the remembered size (`remembered`) and fits the window when either is larger than the screen. Test: a clamped window with a larger remembered size is fitted; a smaller one is not. Co-Authored-By: Claude Opus 5.5 --- apps/lightcraft/src/main.rs | 5 ++++- crates/ui-egui/src/window_place.rs | 15 +++++++++++++-- crates/ui-egui/src/window_place/tests.rs | 16 ++++++++++++++++ 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/apps/lightcraft/src/main.rs b/apps/lightcraft/src/main.rs index 5cfbf26ab4..32836afa39 100644 --- a/apps/lightcraft/src/main.rs +++ b/apps/lightcraft/src/main.rs @@ -293,7 +293,10 @@ fn main() -> eframe::Result { written: serde_json::to_vec_pretty(&app.ui).unwrap_or_default(), library: app.ui.settings.library_path.clone(), keep_file: keep_prefs_file, - start: Some(lightcraft_ui_egui::window_place::StartPlace::new(MAXIMIZE_LATER && opens_as.is_some_and(|w| w.zoomed))), + start: Some( + lightcraft_ui_egui::window_place::StartPlace::new(MAXIMIZE_LATER && opens_as.is_some_and(|w| w.zoomed)) + .remembered(opens_as.map(|w| w.size)), + ), ..Default::default() }; // after the snapshot above, so the writer saves the switched-off preference diff --git a/crates/ui-egui/src/window_place.rs b/crates/ui-egui/src/window_place.rs index 0a496fdce5..6f2f611c83 100644 --- a/crates/ui-egui/src/window_place.rs +++ b/crates/ui-egui/src/window_place.rs @@ -350,12 +350,22 @@ pub struct StartPlace { shown: Option, first_step: Option, done: bool, + /// The size it was remembered at (system points), before the system or eframe fitted it to its screen. + remembered: Option<[f32; 2]>, } impl StartPlace { /// `maximize_after`: the window was built at its size and should be maximized once it shows. pub fn new(maximize_after: bool) -> StartPlace { - StartPlace { maximize: maximize_after, asked: None, retried: false, shown: None, first_step: None, done: false } + StartPlace { maximize: maximize_after, asked: None, retried: false, shown: None, first_step: None, done: false, remembered: None } + } + + /// The size the window was remembered at and built with (`size`, system points): a window remembered larger + /// than its screen is fitted to it even when it was clamped to the whole screen before it was first seen + /// (eframe clamps a remembered 1600 × 1000 to a 1280 × 720 screen). + pub fn remembered(mut self, size: Option<[f32; 2]>) -> StartPlace { + self.remembered = size.filter(|s| s.iter().all(|v| v.is_finite())); + self } /// Whether there is nothing more to do. @@ -384,7 +394,8 @@ impl StartPlace { self.done = true; // remembered larger than this screen: fitted to it, and never larger than it (a screen smaller than // the window's minimum lowers the minimum to the screen) - if !seen.zoomed && (size[0] > screen[0] + SAME_WITHIN || size[1] > screen[1] + SAME_WITHIN) { + let larger = |s: [f32; 2]| s[0] > screen[0] + SAME_WITHIN || s[1] > screen[1] + SAME_WITHIN; + if !seen.zoomed && (larger(size) || self.remembered.is_some_and(larger)) { let side = |i: usize| (screen[i] * FIT_TO_SCREEN).max(MIN_SIZE[i]).min(screen[i]); let fit = [side(0), side(1)]; // (`seen` is in the system's points, the commands in the interface's) diff --git a/crates/ui-egui/src/window_place/tests.rs b/crates/ui-egui/src/window_place/tests.rs index 98de3c284d..d487e7bb0d 100644 --- a/crates/ui-egui/src/window_place/tests.rs +++ b/crates/ui-egui/src/window_place/tests.rs @@ -657,3 +657,19 @@ fn a_window_on_a_screen_smaller_than_its_minimum_fits_within_the_screen() { let big = Seen { size: Some([3000.0, 2000.0]), screen: Some([1920.0, 1080.0]), ..Default::default() }; assert_eq!(s.step(&big, 0.0, 1.0), vec![C::InnerSize(egui::vec2(1728.0, 972.0))]); } + +/// eframe clamps a remembered 1600 × 1000 window to a 1280 × 720 screen before it is first seen: the remembered +/// size still has it fitted to 90 % of the screen, not left covering all of it (CodeRabbit on #2974). +#[test] +fn a_window_clamped_to_its_screen_before_it_shows_is_still_fitted() { + use egui::ViewportCommand as C; + let clamped = Seen { size: Some([1280.0, 720.0]), screen: Some([1280.0, 720.0]), ..Default::default() }; + let mut s = StartPlace::new(false).remembered(Some([1600.0, 1000.0])); + assert_eq!(s.step(&clamped, 0.0, 1.0), vec![C::InnerSize(egui::vec2(1152.0, 648.0))]); + // remembered within the screen: left as it is + let mut s = StartPlace::new(false).remembered(Some([1200.0, 700.0])); + assert!(s.step(&clamped, 0.0, 1.0).is_empty() && s.done()); + // nothing remembered: as before + let mut s = StartPlace::new(false); + assert!(s.step(&clamped, 0.0, 1.0).is_empty()); +} From d69d76d33194432569574673a4a21be23c7c46af Mon Sep 17 00:00:00 2001 From: OneSlips Date: Sun, 1 Nov 2026 05:36:15 +1000 Subject: [PATCH 6/8] LR-BEHAV-WINDOW: a window remembered maximized on a screen smaller than its minimum lowers the minimum before it is maximized (CodeRabbit, #2974) The fit branch already lowered MinInnerSize to a small screen; the deferred maximize did not, so the 900 x 560 minimum could leave the maximized window wider than the screen. Both now share min_within. Test: a_window_on_a_screen_smaller_than_its_minimum_fits_within_the_screen. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/window_place.rs | 28 ++++++++++++++++++------ crates/ui-egui/src/window_place/tests.rs | 7 ++++++ 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/crates/ui-egui/src/window_place.rs b/crates/ui-egui/src/window_place.rs index 6f2f611c83..3844e044bc 100644 --- a/crates/ui-egui/src/window_place.rs +++ b/crates/ui-egui/src/window_place.rs @@ -327,6 +327,21 @@ const MAXIMIZE_CHECK_SECONDS: f64 = 0.6; /// borders Windows keeps off screen, take the rest). const MAXIMIZED_ACROSS: f32 = 0.9; const MAXIMIZED_DOWN: f32 = 0.75; +/// `zoom` when it is a usable interface zoom, else 1. +fn interface_zoom(zoom: f32) -> f32 { + if zoom.is_finite() && zoom > 0.0 { zoom } else { 1.0 } +} + +/// On a `screen` (system points) smaller than [`MIN_SIZE`]: the command that lowers the window's minimum to the +/// screen, in the interface's points (`zoom`). Nothing on a screen the minimum fits on. +fn min_within(screen: [f32; 2], zoom: f32) -> Vec { + if screen[0] < MIN_SIZE[0] || screen[1] < MIN_SIZE[1] { + let min = [MIN_SIZE[0].min(screen[0]), MIN_SIZE[1].min(screen[1])]; + return vec![egui::ViewportCommand::MinInnerSize(egui::vec2(min[0] / zoom, min[1] / zoom))]; + } + Vec::new() +} + /// A window opened larger than its screen is fitted to this much of it. const FIT_TO_SCREEN: f32 = 0.9; /// How long after its first frame the window is placed at most: one that stays unseen, full @@ -399,12 +414,8 @@ impl StartPlace { let side = |i: usize| (screen[i] * FIT_TO_SCREEN).max(MIN_SIZE[i]).min(screen[i]); let fit = [side(0), side(1)]; // (`seen` is in the system's points, the commands in the interface's) - let zoom = if zoom.is_finite() && zoom > 0.0 { zoom } else { 1.0 }; - let mut told = Vec::new(); - if screen[0] < MIN_SIZE[0] || screen[1] < MIN_SIZE[1] { - let min = [MIN_SIZE[0].min(screen[0]), MIN_SIZE[1].min(screen[1])]; - told.push(egui::ViewportCommand::MinInnerSize(egui::vec2(min[0] / zoom, min[1] / zoom))); - } + let zoom = interface_zoom(zoom); + let mut told = min_within(screen, zoom); told.push(egui::ViewportCommand::InnerSize(egui::vec2(fit[0] / zoom, fit[1] / zoom))); return told; } @@ -414,7 +425,10 @@ impl StartPlace { match self.asked { None if now - shown >= MAXIMIZE_AFTER_SECONDS => { self.asked = Some(now); - vec![egui::ViewportCommand::Maximized(true)] + // a screen smaller than the window's minimum lowers it first, or the maximized window would stay wider + let mut told = min_within(screen, interface_zoom(zoom)); + told.push(egui::ViewportCommand::Maximized(true)); + told } None => Vec::new(), Some(at) if now - at < MAXIMIZE_CHECK_SECONDS => Vec::new(), diff --git a/crates/ui-egui/src/window_place/tests.rs b/crates/ui-egui/src/window_place/tests.rs index d487e7bb0d..6b8e0d9bff 100644 --- a/crates/ui-egui/src/window_place/tests.rs +++ b/crates/ui-egui/src/window_place/tests.rs @@ -652,7 +652,14 @@ fn a_window_on_a_screen_smaller_than_its_minimum_fits_within_the_screen() { let mut s = StartPlace::new(false); let small = Seen { size: Some([900.0, 560.0]), screen: Some([800.0, 600.0]), ..Default::default() }; assert_eq!(s.step(&small, 0.0, 1.0), vec![C::MinInnerSize(egui::vec2(800.0, 560.0)), C::InnerSize(egui::vec2(800.0, 560.0))]); + // remembered maximized on that screen: the minimum is lowered before it is maximized, or it would stay wider + let mut s = StartPlace::new(true); + s.step(&small, 0.0, 1.0); + assert_eq!(s.step(&small, 0.2, 2.0), vec![C::MinInnerSize(egui::vec2(400.0, 280.0)), C::Maximized(true)]); // a screen the minimum fits on keeps the minimum + let mut s = StartPlace::new(true); + s.step(&window([1300.0, 800.0]), 0.0, 1.0); + assert_eq!(s.step(&window([1300.0, 800.0]), 0.2, 1.0), vec![C::Maximized(true)]); let mut s = StartPlace::new(false); let big = Seen { size: Some([3000.0, 2000.0]), screen: Some([1920.0, 1080.0]), ..Default::default() }; assert_eq!(s.step(&big, 0.0, 1.0), vec![C::InnerSize(egui::vec2(1728.0, 972.0))]); From 36a1cf29649882c4eaf5774ab560cbee2fb67f81 Mon Sep 17 00:00:00 2001 From: OneSlips Date: Sun, 1 Nov 2026 07:22:40 +1000 Subject: [PATCH 7/8] LR-BEHAV-WINDOW: the window's minimum is weighed at the interface zoom when it is fitted or maximized (CodeRabbit, #2974) MIN_SIZE is in the interface's points, so at 2x zoom it holds the window to 1800 x 1120 system points: on a 1200 x 800 screen that minimum blocked the fit and the maximize though the screen is larger than 900 x 560. The minimum is now compared in the system's points and lowered to the fitted size (or the screen, before maximizing). Tests in a_window_on_a_screen_smaller_than_its_minimum_fits_within_the_screen and the zoomed case of the_window_is_maximized_once_it_shows_and_again_if_it_only_says_so. Co-Authored-By: Claude Opus 5.5 --- crates/ui-egui/src/window_place.rs | 27 ++++++++++++++++-------- crates/ui-egui/src/window_place/tests.rs | 13 ++++++++++-- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/crates/ui-egui/src/window_place.rs b/crates/ui-egui/src/window_place.rs index 3844e044bc..b8846d7a16 100644 --- a/crates/ui-egui/src/window_place.rs +++ b/crates/ui-egui/src/window_place.rs @@ -332,12 +332,19 @@ fn interface_zoom(zoom: f32) -> f32 { if zoom.is_finite() && zoom > 0.0 { zoom } else { 1.0 } } -/// On a `screen` (system points) smaller than [`MIN_SIZE`]: the command that lowers the window's minimum to the -/// screen, in the interface's points (`zoom`). Nothing on a screen the minimum fits on. -fn min_within(screen: [f32; 2], zoom: f32) -> Vec { - if screen[0] < MIN_SIZE[0] || screen[1] < MIN_SIZE[1] { - let min = [MIN_SIZE[0].min(screen[0]), MIN_SIZE[1].min(screen[1])]; - return vec![egui::ViewportCommand::MinInnerSize(egui::vec2(min[0] / zoom, min[1] / zoom))]; +/// The window's minimum in the system's points: [`MIN_SIZE`] is in the interface's, which `zoom` scales (at 2× a +/// 900 × 560 minimum holds the window to 1800 × 1120). +fn native_min(zoom: f32) -> [f32; 2] { + [MIN_SIZE[0] * zoom, MIN_SIZE[1] * zoom] +} + +/// When the window's minimum (at `zoom`) is larger than `room` (system points) on either side: the command that lowers +/// it to `room`, in the interface's points. Nothing when the minimum fits. +fn min_within(room: [f32; 2], zoom: f32) -> Vec { + let min = native_min(zoom); + if min[0] > room[0] || min[1] > room[1] { + let lowered = [min[0].min(room[0]), min[1].min(room[1])]; + return vec![egui::ViewportCommand::MinInnerSize(egui::vec2(lowered[0] / zoom, lowered[1] / zoom))]; } Vec::new() } @@ -411,11 +418,13 @@ impl StartPlace { // the window's minimum lowers the minimum to the screen) let larger = |s: [f32; 2]| s[0] > screen[0] + SAME_WITHIN || s[1] > screen[1] + SAME_WITHIN; if !seen.zoomed && (larger(size) || self.remembered.is_some_and(larger)) { - let side = |i: usize| (screen[i] * FIT_TO_SCREEN).max(MIN_SIZE[i]).min(screen[i]); - let fit = [side(0), side(1)]; // (`seen` is in the system's points, the commands in the interface's) let zoom = interface_zoom(zoom); - let mut told = min_within(screen, zoom); + let min = native_min(zoom); + let side = |i: usize| (screen[i] * FIT_TO_SCREEN).max(min[i]).min(screen[i]); + let fit = [side(0), side(1)]; + // a minimum larger than the fitted size (a small screen, a zoomed interface) is lowered to it first + let mut told = min_within(fit, zoom); told.push(egui::ViewportCommand::InnerSize(egui::vec2(fit[0] / zoom, fit[1] / zoom))); return told; } diff --git a/crates/ui-egui/src/window_place/tests.rs b/crates/ui-egui/src/window_place/tests.rs index 6b8e0d9bff..8012652684 100644 --- a/crates/ui-egui/src/window_place/tests.rs +++ b/crates/ui-egui/src/window_place/tests.rs @@ -641,7 +641,8 @@ fn the_window_is_maximized_once_it_shows_and_again_if_it_only_says_so() { assert!(s.step(&Seen::default(), 5.5, 1.0).is_empty() && s.done()); // the interface zoomed 2×: the fitted size is asked for in its points, half the system's let mut s = StartPlace::new(false); - assert_eq!(s.step(&big, 0.0, 2.0), vec![C::InnerSize(egui::vec2(864.0, 486.0))]); + // (its 900 × 560 minimum is 1800 × 1120 there, taller than the 1080 screen: lowered to the fitted size first) + assert_eq!(s.step(&big, 0.0, 2.0), vec![C::MinInnerSize(egui::vec2(900.0, 540.0)), C::InnerSize(egui::vec2(900.0, 540.0))]); } /// A screen smaller than the window's minimum (800 × 600 beside a 900 pt minimum): the window is fitted within it @@ -655,7 +656,15 @@ fn a_window_on_a_screen_smaller_than_its_minimum_fits_within_the_screen() { // remembered maximized on that screen: the minimum is lowered before it is maximized, or it would stay wider let mut s = StartPlace::new(true); s.step(&small, 0.0, 1.0); - assert_eq!(s.step(&small, 0.2, 2.0), vec![C::MinInnerSize(egui::vec2(400.0, 280.0)), C::Maximized(true)]); + assert_eq!(s.step(&small, 0.2, 2.0), vec![C::MinInnerSize(egui::vec2(400.0, 300.0)), C::Maximized(true)]); + // a screen larger than the minimum, but not than the minimum the zoomed interface makes of it (CodeRabbit on #2974) + let mut s = StartPlace::new(true); + let laptop = Seen { size: Some([1100.0, 700.0]), screen: Some([1200.0, 800.0]), ..Default::default() }; + s.step(&laptop, 0.0, 2.0); + assert_eq!(s.step(&laptop, 0.2, 2.0), vec![C::MinInnerSize(egui::vec2(600.0, 400.0)), C::Maximized(true)]); + let mut s = StartPlace::new(false); + let wide = Seen { size: Some([1600.0, 1000.0]), ..laptop }; + assert_eq!(s.step(&wide, 0.0, 2.0), vec![C::MinInnerSize(egui::vec2(600.0, 400.0)), C::InnerSize(egui::vec2(600.0, 400.0))]); // a screen the minimum fits on keeps the minimum let mut s = StartPlace::new(true); s.step(&window([1300.0, 800.0]), 0.0, 1.0); From e7d729535fcf8f20f1a1544e8adefbf53cdaefa6 Mon Sep 17 00:00:00 2001 From: FredApps <153173854+FredApps@users.noreply.github.com> Date: Thu, 26 Nov 2026 21:27:53 +0700 Subject: [PATCH 8/8] window placement: the time limit runs while the window is hidden, so a hidden start ends placement and its repaints (CodeRabbit on #2974) --- apps/lightcraft/src/prefs.rs | 3 +++ crates/ui-egui/src/window_place.rs | 21 ++++++++++++++++++--- crates/ui-egui/src/window_place/tests.rs | 13 +++++++++++++ 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/apps/lightcraft/src/prefs.rs b/apps/lightcraft/src/prefs.rs index 7187128133..8c3a1859b8 100644 --- a/apps/lightcraft/src/prefs.rs +++ b/apps/lightcraft/src/prefs.rs @@ -243,6 +243,9 @@ impl PrefsWriter { for command in start.step(&seen, at, zoom) { ctx.send_viewport_cmd(command); } + } else { + // (hidden: nothing to place by, but the time limit still runs) + start.idle(at); } match start.waits() { Some(wait) => ctx.request_repaint_after(wait), diff --git a/crates/ui-egui/src/window_place.rs b/crates/ui-egui/src/window_place.rs index b8846d7a16..20e6d1f80e 100644 --- a/crates/ui-egui/src/window_place.rs +++ b/crates/ui-egui/src/window_place.rs @@ -402,9 +402,7 @@ impl StartPlace { return Vec::new(); } // (not shown yet, its screen unknown, full screen or minimized: wait, but not for ever) - let first = *self.first_step.get_or_insert(now); - if now - first > PLACE_WITHIN_SECONDS { - self.done = true; + if self.out_of_time(now) { return Vec::new(); } if seen.full_screen || seen.minimized { @@ -458,6 +456,23 @@ impl StartPlace { } } + /// A pass with nothing to place by (the window is hidden: its size is stale) at time `now`: the time limit + /// still runs, so a window kept hidden ends the placement and stops asking to be looked at. + pub fn idle(&mut self, now: f64) { + if !self.done { + self.out_of_time(now); + } + } + + /// Whether placing has gone on for longer than it may (it is then done); its clock starts at the first pass. + fn out_of_time(&mut self, now: f64) -> bool { + let first = *self.first_step.get_or_insert(now); + if now - first > PLACE_WITHIN_SECONDS { + self.done = true; + } + self.done + } + /// When to look again while it waits (the app may have nothing else to draw). pub fn waits(&self) -> Option { (!self.done).then(|| std::time::Duration::from_millis(100)) diff --git a/crates/ui-egui/src/window_place/tests.rs b/crates/ui-egui/src/window_place/tests.rs index 8012652684..2ada192d28 100644 --- a/crates/ui-egui/src/window_place/tests.rs +++ b/crates/ui-egui/src/window_place/tests.rs @@ -689,3 +689,16 @@ fn a_window_clamped_to_its_screen_before_it_shows_is_still_fitted() { let mut s = StartPlace::new(false); assert!(s.step(&clamped, 0.0, 1.0).is_empty()); } + +/// A window kept hidden while it is being placed still ends the placement in time, and then stops asking to be +/// looked at (CodeRabbit on #2974). +#[test] +fn placement_ends_in_time_while_the_window_is_hidden() { + let mut s = StartPlace::new(true); + s.idle(0.0); + assert!(!s.done() && s.waits().is_some(), "still within its time"); + s.idle(PLACE_WITHIN_SECONDS + 0.1); + assert!(s.done()); + assert_eq!(s.waits(), None); + assert!(s.step(&window([1300.0, 800.0]), PLACE_WITHIN_SECONDS + 0.2, 1.0).is_empty()); +}