mac scale factor of each screen (#8368)
Signed-off-by: 21pages <sunboeasy@gmail.com>
This commit is contained in:
parent
12ff1319f1
commit
60ea8d2c2b
@ -71,7 +71,7 @@ impl Display {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn scale(self) -> f64 {
|
pub fn scale(self) -> f64 {
|
||||||
let s = unsafe { BackingScaleFactor() as _ };
|
let s = unsafe { BackingScaleFactor(self.0) as _ };
|
||||||
if s > 1. {
|
if s > 1. {
|
||||||
let enable_retina = super::ENABLE_RETINA.lock().unwrap().clone();
|
let enable_retina = super::ENABLE_RETINA.lock().unwrap().clone();
|
||||||
if enable_retina {
|
if enable_retina {
|
||||||
|
@ -193,7 +193,7 @@ extern "C" {
|
|||||||
pub fn CGDisplayIsOnline(display: u32) -> i32;
|
pub fn CGDisplayIsOnline(display: u32) -> i32;
|
||||||
|
|
||||||
pub fn CGDisplayBounds(display: u32) -> CGRect;
|
pub fn CGDisplayBounds(display: u32) -> CGRect;
|
||||||
pub fn BackingScaleFactor() -> f32;
|
pub fn BackingScaleFactor(display: u32) -> f32;
|
||||||
|
|
||||||
// IOSurface
|
// IOSurface
|
||||||
|
|
||||||
|
@ -109,9 +109,13 @@ extern "C" bool MacCheckAdminAuthorization() {
|
|||||||
return Elevate(NULL, NULL);
|
return Elevate(NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" float BackingScaleFactor() {
|
extern "C" float BackingScaleFactor(uint32_t display) {
|
||||||
NSScreen* s = [NSScreen mainScreen];
|
display -= 1;
|
||||||
if (s) return [s backingScaleFactor];
|
NSArray<NSScreen *> *screens = [NSScreen screens];
|
||||||
|
if (display >= 0 && display < [screens count]) {
|
||||||
|
NSScreen* s = [screens objectAtIndex:display];
|
||||||
|
if (s) return [s backingScaleFactor];
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user