diff --git a/src/platform/macos.mm b/src/platform/macos.mm index 27caf32a8..92ee5170b 100644 --- a/src/platform/macos.mm +++ b/src/platform/macos.mm @@ -240,6 +240,13 @@ static bool setDisplayToMode(CGDirectDisplayID display, CGDisplayModeRef mode) { return true; } +// Set the display to a specific mode based on width and height. +// Returns true if the display mode was successfully changed, false otherwise. +// If no such mode is available, it will not change the display mode. +// +// If `tryHiDPI` is true, it will try to set the display to a HiDPI mode if available. +// If no HiDPI mode is available, it will fall back to a non-HiDPI mode with the same resolution. +// If `tryHiDPI` is false, it sets the display to the first mode with the same resolution, no matter if it's HiDPI or not. extern "C" bool MacSetMode(CGDirectDisplayID display, uint32_t width, uint32_t height, bool tryHiDPI) { bool ret = false; diff --git a/src/platform/macos.rs b/src/platform/macos.rs index 4e6b35dac..ac5e47f67 100644 --- a/src/platform/macos.rs +++ b/src/platform/macos.rs @@ -890,6 +890,17 @@ pub fn handle_application_should_open_untitled_file() { } } +/// Get all resolutions of the display. The resolutions are: +/// 1. Sorted by width and height in descending order, with duplicates removed. +/// 2. Filtered out if the width is less than 800 (800x600) if there are too many (e.g., >15). +/// 3. Contain HiDPI resolutions and the real resolutions. +/// +/// We don't need to distinguish between HiDPI and real resolutions. +/// When the controlling side changes the resolution, it will call `change_resolution_directly()`. +/// `change_resolution_directly()` will try to use the HiDPI resolution first. +/// This is how teamviewer does it for now. +/// +/// If we need to distinguish HiDPI and real resolutions, we can add a flag to the `Resolution` struct. pub fn resolutions(name: &str) -> Vec { let mut v = vec![]; if let Ok(display) = name.parse::() {