mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-12-12 11:06:57 +00: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:
@@ -1253,7 +1253,7 @@ class _ResolutionsMenuState extends State<_ResolutionsMenu> {
|
||||
FFI get ffi => widget.ffi;
|
||||
PeerInfo get pi => widget.ffi.ffiModel.pi;
|
||||
FfiModel get ffiModel => widget.ffi.ffiModel;
|
||||
Rect? get rect => ffiModel.rect;
|
||||
Rect? get rect => scaledRect();
|
||||
List<Resolution> get resolutions => pi.resolutions;
|
||||
bool get isWayland => bind.mainCurrentIsWayland();
|
||||
|
||||
@@ -1263,6 +1263,20 @@ class _ResolutionsMenuState extends State<_ResolutionsMenu> {
|
||||
_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
|
||||
Widget build(BuildContext context) {
|
||||
final isVirtualDisplay = ffiModel.isVirtualDisplayResolution;
|
||||
@@ -1296,9 +1310,8 @@ class _ResolutionsMenuState extends State<_ResolutionsMenu> {
|
||||
if (lastGroupValue == _kCustomResolutionValue) {
|
||||
_groupValue = _kCustomResolutionValue;
|
||||
} else {
|
||||
var scale = pi.scaleOfDisplay(pi.currentDisplay);
|
||||
_groupValue =
|
||||
'${(rect?.width ?? 0) ~/ scale}x${(rect?.height ?? 0) ~/ scale}';
|
||||
'${(rect?.width ?? 0).toInt()}x${(rect?.height ?? 0).toInt()}';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user