From acd6f12abaa2fe77211b72be92ba24f219cf2ac2 Mon Sep 17 00:00:00 2001 From: Psychotoxical <171614930+Psychotoxical@users.noreply.github.com> Date: Tue, 16 Jun 2026 21:00:18 +0200 Subject: [PATCH] fix(window): honour minimize-to-tray on the macOS close button MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The macOS red close button always emitted app:force-quit, which exits unconditionally and never checked the minimizeToTray setting — so on macOS the window closed the app even with "Minimize to Tray" enabled. Route the main-window close through window:close-requested on all platforms, so JS decides hide-vs-exit from the setting (default off = unchanged quit). The tray "Exit" item still force-quits. Fixes #1103 --- src-tauri/src/lib.rs | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 16e3a98e..94866281 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -608,24 +608,15 @@ pub fn run() { if let tauri::WindowEvent::CloseRequested { api, .. } = event { if window.label() == "main" { api.prevent_close(); - - #[cfg(target_os = "macos")] - { - // On macOS the red close button quits the app entirely. - // Route through JS so playback position + Orbit state get - // flushed; exit_app on the way back stops the audio engine. - let _ = window.emit("app:force-quit", ()); - } - - #[cfg(not(target_os = "macos"))] - { - // Pause rendering before JS decides whether to hide to tray or exit. - if let Some(w) = window.app_handle().get_webview_window("main") { - let _ = w.eval(PAUSE_RENDERING_JS); - } - // Let JS decide: minimize to tray or exit, based on user setting. - let _ = window.emit("window:close-requested", ()); + // All platforms: pause rendering, then let JS decide hide-to-tray + // vs exit based on the minimizeToTray setting. macOS previously + // always force-quit on the red close button, ignoring the setting + // (#1103). The tray "Exit" item still emits app:force-quit for an + // unconditional quit. + if let Some(w) = window.app_handle().get_webview_window("main") { + let _ = w.eval(PAUSE_RENDERING_JS); } + let _ = window.emit("window:close-requested", ()); } else if window.label() == "mini" { // Native close on the mini: hide instead of destroying so // state is preserved, and restore the main window.