mac tray icon opt

This commit is contained in:
rustdesk
2023-01-11 15:35:35 +08:00
parent 8e3e8ab5bc
commit 3cbcd2e46a
10 changed files with 33 additions and 9 deletions

View File

@@ -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;
}

View File

@@ -541,7 +541,6 @@ pub fn is_installed() -> bool {
}
pub fn quit_gui() {
use cocoa::appkit::NSApp;
unsafe {
let () = msg_send!(NSApp(), terminate: nil);
};

View File

@@ -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!(
"{} {}",