mirror of
https://github.com/weyne85/rustdesk.git
synced 2025-10-29 17:00:05 +00:00
enable retina scale factor (#7269)
* enable retina scale factor * enabled only when there are only one video service running * scale mouse event * scale cursor position * scale remote menu display button * adjust resolution Signed-off-by: 21pages <pages21@163.com> * Update server.rs --------- Signed-off-by: 21pages <pages21@163.com> Co-authored-by: RustDesk <71636191+rustdesk@users.noreply.github.com>
This commit is contained in:
@@ -128,6 +128,10 @@ impl Display {
|
||||
self.0.height()
|
||||
}
|
||||
|
||||
pub fn scale(&self) -> f64 {
|
||||
self.0.scale()
|
||||
}
|
||||
|
||||
pub fn name(&self) -> String {
|
||||
self.0.id().to_string()
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ impl Display {
|
||||
let w = unsafe { CGDisplayPixelsWide(self.0) };
|
||||
let s = self.scale();
|
||||
if s > 1.0 {
|
||||
((w as f64) * s).round() as usize
|
||||
((w as f64) * s).round() as usize
|
||||
} else {
|
||||
w
|
||||
}
|
||||
@@ -48,7 +48,7 @@ impl Display {
|
||||
let h = unsafe { CGDisplayPixelsHigh(self.0) };
|
||||
let s = self.scale();
|
||||
if s > 1.0 {
|
||||
((h as f64) * s).round() as usize
|
||||
((h as f64) * s).round() as usize
|
||||
} else {
|
||||
h
|
||||
}
|
||||
@@ -71,7 +71,13 @@ impl Display {
|
||||
}
|
||||
|
||||
pub fn scale(self) -> f64 {
|
||||
// unsafe { BackingScaleFactor() as _ }
|
||||
let s = unsafe { BackingScaleFactor() as _ };
|
||||
if s > 1. {
|
||||
let enable_retina = super::ENABLE_RETINA.lock().unwrap().clone();
|
||||
if enable_retina {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
1.
|
||||
}
|
||||
|
||||
|
||||
@@ -9,3 +9,9 @@ mod config;
|
||||
mod display;
|
||||
pub mod ffi;
|
||||
mod frame;
|
||||
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
lazy_static::lazy_static! {
|
||||
pub static ref ENABLE_RETINA: Arc<Mutex<bool>> = Arc::new(Mutex::new(true));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user