fix: #3369
This commit is contained in:
parent
c685a0b5fa
commit
c5d7e5dfda
@ -26,7 +26,7 @@ const SHOW_SETTINGS_TAG: u32 = 2;
|
||||
const RUN_ME_TAG: u32 = 3;
|
||||
const AWAKE: u32 = 4;
|
||||
|
||||
trait AppHandler {
|
||||
pub trait AppHandler {
|
||||
fn command(&mut self, cmd: u32);
|
||||
}
|
||||
|
||||
@ -63,9 +63,12 @@ impl AppHandler for Rc<Host> {
|
||||
}
|
||||
|
||||
// https://github.com/xi-editor/druid/blob/master/druid-shell/src/platform/mac/application.rs
|
||||
unsafe fn set_delegate(handler: Option<Box<dyn AppHandler>>) {
|
||||
let mut decl =
|
||||
ClassDecl::new("AppDelegate", class!(NSObject)).expect("App Delegate definition failed");
|
||||
pub unsafe fn set_delegate(handler: Option<Box<dyn AppHandler>>) {
|
||||
let decl = ClassDecl::new("AppDelegate", class!(NSObject));
|
||||
if decl.is_none() {
|
||||
return;
|
||||
}
|
||||
let mut decl = decl.unwrap();
|
||||
decl.add_ivar::<*mut c_void>(APP_HANDLER_IVAR);
|
||||
|
||||
decl.add_method(
|
@ -11,6 +11,9 @@ pub mod windows;
|
||||
#[cfg(target_os = "macos")]
|
||||
pub mod macos;
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
pub mod delegate;
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
pub mod linux;
|
||||
|
||||
|
@ -131,6 +131,10 @@ pub fn make_tray() -> hbb_common::ResultType<()> {
|
||||
|
||||
let event_loop = EventLoopBuilder::new().build();
|
||||
|
||||
unsafe {
|
||||
crate::platform::delegate::set_delegate(None);
|
||||
}
|
||||
|
||||
let tray_menu = Menu::new();
|
||||
let quit_i = MenuItem::new(crate::client::translate("Exit".to_owned()), true, None);
|
||||
tray_menu.append_items(&[&quit_i]);
|
||||
|
@ -20,8 +20,6 @@ use crate::{common::get_app_name, ipc, ui_interface::*};
|
||||
mod cm;
|
||||
#[cfg(feature = "inline")]
|
||||
pub mod inline;
|
||||
#[cfg(target_os = "macos")]
|
||||
pub mod macos;
|
||||
pub mod remote;
|
||||
|
||||
pub type Children = Arc<Mutex<(bool, HashMap<(String, String), Child>)>>;
|
||||
@ -43,7 +41,7 @@ struct UIHostHandler;
|
||||
|
||||
pub fn start(args: &mut [String]) {
|
||||
#[cfg(target_os = "macos")]
|
||||
macos::show_dock();
|
||||
crate::platform::delegate::show_dock();
|
||||
#[cfg(all(target_os = "linux", feature = "inline"))]
|
||||
{
|
||||
#[cfg(feature = "appimage")]
|
||||
@ -75,7 +73,7 @@ pub fn start(args: &mut [String]) {
|
||||
allow_err!(sciter::set_options(sciter::RuntimeOptions::UxTheming(true)));
|
||||
frame.set_title(&crate::get_app_name());
|
||||
#[cfg(target_os = "macos")]
|
||||
macos::make_menubar(frame.get_host(), args.is_empty());
|
||||
crate::platform::delegate::make_menubar(frame.get_host(), args.is_empty());
|
||||
let page;
|
||||
if args.len() > 1 && args[0] == "--play" {
|
||||
args[0] = "--connect".to_owned();
|
||||
|
Loading…
x
Reference in New Issue
Block a user