From 3e4cf2ef24d5cb87b539c3910490f315ee660414 Mon Sep 17 00:00:00 2001 From: CJ Pais Date: Tue, 13 May 2025 12:59:27 -0700 Subject: [PATCH] Fix the window being hidden on macOS when clicking Settings. --- src-tauri/src/lib.rs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index afe2d4f..b8b961a 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -50,8 +50,27 @@ pub fn run() { .show_menu_on_left_click(true) .on_menu_event(|app, event| match event.id.as_ref() { "settings" => { - let settings_window = app.get_webview_window("main").unwrap(); - settings_window.show().unwrap(); + if let Some(settings_window) = app.get_webview_window("main") { + // First, ensure the window is visible + if let Err(e) = settings_window.show() { + eprintln!("Failed to show window: {}", e); + } + // Then, bring it to the front and give it focus + if let Err(e) = settings_window.set_focus() { + eprintln!("Failed to focus window: {}", e); + } + // Optional: On macOS, ensure the app becomes active if it was an accessory + #[cfg(target_os = "macos")] + { + if let Err(e) = + app.set_activation_policy(tauri::ActivationPolicy::Regular) + { + eprintln!("Failed to set activation policy to Regular: {}", e); + } + } + } else { + eprintln!("Main window not found"); + } } "quit" => { app.exit(0);