fix uni link when mac service started, by use
applicationShouldOpenUntitledFile delegate
This commit is contained in:
parent
e86d4657da
commit
9ad240951e
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -6176,7 +6176,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "tao"
|
||||
version = "0.25.0"
|
||||
source = "git+https://github.com/rustdesk-org/tao?branch=dev#1a813dc8788735ff0ad427ffa71394aa02d16709"
|
||||
source = "git+https://github.com/rustdesk-org/tao?branch=dev#1cad16b200485bbccc67dcee2d339eac6e1c16ad"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"cc",
|
||||
@ -6216,7 +6216,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "tao-macros"
|
||||
version = "0.1.2"
|
||||
source = "git+https://github.com/rustdesk-org/tao?branch=dev#1a813dc8788735ff0ad427ffa71394aa02d16709"
|
||||
source = "git+https://github.com/rustdesk-org/tao?branch=dev#1cad16b200485bbccc67dcee2d339eac6e1c16ad"
|
||||
dependencies = [
|
||||
"proc-macro2 1.0.69",
|
||||
"quote 1.0.33",
|
||||
|
1
build.py
1
build.py
@ -426,6 +426,7 @@ def build_flutter_dmg(version, features):
|
||||
"create-dmg --volname \"RustDesk Installer\" --window-pos 200 120 --window-size 800 400 --icon-size 100 --app-drop-link 600 185 --icon RustDesk.app 200 190 --hide-extension RustDesk.app rustdesk.dmg ./build/macos/Build/Products/Release/RustDesk.app")
|
||||
os.rename("rustdesk.dmg", f"../rustdesk-{version}.dmg")
|
||||
'''
|
||||
#system2("g++ main.cc -O3 && mv a.out flutter/build/macos/Build/Products/Release/RustDesk.app/Contents/MacOS/serve")
|
||||
os.chdir("..")
|
||||
|
||||
|
||||
|
27
main.cc
Normal file
27
main.cc
Normal file
@ -0,0 +1,27 @@
|
||||
#include <dlfcn.h>
|
||||
#include <iostream>
|
||||
|
||||
int main()
|
||||
{
|
||||
void *handle = dlopen("../Frameworks/liblibrustdesk.dylib", RTLD_LAZY);
|
||||
if (!handle)
|
||||
{
|
||||
std::cerr << "Cannot open library: " << dlerror() << '\n';
|
||||
return 1;
|
||||
}
|
||||
|
||||
// use dlsym to get a symbol from the library
|
||||
typedef int (*some_func_t)();
|
||||
some_func_t some_func = (some_func_t)dlsym(handle, "rustdesk_core_main");
|
||||
const char *dlsym_error = dlerror();
|
||||
if (dlsym_error)
|
||||
{
|
||||
std::cerr << "Cannot load symbol 'some_func': " << dlsym_error << '\n';
|
||||
dlclose(handle);
|
||||
return 1;
|
||||
}
|
||||
|
||||
some_func();
|
||||
|
||||
dlclose(handle);
|
||||
}
|
@ -63,7 +63,7 @@ impl AppHandler for Rc<Host> {
|
||||
}
|
||||
|
||||
// https://github.com/xi-editor/druid/blob/master/druid-shell/src/platform/mac/application.rs
|
||||
pub unsafe fn set_delegate(handler: Option<Box<dyn AppHandler>>) {
|
||||
unsafe fn set_delegate(handler: Option<Box<dyn AppHandler>>) {
|
||||
let Some(mut decl) = ClassDecl::new("AppDelegate", class!(NSObject)) else {
|
||||
log::error!("Failed to new AppDelegate");
|
||||
return;
|
||||
@ -105,8 +105,8 @@ pub unsafe fn set_delegate(handler: Option<Box<dyn AppHandler>>) {
|
||||
handle_menu_item as extern "C" fn(&mut Object, Sel, id),
|
||||
);
|
||||
decl.add_method(
|
||||
sel!(handleEvent:withReplyEvent:),
|
||||
handle_apple_event as extern "C" fn(&Object, Sel, u64, u64) -> BOOL,
|
||||
sel!(application:openURLs:),
|
||||
handle_open_urls as extern "C" fn(&Object, Sel, id, id) -> (),
|
||||
);
|
||||
let decl = decl.register();
|
||||
let delegate: id = msg_send![decl, alloc];
|
||||
@ -186,12 +186,19 @@ extern "C" fn handle_menu_item(this: &mut Object, _: Sel, item: id) {
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
extern "C" fn handle_apple_event(_this: &Object, _cmd: Sel, event: u64, _reply: u64) -> BOOL {
|
||||
let event = event as *mut Object;
|
||||
let url = fruitbasket::parse_url_event(event);
|
||||
log::debug!("an event was received: {}", url);
|
||||
std::thread::spawn(move || crate::handle_url_scheme(url));
|
||||
YES
|
||||
extern "C" fn handle_open_urls(_self: &Object, _cmd: Sel, _: id, urls: id) -> () {
|
||||
use cocoa::foundation::NSArray;
|
||||
use cocoa::foundation::NSURL;
|
||||
use std::ffi::CStr;
|
||||
unsafe {
|
||||
for i in 0..urls.count() {
|
||||
let theurl = CStr::from_ptr(urls.objectAtIndex(i).absoluteString().UTF8String())
|
||||
.to_string_lossy()
|
||||
.into_owned();
|
||||
log::debug!("URL received: {}", theurl);
|
||||
std::thread::spawn(move || crate::handle_url_scheme(theurl));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Customize the service opening logic.
|
||||
|
Loading…
Reference in New Issue
Block a user