Fix: Mac retina display video blur (#6980)

* fix mac retina display blur

Signed-off-by: Sahil Yeole <sahilyeole93@gmail.com>

* Update display.rs

---------

Signed-off-by: Sahil Yeole <sahilyeole93@gmail.com>
Co-authored-by: RustDesk <71636191+rustdesk@users.noreply.github.com>
This commit is contained in:
Sahil Yeole 2024-01-26 10:20:13 +05:30 committed by GitHub
parent a0d79dd26d
commit 1d755c705b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 2 deletions

View File

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

View File

@ -193,6 +193,7 @@ extern "C" {
pub fn CGDisplayIsOnline(display: u32) -> i32;
pub fn CGDisplayBounds(display: u32) -> CGRect;
pub fn BackingScaleFactor() -> f32;
// IOSurface