From 4666c4b9a59d163a384ad5d8071be4f4f84f0d8e Mon Sep 17 00:00:00 2001 From: l0ng-ai <24760907+l0ng-ai@users.noreply.github.com> Date: Thu, 29 Oct 2026 18:05:06 +0800 Subject: [PATCH] fix(settings): keep macOS settings visible across displays (#254) --- src-tauri/src/windows.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src-tauri/src/windows.rs b/src-tauri/src/windows.rs index b66b72b8a..7fb0a1b48 100644 --- a/src-tauri/src/windows.rs +++ b/src-tauri/src/windows.rs @@ -6,7 +6,7 @@ //! (`window_take_launch`), and re-taken whenever [`LAUNCH_EVENT`] fires (a //! second app instance asking an already-loaded window to open a path). //! -//! Settings open in a native child window `settings-` (one per project +//! Settings open in a separate window `settings-` (one per project //! window) that shares its parent's project (see [`AppState::project`]); its //! [`Launch::settings_page`] tells it which page to show. @@ -666,7 +666,7 @@ pub fn cycle(app: &AppHandle, current: &str, forward: bool) { } /// Opens (or focuses) the settings window of `parent` showing `page`: a -/// native child window centred over its parent, sized like IDEA's Settings. +/// separate window centred over its parent, sized like IDEA's Settings. pub fn open_settings_window( app: &AppHandle, parent: &WebviewWindow, @@ -699,13 +699,17 @@ pub fn open_settings_window( config.maximized = false; config.fullscreen = false; config.drag_drop_enabled = false; - // macOS shows a child window as soon as it is attached, before the page loads: paint the theme's frame colour. + // Paint the theme's frame colour before the page loads. if let Some(color) = background.as_deref().and_then(hex_color) { config.background_color = Some(color); } windows.set_launch(&label, Launch { settings_page: page, new_projects, ..Default::default() }); - let window = WebviewWindowBuilder::from_config(app, &config) - .and_then(|b| b.parent(&parent)) + let builder = WebviewWindowBuilder::from_config(app, &config); + // AppKit child windows can disappear when dragged to another display's Space. + // The settings label already tracks ownership and parent-close cleanup. + #[cfg(not(target_os = "macos"))] + let builder = builder.and_then(|b| b.parent(&parent)); + let window = builder .and_then(|b| b.build()) .map_err(|e| IdeError::internal(format!("cannot create settings window: {e}")))?; apply_zoom(app, &window);