Skip to content

Fix Avalonia main window growing on every restart (Windows)#5056

Merged
Gabriel Dufresne (GabrielDuf) merged 1 commit into
mainfrom
fix/window-grows-on-restart
Jul 7, 2026
Merged

Fix Avalonia main window growing on every restart (Windows)#5056
Gabriel Dufresne (GabrielDuf) merged 1 commit into
mainfrom
fix/window-grows-on-restart

Conversation

@GabrielDuf

Copy link
Copy Markdown
Contributor

This pull request improves the reliability of restoring the main window's size on Windows by addressing a long-standing issue with frame drift when reopening the application. The changes ensure that the window's outer size is restored exactly as saved, preventing gradual inflation of the window over multiple launches.

Window geometry restoration improvements:

  • Added _pendingRestoreWidth and _pendingRestoreHeight fields to temporarily store the saved window size for native restoration on Windows.
  • Modified RestoreGeometry() to set these pending size fields on Windows, instead of relying solely on Avalonia's Width and Height setters, which previously caused window size drift.
  • Updated OnOpened() to natively restore the window's outer size using SetWindowPos and DPI scaling, ensuring the restored size matches the original exactly and eliminating frame drift.

@GabrielDuf Gabriel Dufresne (GabrielDuf) merged commit 23b2ea5 into main Jul 7, 2026
3 checks passed
@GabrielDuf Gabriel Dufresne (GabrielDuf) deleted the fix/window-grows-on-restart branch July 7, 2026 19:59
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.

2 participants