Skip to content

Avalonia: remember size and position#4805

Merged
Gabriel Dufresne (GabrielDuf) merged 2 commits into
mainfrom
remember-size-position
May 20, 2026
Merged

Avalonia: remember size and position#4805
Gabriel Dufresne (GabrielDuf) merged 2 commits into
mainfrom
remember-size-position

Conversation

@GabrielDuf
Copy link
Copy Markdown
Contributor

@GabrielDuf Gabriel Dufresne (GabrielDuf) commented May 19, 2026

This pull request introduces persistent window geometry management to the MainWindow in src/UniGetUI.Avalonia/Views/MainWindow.axaml.cs. The changes ensure that the window's size, position, and state are saved and restored across application restarts, and improve handling of DPI scaling and user interactions with the window. The most significant updates are grouped below:

Window Geometry Persistence:

  • Added methods to save (SaveGeometryAsync, SaveGeometryNow) and restore (RestoreGeometry) the window's geometry (position, size, and maximized state) using the Settings system, including logic to verify restored bounds are visible on the current desktop configuration. These methods are called on window events such as resize, position change, and closing.

DPI and Window Minimum Size Handling (Windows-specific):

  • Enhanced the Windows message handler to correctly calculate minimum window sizes by accounting for DPI scaling and window frame sizes, using new P/Invoke calls to GetDpiForWindow and AdjustWindowRectExForDpi.

User Interaction Improvements:

  • Improved the title bar pointer handler to support double-clicking for maximize/restore and to avoid starting a drag unless the left mouse button is pressed.

fix issue #4799

@GabrielDuf Gabriel Dufresne (GabrielDuf) merged commit 5c24a77 into main May 20, 2026
3 checks passed
@GabrielDuf Gabriel Dufresne (GabrielDuf) deleted the remember-size-position branch May 20, 2026 12:04
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