mirror of
https://github.com/rustdesk/rustdesk.git
synced 2024-11-24 04:12:20 +08:00
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:
parent
57510980ed
commit
de65c8b2cf
@ -1253,7 +1253,7 @@ class _ResolutionsMenuState extends State<_ResolutionsMenu> {
|
|||||||
FFI get ffi => widget.ffi;
|
FFI get ffi => widget.ffi;
|
||||||
PeerInfo get pi => widget.ffi.ffiModel.pi;
|
PeerInfo get pi => widget.ffi.ffiModel.pi;
|
||||||
FfiModel get ffiModel => widget.ffi.ffiModel;
|
FfiModel get ffiModel => widget.ffi.ffiModel;
|
||||||
Rect? get rect => ffiModel.rect;
|
Rect? get rect => scaledRect();
|
||||||
List<Resolution> get resolutions => pi.resolutions;
|
List<Resolution> get resolutions => pi.resolutions;
|
||||||
bool get isWayland => bind.mainCurrentIsWayland();
|
bool get isWayland => bind.mainCurrentIsWayland();
|
||||||
|
|
||||||
@ -1263,6 +1263,20 @@ class _ResolutionsMenuState extends State<_ResolutionsMenu> {
|
|||||||
_getLocalResolutionWayland();
|
_getLocalResolutionWayland();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Rect? scaledRect() {
|
||||||
|
final scale = pi.scaleOfDisplay(pi.currentDisplay);
|
||||||
|
final rect = ffiModel.rect;
|
||||||
|
if (rect == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return Rect.fromLTWH(
|
||||||
|
rect.left,
|
||||||
|
rect.top,
|
||||||
|
rect.width / scale,
|
||||||
|
rect.height / scale,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final isVirtualDisplay = ffiModel.isVirtualDisplayResolution;
|
final isVirtualDisplay = ffiModel.isVirtualDisplayResolution;
|
||||||
@ -1296,9 +1310,8 @@ class _ResolutionsMenuState extends State<_ResolutionsMenu> {
|
|||||||
if (lastGroupValue == _kCustomResolutionValue) {
|
if (lastGroupValue == _kCustomResolutionValue) {
|
||||||
_groupValue = _kCustomResolutionValue;
|
_groupValue = _kCustomResolutionValue;
|
||||||
} else {
|
} else {
|
||||||
var scale = pi.scaleOfDisplay(pi.currentDisplay);
|
|
||||||
_groupValue =
|
_groupValue =
|
||||||
'${(rect?.width ?? 0) ~/ scale}x${(rect?.height ?? 0) ~/ scale}';
|
'${(rect?.width ?? 0).toInt()}x${(rect?.height ?? 0).toInt()}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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]
|
#[inline]
|
||||||
@ -235,9 +237,13 @@ pub(super) fn get_original_resolution(
|
|||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
} else {
|
} 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) {
|
let (width, height) = match changed_resolutions.get(display_name) {
|
||||||
Some(res) => {
|
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 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.
|
// If the resolution is changed by third process, remove the record in changed_resolutions.
|
||||||
changed_resolutions.remove(display_name);
|
changed_resolutions.remove(display_name);
|
||||||
@ -245,6 +251,7 @@ pub(super) fn get_original_resolution(
|
|||||||
} else {
|
} else {
|
||||||
res.original
|
res.original
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
None => (w as _, h as _),
|
None => (w as _, h as _),
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user