Skip to content

[desktop] Improve window handling#2056

Merged
AdamVe merged 9 commits intomainfrom
adamve/fix/2036_window_not_displaying
Jan 8, 2026
Merged

[desktop] Improve window handling#2056
AdamVe merged 9 commits intomainfrom
adamve/fix/2036_window_not_displaying

Conversation

@AdamVe
Copy link
Member

@AdamVe AdamVe commented Dec 16, 2025

Improve robustness against invalid or out-of-range window states and rapid window events

  • Apply clamping when reading and writing window bounds to preferences
  • Introduce delayed writes for window state persistence to reduce redundant disk operations

Fixes #2036

@AdamVe AdamVe requested a review from Copilot December 16, 2025 16:33
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves window state management on desktop platforms by adding bounds validation and implementing delayed persistence to reduce redundant disk operations.

Key changes:

  • Introduced window bounds clamping to prevent invalid or out-of-range dimensions
  • Refactored window state persistence with delayed writes using a timer to debounce rapid window events
  • Separated window state save/restore logic into dedicated methods

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
lib/desktop/window_manager_helper/window_manager_helper.dart Added bounds clamping logic and new save/restore methods for window state persistence
lib/desktop/window_manager_helper/_wm_helper_windows_impl.dart Extracted save/restore logic from getBounds into separate methods
lib/desktop/window_manager_helper/_wm_helper_macos_impl.dart Extracted save/restore logic and refactored display detection into a helper method
lib/desktop/init.dart Implemented delayed window state persistence using a timer and removed direct window bounds management
integration_test/utils.dart Renamed variable from window to windowManagerHelper for clarity

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@fdennis fdennis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on my Win 11. Worked very well for me and I tried various random scenarios and numbers for width, height, top, left.

_saveWindowManagerPropertiesTimer?.cancel();
_saveWindowManagerPropertiesTimer = Timer(
const Duration(
milliseconds: 500, // lower values result in invalid display properties
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a timer here? Is its purpose to prevent writing/saving too frequently? Was this an issue in the old code?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly that. The timer prevents racing conditions when persisting the values.

@AdamVe AdamVe merged commit 24acd12 into main Jan 8, 2026
21 checks passed
@AdamVe AdamVe deleted the adamve/fix/2036_window_not_displaying branch January 8, 2026 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

UI window empty or not displaying

2 participants