mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
macos support uni command "rustdesk rustdesk://xxxx" without mainwindow (#7534)
Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
@@ -19,7 +19,7 @@ use core_graphics::{
|
||||
};
|
||||
use hbb_common::{anyhow::anyhow, bail, log, message_proto::Resolution};
|
||||
use include_dir::{include_dir, Dir};
|
||||
use objc::{class, msg_send, sel, sel_impl};
|
||||
use objc::{class, msg_send, runtime::Object, sel, sel_impl};
|
||||
use scrap::{libc::c_void, quartz::ffi::*};
|
||||
use std::path::PathBuf;
|
||||
|
||||
@@ -762,3 +762,21 @@ impl WakeLock {
|
||||
.ok_or(anyhow!("no AwakeHandle"))?
|
||||
}
|
||||
}
|
||||
|
||||
pub fn send_url_to_system(uni_links: &str) -> Result<(), &'static str> {
|
||||
unsafe {
|
||||
let ns_string = NSString::alloc(nil);
|
||||
let url_str = ns_string.init_str(uni_links);
|
||||
let url: *mut Object = msg_send![class!(NSURL), URLWithString: url_str];
|
||||
if url.is_null() {
|
||||
return Err("Failed to create NSURL");
|
||||
}
|
||||
let workspace: *mut Object = msg_send![class!(NSWorkspace), sharedWorkspace];
|
||||
let success: bool = msg_send![workspace, openURL: url];
|
||||
if success {
|
||||
Ok(())
|
||||
} else {
|
||||
Err("Failed to open URL")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user