From d99da92b43f80ecc4ff61d9f9af94b9ac8424046 Mon Sep 17 00:00:00 2001 From: lucaronin Date: Thu, 14 May 2026 12:20:01 +0200 Subject: [PATCH] fix: preserve windows fullscreen navigation --- docs/ARCHITECTURE.md | 2 +- src-tauri/src/commands/system.rs | 59 ++++++++++++++++++++++++++++++-- 2 files changed, 57 insertions(+), 4 deletions(-) diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index 37a09a5b..b316010c 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -227,7 +227,7 @@ flowchart TD Panels are separated by `ResizeHandle` components that support drag-to-resize. `useLayoutPanels` clamps the sidebar, note-list, and inspector widths before applying them, keeps the side panes from flex-shrinking below their protected widths, and persists the last chosen widths in installation-local localStorage under `tolaria:layout-panels`. -The main Tauri window derives its minimum width from the visible panes instead of a single fixed floor. `useMainWindowSizeConstraints` treats the editor-only shell as the 480px baseline, adds the current sidebar / note-list / expanded-inspector widths on top with minimum floors, and calls the native `update_current_window_min_size` command whenever view mode, inspector visibility, or restored pane widths change. That same native command can grow the current window back out when a wider pane combination is restored, but Windows keeps grow-to-fit disabled so opening or closing the Properties panel does not unmaximize or reposition the main window. Note windows skip this path and keep their dedicated 800×700 initial sizing. +The main Tauri window derives its minimum width from the visible panes instead of a single fixed floor. `useMainWindowSizeConstraints` treats the editor-only shell as the 480px baseline, adds the current sidebar / note-list / expanded-inspector widths on top with minimum floors, and calls the native `update_current_window_min_size` command whenever view mode, inspector visibility, or restored pane widths change. That same native command can grow the current window back out when a wider pane combination is restored, but Windows keeps grow-to-fit disabled and skips min-size mutation while fullscreen or maximized so navigation/sidebar interactions do not unfullscreen or reposition the main window. Note windows skip this path and keep their dedicated 800×700 initial sizing. The main Tauri window also persists its last normal size and screen position in the app config directory as `window-state.json`. The state stores logical window points, while `window_state.rs` migrates older physical-pixel state on read so Retina and non-Retina launches restore the same user-facing bounds. On startup, the restored frame applies only to the main window and clamps to the currently available monitor work areas, so stale coordinates from a disconnected display fall back to a visible placement. Maximized, fullscreen, minimized, and detached note-window frames are not written as the restore baseline. diff --git a/src-tauri/src/commands/system.rs b/src-tauri/src/commands/system.rs index c1e01d19..1812e2ef 100644 --- a/src-tauri/src/commands/system.rs +++ b/src-tauri/src/commands/system.rs @@ -384,9 +384,33 @@ pub fn trigger_menu_command(_app_handle: tauri::AppHandle, _id: String) -> Resul } #[cfg(desktop)] -#[tauri::command] -pub fn update_current_window_min_size( - window: Window, +fn should_apply_window_min_size_constraints( + is_windows: bool, + is_fullscreen: bool, + is_maximized: bool, +) -> bool { + !(is_windows && (is_fullscreen || is_maximized)) +} + +#[cfg(desktop)] +fn should_skip_window_min_size_update(window: &Window) -> Result { + if !cfg!(target_os = "windows") { + return Ok(false); + } + + let is_fullscreen = window.is_fullscreen().map_err(|e| e.to_string())?; + let is_maximized = window.is_maximized().map_err(|e| e.to_string())?; + + Ok(!should_apply_window_min_size_constraints( + true, + is_fullscreen, + is_maximized, + )) +} + +#[cfg(desktop)] +fn apply_window_min_size_update( + window: &Window, min_width: f64, min_height: f64, grow_to_fit: bool, @@ -416,6 +440,21 @@ pub fn update_current_window_min_size( .map_err(|e| e.to_string()) } +#[cfg(desktop)] +#[tauri::command] +pub fn update_current_window_min_size( + window: Window, + min_width: f64, + min_height: f64, + grow_to_fit: bool, +) -> Result<(), String> { + if should_skip_window_min_size_update(&window)? { + return Ok(()); + } + + apply_window_min_size_update(&window, min_width, min_height, grow_to_fit) +} + #[cfg(desktop)] #[tauri::command] pub fn perform_current_window_titlebar_double_click(window: Window) -> Result<(), String> { @@ -623,6 +662,20 @@ mod tests { } } + #[test] + fn skips_min_size_updates_for_windows_fullscreen_or_maximized_windows() { + for (is_fullscreen, is_maximized) in [(true, false), (false, true), (true, true)] { + assert!(!should_apply_window_min_size_constraints( + true, + is_fullscreen, + is_maximized + )); + } + + assert!(should_apply_window_min_size_constraints(true, false, false)); + assert!(should_apply_window_min_size_constraints(false, true, true)); + } + #[test] fn propagates_title_bar_action_errors() { for (state, maximize, unmaximize, expected) in [