mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-21 14:55:43 +00:00
fix(window): honour minimize-to-tray on the macOS close button
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
This commit is contained in:
+8
-17
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user