From 05bbef0b8aef606bd50a0b783ea8b6db90dcd65a Mon Sep 17 00:00:00 2001 From: nyne Date: Mon, 11 Nov 2024 18:43:32 +0800 Subject: [PATCH] fix #30 --- lib/components/window_frame.dart | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/components/window_frame.dart b/lib/components/window_frame.dart index fda1520..9caefd5 100644 --- a/lib/components/window_frame.dart +++ b/lib/components/window_frame.dart @@ -485,8 +485,15 @@ class WindowPlacement { } } + static Rect? lastValidRect; + static Future get current async { var rect = await windowManager.getBounds(); + if(validate(rect)) { + lastValidRect = rect; + } else { + rect = lastValidRect ?? defaultPlacement.rect; + } var isMaximized = await windowManager.isMaximized(); return WindowPlacement(rect, isMaximized); } @@ -501,9 +508,6 @@ class WindowPlacement { static void loop() async { timer ??= Timer.periodic(const Duration(milliseconds: 100), (timer) async { var placement = await WindowPlacement.current; - if (!validate(placement.rect)) { - return; - } if (placement.rect != cache.rect || placement.isMaximized != cache.isMaximized) { cache = placement;