applicationShouldOpenUntitledFile
This commit is contained in:
parent
3e63df1d59
commit
aac12c2b21
@ -15,7 +15,7 @@
|
|||||||
<BuildableReference
|
<BuildableReference
|
||||||
BuildableIdentifier = "primary"
|
BuildableIdentifier = "primary"
|
||||||
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
|
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
|
||||||
BuildableName = "rustdesk.app"
|
BuildableName = "RustDesk.app"
|
||||||
BlueprintName = "Runner"
|
BlueprintName = "Runner"
|
||||||
ReferencedContainer = "container:Runner.xcodeproj">
|
ReferencedContainer = "container:Runner.xcodeproj">
|
||||||
</BuildableReference>
|
</BuildableReference>
|
||||||
@ -31,7 +31,7 @@
|
|||||||
<BuildableReference
|
<BuildableReference
|
||||||
BuildableIdentifier = "primary"
|
BuildableIdentifier = "primary"
|
||||||
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
|
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
|
||||||
BuildableName = "rustdesk.app"
|
BuildableName = "RustDesk.app"
|
||||||
BlueprintName = "Runner"
|
BlueprintName = "Runner"
|
||||||
ReferencedContainer = "container:Runner.xcodeproj">
|
ReferencedContainer = "container:Runner.xcodeproj">
|
||||||
</BuildableReference>
|
</BuildableReference>
|
||||||
@ -54,7 +54,7 @@
|
|||||||
<BuildableReference
|
<BuildableReference
|
||||||
BuildableIdentifier = "primary"
|
BuildableIdentifier = "primary"
|
||||||
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
|
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
|
||||||
BuildableName = "rustdesk.app"
|
BuildableName = "RustDesk.app"
|
||||||
BlueprintName = "Runner"
|
BlueprintName = "Runner"
|
||||||
ReferencedContainer = "container:Runner.xcodeproj">
|
ReferencedContainer = "container:Runner.xcodeproj">
|
||||||
</BuildableReference>
|
</BuildableReference>
|
||||||
@ -71,7 +71,7 @@
|
|||||||
<BuildableReference
|
<BuildableReference
|
||||||
BuildableIdentifier = "primary"
|
BuildableIdentifier = "primary"
|
||||||
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
|
BlueprintIdentifier = "33CC10EC2044A3C60003C045"
|
||||||
BuildableName = "rustdesk.app"
|
BuildableName = "RustDesk.app"
|
||||||
BlueprintName = "Runner"
|
BlueprintName = "Runner"
|
||||||
ReferencedContainer = "container:Runner.xcodeproj">
|
ReferencedContainer = "container:Runner.xcodeproj">
|
||||||
</BuildableReference>
|
</BuildableReference>
|
||||||
|
@ -7,4 +7,9 @@ class AppDelegate: FlutterAppDelegate {
|
|||||||
dummy_method_to_enforce_bundling()
|
dummy_method_to_enforce_bundling()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override func applicationShouldOpenUntitledFile(_ sender: NSApplication) -> Bool {
|
||||||
|
handle_applicationShouldOpenUntitledFile();
|
||||||
|
return true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -699,6 +699,13 @@ packages:
|
|||||||
url: "https://pub.dartlang.org"
|
url: "https://pub.dartlang.org"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.0"
|
version: "2.1.0"
|
||||||
|
password_strength:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: password_strength
|
||||||
|
url: "https://pub.dartlang.org"
|
||||||
|
source: hosted
|
||||||
|
version: "0.2.0"
|
||||||
path:
|
path:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
|
@ -39,6 +39,15 @@ pub extern "C" fn rustdesk_core_main() -> bool {
|
|||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn handle_applicationShouldOpenUntitledFile() {
|
||||||
|
hbb_common::log::debug!("icon clicked on finder");
|
||||||
|
if std::env::args().nth(1) == Some("--server".to_owned()) {
|
||||||
|
crate::platform::macos::check_main_window();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn rustdesk_core_main_args(args_len: *mut c_int) -> *mut *mut c_char {
|
pub extern "C" fn rustdesk_core_main_args(args_len: *mut c_int) -> *mut *mut c_char {
|
||||||
|
@ -556,3 +556,23 @@ pub fn hide_dock() {
|
|||||||
NSApp().setActivationPolicy_(NSApplicationActivationPolicyAccessory);
|
NSApp().setActivationPolicy_(NSApplicationActivationPolicyAccessory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn check_main_window() {
|
||||||
|
use sysinfo::{ProcessExt, System, SystemExt};
|
||||||
|
let mut sys = System::new();
|
||||||
|
sys.refresh_processes();
|
||||||
|
let app = format!("/Applications/{}.app", crate::get_app_name());
|
||||||
|
let my_uid = sys
|
||||||
|
.process((std::process::id() as i32).into())
|
||||||
|
.map(|x| x.user_id())
|
||||||
|
.unwrap_or_default();
|
||||||
|
for (_, p) in sys.processes().iter() {
|
||||||
|
if p.cmd().len() == 1 && p.user_id() == my_uid && p.cmd()[0].contains(&app) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
std::process::Command::new("open")
|
||||||
|
.args(["-n", &app])
|
||||||
|
.status()
|
||||||
|
.ok();
|
||||||
|
}
|
||||||
|
@ -127,7 +127,7 @@ extern "C" fn application_should_handle_open_untitled_file(
|
|||||||
}
|
}
|
||||||
hbb_common::log::debug!("icon clicked on finder");
|
hbb_common::log::debug!("icon clicked on finder");
|
||||||
if std::env::args().nth(1) == Some("--server".to_owned()) {
|
if std::env::args().nth(1) == Some("--server".to_owned()) {
|
||||||
check_main_window();
|
crate::platform::macos::check_main_window();
|
||||||
}
|
}
|
||||||
let inner: *mut c_void = *this.get_ivar(APP_HANDLER_IVAR);
|
let inner: *mut c_void = *this.get_ivar(APP_HANDLER_IVAR);
|
||||||
let inner = &mut *(inner as *mut DelegateState);
|
let inner = &mut *(inner as *mut DelegateState);
|
||||||
@ -233,24 +233,4 @@ pub fn make_tray() {
|
|||||||
set_delegate(None);
|
set_delegate(None);
|
||||||
}
|
}
|
||||||
crate::tray::make_tray();
|
crate::tray::make_tray();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn check_main_window() {
|
|
||||||
use sysinfo::{ProcessExt, System, SystemExt};
|
|
||||||
let mut sys = System::new();
|
|
||||||
sys.refresh_processes();
|
|
||||||
let app = format!("/Applications/{}.app", crate::get_app_name());
|
|
||||||
let my_uid = sys
|
|
||||||
.process((std::process::id() as i32).into())
|
|
||||||
.map(|x| x.user_id())
|
|
||||||
.unwrap_or_default();
|
|
||||||
for (_, p) in sys.processes().iter() {
|
|
||||||
if p.cmd().len() == 1 && p.user_id() == my_uid && p.cmd()[0].contains(&app) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
std::process::Command::new("open")
|
|
||||||
.args(["-n", &app])
|
|
||||||
.status()
|
|
||||||
.ok();
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user