diff --git a/Cargo.toml b/Cargo.toml index 2713df11d..427fcd4e7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -155,7 +155,7 @@ identifier = "com.carriez.rustdesk" icon = ["res/32x32.png", "res/128x128.png", "res/128x128@2x.png"] deb_depends = ["libgtk-3-0", "libxcb-randr0", "libxdo3", "libxfixes3", "libxcb-shape0", "libxcb-xfixes0", "libasound2", "libsystemd0", "curl", "libvdpau1", "libva2"] osx_minimum_system_version = "10.14" -resources = ["res/mac-tray-light.png","res/mac-tray-dark.png"] +resources = ["res/mac-tray-light.png","res/mac-tray-dark.png", "res/mac-tray-light-x2.png","res/mac-tray-dark-x2.png"] #https://github.com/johnthagen/min-sized-rust [profile.release] diff --git a/flutter/macos/Runner.xcodeproj/project.pbxproj b/flutter/macos/Runner.xcodeproj/project.pbxproj index a8b5306be..8f11a09ed 100644 --- a/flutter/macos/Runner.xcodeproj/project.pbxproj +++ b/flutter/macos/Runner.xcodeproj/project.pbxproj @@ -28,6 +28,8 @@ 33CC11132044BFA00003C045 /* MainFlutterWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 33CC11122044BFA00003C045 /* MainFlutterWindow.swift */; }; 7E4BCD762966B0EC006D24E2 /* mac-tray-light.png in Resources */ = {isa = PBXBuildFile; fileRef = 7E4BCD742966B0EC006D24E2 /* mac-tray-light.png */; }; 7E4BCD772966B0EC006D24E2 /* mac-tray-dark.png in Resources */ = {isa = PBXBuildFile; fileRef = 7E4BCD752966B0EC006D24E2 /* mac-tray-dark.png */; }; + 7E881462296E98EE00A0C54F /* mac-tray-light-x2.png in Resources */ = {isa = PBXBuildFile; fileRef = 7E881461296E98ED00A0C54F /* mac-tray-light-x2.png */; }; + 7E881464296E991200A0C54F /* mac-tray-dark-x2.png in Resources */ = {isa = PBXBuildFile; fileRef = 7E881463296E991200A0C54F /* mac-tray-dark-x2.png */; }; 84010BA8292CF66600152837 /* liblibrustdesk.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 84010BA7292CF66600152837 /* liblibrustdesk.dylib */; settings = {ATTRIBUTES = (Weak, ); }; }; 84010BA9292CF68300152837 /* liblibrustdesk.dylib in Embed Libraries */ = {isa = PBXBuildFile; fileRef = 84010BA7292CF66600152837 /* liblibrustdesk.dylib */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; }; C5E54335B73C89F72DB1B606 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 26C84465887F29AE938039CB /* Pods_Runner.framework */; }; @@ -78,6 +80,8 @@ 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Release.xcconfig; sourceTree = ""; }; 7E4BCD742966B0EC006D24E2 /* mac-tray-light.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "mac-tray-light.png"; path = "../../res/mac-tray-light.png"; sourceTree = ""; }; 7E4BCD752966B0EC006D24E2 /* mac-tray-dark.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "mac-tray-dark.png"; path = "../../res/mac-tray-dark.png"; sourceTree = ""; }; + 7E881461296E98ED00A0C54F /* mac-tray-light-x2.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "mac-tray-light-x2.png"; path = "../../res/mac-tray-light-x2.png"; sourceTree = ""; }; + 7E881463296E991200A0C54F /* mac-tray-dark-x2.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "mac-tray-dark-x2.png"; path = "../../res/mac-tray-dark-x2.png"; sourceTree = ""; }; 84010BA7292CF66600152837 /* liblibrustdesk.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = liblibrustdesk.dylib; path = ../../target/release/liblibrustdesk.dylib; sourceTree = ""; }; 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; path = Debug.xcconfig; sourceTree = ""; }; C3BB669FF6190AE1B11BCAEA /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; }; @@ -131,6 +135,8 @@ 33CC11242044D66E0003C045 /* Resources */ = { isa = PBXGroup; children = ( + 7E881463296E991200A0C54F /* mac-tray-dark-x2.png */, + 7E881461296E98ED00A0C54F /* mac-tray-light-x2.png */, 7E4BCD752966B0EC006D24E2 /* mac-tray-dark.png */, 7E4BCD742966B0EC006D24E2 /* mac-tray-light.png */, 33CC10F22044A3C60003C045 /* Assets.xcassets */, @@ -259,10 +265,12 @@ isa = PBXResourcesBuildPhase; buildActionMask = 2147483647; files = ( + 7E881462296E98EE00A0C54F /* mac-tray-light-x2.png in Resources */, 7E4BCD762966B0EC006D24E2 /* mac-tray-light.png in Resources */, 7E4BCD772966B0EC006D24E2 /* mac-tray-dark.png in Resources */, 33CC10F32044A3C60003C045 /* Assets.xcassets in Resources */, 33CC10F62044A3C60003C045 /* MainMenu.xib in Resources */, + 7E881464296E991200A0C54F /* mac-tray-dark-x2.png in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/flutter/pubspec.lock b/flutter/pubspec.lock index 807f932bb..228817422 100644 --- a/flutter/pubspec.lock +++ b/flutter/pubspec.lock @@ -264,8 +264,8 @@ packages: dependency: "direct main" description: path: "." - ref: "82f9eab81cb2c7bfb938def7a1b399a6279bbc75" - resolved-ref: "82f9eab81cb2c7bfb938def7a1b399a6279bbc75" + ref: "057e6eb1bc7dcbcf9dafd1384274a611e4fe7124" + resolved-ref: "057e6eb1bc7dcbcf9dafd1384274a611e4fe7124" url: "https://github.com/Kingtous/rustdesk_desktop_multi_window" source: git version: "0.1.0" diff --git a/res/mac-tray-dark-x2.png b/res/mac-tray-dark-x2.png new file mode 100644 index 000000000..860f9fcf5 Binary files /dev/null and b/res/mac-tray-dark-x2.png differ diff --git a/res/mac-tray-dark.png b/res/mac-tray-dark.png index 860f9fcf5..ba8ed8c12 100644 Binary files a/res/mac-tray-dark.png and b/res/mac-tray-dark.png differ diff --git a/res/mac-tray-light-x2.png b/res/mac-tray-light-x2.png new file mode 100644 index 000000000..f723d980e Binary files /dev/null and b/res/mac-tray-light-x2.png differ diff --git a/res/mac-tray-light.png b/res/mac-tray-light.png index f723d980e..ad8bfa396 100644 Binary files a/res/mac-tray-light.png and b/res/mac-tray-light.png differ diff --git a/src/platform/macos.mm b/src/platform/macos.mm index c25a854cc..789404cb6 100644 --- a/src/platform/macos.mm +++ b/src/platform/macos.mm @@ -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; +} diff --git a/src/platform/macos.rs b/src/platform/macos.rs index 204993c13..165470cac 100644 --- a/src/platform/macos.rs +++ b/src/platform/macos.rs @@ -541,7 +541,6 @@ pub fn is_installed() -> bool { } pub fn quit_gui() { - use cocoa::appkit::NSApp; unsafe { let () = msg_send!(NSApp(), terminate: nil); }; diff --git a/src/tray.rs b/src/tray.rs index 98a4127a3..2ee423a9f 100644 --- a/src/tray.rs +++ b/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!( "{} {}",