mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
mac tray icon opt
This commit is contained in:
@@ -34,3 +34,9 @@ extern "C" bool InputMonitoringAuthStatus(bool prompt) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
extern "C" float BackingScaleFactor() {
|
||||
NSScreen* s = [NSScreen mainScreen];
|
||||
if (s) return [s backingScaleFactor];
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -541,7 +541,6 @@ pub fn is_installed() -> bool {
|
||||
}
|
||||
|
||||
pub fn quit_gui() {
|
||||
use cocoa::appkit::NSApp;
|
||||
unsafe {
|
||||
let () = msg_send!(NSApp(), terminate: nil);
|
||||
};
|
||||
|
||||
21
src/tray.rs
21
src/tray.rs
@@ -206,17 +206,28 @@ fn is_service_stopped() -> bool {
|
||||
|
||||
#[cfg(target_os = "macos")]
|
||||
pub fn make_tray() {
|
||||
extern "C" {
|
||||
fn BackingScaleFactor() -> f32;
|
||||
}
|
||||
let f = unsafe { BackingScaleFactor() };
|
||||
use tray_item::TrayItem;
|
||||
let mode = dark_light::detect();
|
||||
let icon_path;
|
||||
match mode {
|
||||
let icon_path = match mode {
|
||||
dark_light::Mode::Dark => {
|
||||
icon_path = "mac-tray-light.png";
|
||||
if f > 1. {
|
||||
"mac-tray-light_x2.png";
|
||||
} else {
|
||||
"mac-tray-light.png";
|
||||
}
|
||||
}
|
||||
dark_light::Mode::Light => {
|
||||
icon_path = "mac-tray-dark.png";
|
||||
if f > 1. {
|
||||
"mac-tray-dark_x2.png";
|
||||
} else {
|
||||
"mac-tray-dark.png";
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
if let Ok(mut tray) = TrayItem::new(&crate::get_app_name(), icon_path) {
|
||||
tray.add_label(&format!(
|
||||
"{} {}",
|
||||
|
||||
Reference in New Issue
Block a user