From cb3e491c325a9872c33a56601dc252bce0891f05 Mon Sep 17 00:00:00 2001 From: Elias Bonnici Date: Wed, 17 Apr 2024 10:50:39 +0200 Subject: [PATCH] WINDOWS: Recompute default size based on scaling factor --- .../_wm_helper_windows_impl.dart | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/desktop/window_manager_helper/_wm_helper_windows_impl.dart b/lib/desktop/window_manager_helper/_wm_helper_windows_impl.dart index f7b316b8..df5e4bfa 100644 --- a/lib/desktop/window_manager_helper/_wm_helper_windows_impl.dart +++ b/lib/desktop/window_manager_helper/_wm_helper_windows_impl.dart @@ -58,14 +58,17 @@ class WindowManagerHelperWindows { final primaryDisplay = await screenRetriever.getPrimaryDisplay(); final primaryScaleFactor = primaryDisplay.scaleFactor?.toDouble() ?? 1.0; - final savedScaleFactor = prefs.getDouble(_keyPrimaryScaleFactor) ?? 1.0; + final savedScaleFactor = prefs.getDouble(_keyPrimaryScaleFactor); + final hasSavedScaleFactor = savedScaleFactor != null; - final savedBounds = Rect.fromLTWH( - bounds.left, - bounds.top, - bounds.width / savedScaleFactor * primaryScaleFactor, - bounds.height / savedScaleFactor * primaryScaleFactor, - ); + var height = hasSavedScaleFactor + ? bounds.height / savedScaleFactor * primaryScaleFactor + : bounds.height; + var width = hasSavedScaleFactor + ? bounds.width / savedScaleFactor * primaryScaleFactor + : bounds.width; + + final savedBounds = Rect.fromLTWH(bounds.left, bounds.top, width, height); final configChanged = await _displayConfigurationChanged(prefs); final windowRect =