Skip to content

Commit 511a0b3

Browse files
authored
refact: macos, comments, resolution list (rustdesk#11830)
Signed-off-by: fufesou <linlong1266@gmail.com>
1 parent 06ab987 commit 511a0b3

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

src/platform/macos.mm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,13 @@ static bool setDisplayToMode(CGDirectDisplayID display, CGDisplayModeRef mode) {
240240
return true;
241241
}
242242

243+
// Set the display to a specific mode based on width and height.
244+
// Returns true if the display mode was successfully changed, false otherwise.
245+
// If no such mode is available, it will not change the display mode.
246+
//
247+
// If `tryHiDPI` is true, it will try to set the display to a HiDPI mode if available.
248+
// If no HiDPI mode is available, it will fall back to a non-HiDPI mode with the same resolution.
249+
// If `tryHiDPI` is false, it sets the display to the first mode with the same resolution, no matter if it's HiDPI or not.
243250
extern "C" bool MacSetMode(CGDirectDisplayID display, uint32_t width, uint32_t height, bool tryHiDPI)
244251
{
245252
bool ret = false;

src/platform/macos.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -890,6 +890,17 @@ pub fn handle_application_should_open_untitled_file() {
890890
}
891891
}
892892

893+
/// Get all resolutions of the display. The resolutions are:
894+
/// 1. Sorted by width and height in descending order, with duplicates removed.
895+
/// 2. Filtered out if the width is less than 800 (800x600) if there are too many (e.g., >15).
896+
/// 3. Contain HiDPI resolutions and the real resolutions.
897+
///
898+
/// We don't need to distinguish between HiDPI and real resolutions.
899+
/// When the controlling side changes the resolution, it will call `change_resolution_directly()`.
900+
/// `change_resolution_directly()` will try to use the HiDPI resolution first.
901+
/// This is how teamviewer does it for now.
902+
///
903+
/// If we need to distinguish HiDPI and real resolutions, we can add a flag to the `Resolution` struct.
893904
pub fn resolutions(name: &str) -> Vec<Resolution> {
894905
let mut v = vec![];
895906
if let Ok(display) = name.parse::<u32>() {

0 commit comments

Comments
 (0)