Merge updated PR #1055

This commit is contained in:
Hakan Seven committed 2026-09-07 19:10:55 +03:00
commit 8922a5a25b
1 file changed
+20
+20
View File
@@ -63,6 +63,7 @@ fn deliver_or_launch(files: &[String]) {
let paths: Vec<PathBuf> = files.iter().map(PathBuf::from).collect(); let paths: Vec<PathBuf> = files.iter().map(PathBuf::from).collect();
if let Some(stream) = single_instance::try_connect_existing() { if let Some(stream) = single_instance::try_connect_existing() {
if single_instance::handoff(stream, &paths) { if single_instance::handoff(stream, &paths) {
reassert_accessory_policy();
return; return;
} }
} }
@@ -81,6 +82,16 @@ fn deliver_or_launch(files: &[String]) {
eprintln!("OpenCADStudio launcher: failed to launch the GUI: {err}"); eprintln!("OpenCADStudio launcher: failed to launch the GUI: {err}");
} }
} }
reassert_accessory_policy();
}
/// Keep the windowless relay out of the Dock after an open event activates it.
#[cfg(target_os = "macos")]
fn reassert_accessory_policy() {
if let Some(mtm) = MainThreadMarker::new() {
NSApplication::sharedApplication(mtm)
.setActivationPolicy(NSApplicationActivationPolicy::Accessory);
}
} }
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
@@ -118,6 +129,15 @@ declare_class!(
.collect(); .collect();
deliver_or_launch(&files); deliver_or_launch(&files);
} }
/// Start or activate the GUI when the bundle is reopened without files.
#[method(applicationShouldHandleReopen:hasVisibleWindows:)]
fn should_handle_reopen(&self, _sender: &NSApplication, has_visible_windows: bool) -> bool {
if !has_visible_windows {
deliver_or_launch(&[]);
}
true
}
} }
); );