diff --git a/src/core_main.rs b/src/core_main.rs index bf6866df5..720c01da8 100644 --- a/src/core_main.rs +++ b/src/core_main.rs @@ -193,6 +193,7 @@ pub fn core_main() -> Option> { #[cfg(target_os = "macos")] { std::thread::spawn(move || crate::start_server(true)); + crate::platform::macos::hide_dock(); crate::tray::make_tray(); return None; } @@ -242,6 +243,8 @@ pub fn core_main() -> Option> { #[cfg(feature = "flutter")] crate::flutter::connection_manager::start_listen_ipc_thread(); crate::ui_interface::start_option_status_sync(); + #[cfg(target_os = "macos")] + crate::platform::macos::hide_dock(); } } //_async_logger_holder.map(|x| x.flush()); diff --git a/src/platform/macos.rs b/src/platform/macos.rs index 62fa1ee25..70e38eb57 100644 --- a/src/platform/macos.rs +++ b/src/platform/macos.rs @@ -4,6 +4,7 @@ use super::{CursorData, ResultType}; use cocoa::{ + appkit::{NSApp, NSApplication, NSApplicationActivationPolicy::*}, base::{id, nil, BOOL, NO, YES}, foundation::{NSDictionary, NSPoint, NSSize, NSString}, }; @@ -550,3 +551,9 @@ pub fn get_double_click_time() -> u32 { // to-do: https://github.com/servo/core-foundation-rs/blob/786895643140fa0ee4f913d7b4aeb0c4626b2085/cocoa/src/appkit.rs#L2823 500 as _ } + +pub fn hide_dock() { + unsafe { + NSApp().setActivationPolicy_(NSApplicationActivationPolicyAccessory); + } +}