fix resolution restoration (#7572)

* Fix resolution restore. Screen resolution changes may be slow and cause errors in judgment. Remove the consideration of resolution changes caused by other processes.
* Keep the design unchange: when all connections end, revert to the resolution when there were no connections.
* Resolution menu use `scaledRect` for retina
* I can't reproduce the restoration failure of retina with 3rd software, but it maybe the same reason of slow resolution change.

Signed-off-by: 21pages <pages21@163.com>
This commit is contained in:
21pages
2024-04-01 17:20:19 +08:00
committed by GitHub
parent 57510980ed
commit de65c8b2cf
2 changed files with 24 additions and 4 deletions

View File

@@ -122,6 +122,8 @@ pub fn reset_resolutions() {
);
}
}
// Can be cleared because reset resolutions is called when there is no client connected.
CHANGED_RESOLUTIONS.write().unwrap().clear();
}
#[inline]
@@ -235,9 +237,13 @@ pub(super) fn get_original_resolution(
..Default::default()
}
} else {
let mut changed_resolutions = CHANGED_RESOLUTIONS.write().unwrap();
let changed_resolutions = CHANGED_RESOLUTIONS.write().unwrap();
let (width, height) = match changed_resolutions.get(display_name) {
Some(res) => {
res.original
/*
The resolution change may not happen immediately, `changed` has been updated,
but the actual resolution is old, it will be mistaken for a third-party change.
if res.changed.0 != w as i32 || res.changed.1 != h as i32 {
// If the resolution is changed by third process, remove the record in changed_resolutions.
changed_resolutions.remove(display_name);
@@ -245,6 +251,7 @@ pub(super) fn get_original_resolution(
} else {
res.original
}
*/
}
None => (w as _, h as _),
};