forked from 1b-agent/opencadstudio-upstream
Merge updated PR #1055
This commit is contained in:
commit
8922a5a25b
1 file changed
+20
@@ -63,6 +63,7 @@ fn deliver_or_launch(files: &[String]) {
|
||||
let paths: Vec<PathBuf> = files.iter().map(PathBuf::from).collect();
|
||||
if let Some(stream) = single_instance::try_connect_existing() {
|
||||
if single_instance::handoff(stream, &paths) {
|
||||
reassert_accessory_policy();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -81,6 +82,16 @@ fn deliver_or_launch(files: &[String]) {
|
||||
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")]
|
||||
@@ -118,6 +129,15 @@ declare_class!(
|
||||
.collect();
|
||||
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
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
Reference in new issue
Block a user