diff --git a/libs/scrap/src/quartz/display.rs b/libs/scrap/src/quartz/display.rs index 47ace49db..9c2db6bfd 100644 --- a/libs/scrap/src/quartz/display.rs +++ b/libs/scrap/src/quartz/display.rs @@ -35,11 +35,23 @@ impl Display { } pub fn width(self) -> usize { - unsafe { CGDisplayPixelsWide(self.0) } + let w = unsafe { CGDisplayPixelsWide(self.0) }; + let s = self.scale(); + if s > 1.0 { + ((w as f64) * s) as usize + } else { + w + } } pub fn height(self) -> usize { - unsafe { CGDisplayPixelsHigh(self.0) } + let h = unsafe { CGDisplayPixelsHigh(self.0) }; + let s = self.scale(); + if s > 1.0 { + ((h as f64) * s) as usize + } else { + h + } } pub fn is_builtin(self) -> bool { @@ -58,6 +70,10 @@ impl Display { unsafe { CGDisplayIsOnline(self.0) != 0 } } + pub fn scale(self) -> f64 { + unsafe { BackingScaleFactor() } as _ + } + pub fn bounds(self) -> CGRect { unsafe { CGDisplayBounds(self.0) } } diff --git a/libs/scrap/src/quartz/ffi.rs b/libs/scrap/src/quartz/ffi.rs index 6b8c6e0e1..7cc57e29e 100644 --- a/libs/scrap/src/quartz/ffi.rs +++ b/libs/scrap/src/quartz/ffi.rs @@ -193,6 +193,7 @@ extern "C" { pub fn CGDisplayIsOnline(display: u32) -> i32; pub fn CGDisplayBounds(display: u32) -> CGRect; + pub fn BackingScaleFactor() -> f32; // IOSurface