From cfb3ec0e21cab8010fbc1d7ef82aa65d86c3cfa9 Mon Sep 17 00:00:00 2001 From: Fabian-Lars Date: Tue, 5 Nov 2024 17:01:35 +0100 Subject: [PATCH] fix(window-state): Ignore is_maximized state in resize events on macos (#2007) --- .../window-state-disable-maximize-check.md | 5 +++++ plugins/window-state/src/lib.rs | 22 ++++++++++++++----- 2 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 .changes/window-state-disable-maximize-check.md diff --git a/.changes/window-state-disable-maximize-check.md b/.changes/window-state-disable-maximize-check.md new file mode 100644 index 00000000..d5e57a3d --- /dev/null +++ b/.changes/window-state-disable-maximize-check.md @@ -0,0 +1,5 @@ +--- +window-state: patch +--- + +On macOS the plugin now (temporarily) ignores the maximized state for undecorated windows on resize events to fix app freezes. diff --git a/plugins/window-state/src/lib.rs b/plugins/window-state/src/lib.rs index 15599da8..82beb9f4 100644 --- a/plugins/window-state/src/lib.rs +++ b/plugins/window-state/src/lib.rs @@ -471,13 +471,23 @@ impl Builder { .0 .try_lock() .is_ok() - && !window_clone.is_minimized().unwrap_or_default() - && !window_clone.is_maximized().unwrap_or_default() { - let mut c = cache.lock().unwrap(); - if let Some(state) = c.get_mut(&label) { - state.width = size.width; - state.height = size.height; + // TODO: Remove once https://github.com/tauri-apps/tauri/issues/5812 is resolved. + let is_maximized = if cfg!(target_os = "macos") + && (!window_clone.is_decorated().unwrap_or_default() + || !window_clone.is_resizable().unwrap_or_default()) + { + false + } else { + window_clone.is_maximized().unwrap_or_default() + }; + + if !window_clone.is_minimized().unwrap_or_default() && !is_maximized { + let mut c = cache.lock().unwrap(); + if let Some(state) = c.get_mut(&label) { + state.width = size.width; + state.height = size.height; + } } } }