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

@@ -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()}';
}
}