diff --git a/src-tauri/src/bin/donut_daemon.rs b/src-tauri/src/bin/donut_daemon.rs index ea30d4c..254b0dd 100644 --- a/src-tauri/src/bin/donut_daemon.rs +++ b/src-tauri/src/bin/donut_daemon.rs @@ -26,7 +26,6 @@ static SHOULD_QUIT: AtomicBool = AtomicBool::new(false); #[cfg(windows)] fn win_process_exists(pid: u32) -> bool { - use std::ptr; const PROCESS_QUERY_LIMITED_INFORMATION: u32 = 0x1000; extern "system" { @@ -35,7 +34,7 @@ fn win_process_exists(pid: u32) -> bool { } let handle = unsafe { OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, 0, pid) }; - if handle.is_null() || handle == ptr::null_mut() { + if handle.is_null() { false } else { unsafe { CloseHandle(handle) }; diff --git a/src-tauri/src/daemon/tray.rs b/src-tauri/src/daemon/tray.rs index d402c41..d584811 100644 --- a/src-tauri/src/daemon/tray.rs +++ b/src-tauri/src/daemon/tray.rs @@ -80,10 +80,14 @@ pub fn open_gui() { // Using `-n` would bypass the single-instance plugin entirely. #[cfg(target_os = "macos")] { + // Use `open -n` to force launching a new process. Without `-n`, macOS + // re-activates the daemon (the existing process from the bundle) instead + // of launching the GUI binary. The single-instance Tauri plugin in the + // GUI handles deduplication if a GUI instance is already running. if let Some(app_bundle) = get_app_bundle_path() { - let _ = Command::new("open").arg(&app_bundle).spawn(); + let _ = Command::new("open").args(["-n"]).arg(&app_bundle).spawn(); } else { - let _ = Command::new("open").arg("-a").arg("Donut").spawn(); + let _ = Command::new("open").args(["-n", "-a", "Donut"]).spawn(); } } diff --git a/src-tauri/src/daemon_spawn.rs b/src-tauri/src/daemon_spawn.rs index e55bc7e..1abfdcd 100644 --- a/src-tauri/src/daemon_spawn.rs +++ b/src-tauri/src/daemon_spawn.rs @@ -13,7 +13,6 @@ use crate::daemon::autostart; /// This avoids spawning tasklist.exe which causes a visible conhost window flash. #[cfg(windows)] fn win_process_exists(pid: u32) -> bool { - use std::ptr; const PROCESS_QUERY_LIMITED_INFORMATION: u32 = 0x1000; extern "system" { @@ -22,7 +21,7 @@ fn win_process_exists(pid: u32) -> bool { } let handle = unsafe { OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, 0, pid) }; - if handle.is_null() || handle == ptr::null_mut() { + if handle.is_null() { false } else { unsafe { CloseHandle(handle) };