Ability to set initial window size and position and restore previous values
- Dominant language
- C#
- Stars
- 23.3k
- Forks
- 2k
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 290
Description
### Description
I wish to be able to define a default starting size and position for the MAUI application and to restore the window position and size the next time the application is launched.
While I understand the paradigm of starting MAUI apps as full-screen (or close to full screen), it is very impractical for users to have ultra-wide monitors (in my case a 49" 5440x1440 monitor); I literally have to turn my head to change from the left side to the right side of the monitor.
I have a work-around for the initial window size and position* (except for not being able to determine the screen size, so I cannot do bounds checking to make sure the window is wholly within the screen for different resolutions / monitor sizes) but would prefer to have official support, cross platform to MacOS, for this functionality.
### Public API Changes
```csharp
int initialWidth = 1024;
int initialHeight = 726;
Screen primary = Screen.GetPrimaryScreen(); // New API
RectInt32 sizeAndPosition = new RectInt32(
primary.Width/2 - initialWidth/2,
primary.Height/2 - initialHeight/2,
initialWidth,
initialHeight);
Window window = new Window(new SomePage(), sizeAndPosition); // New API
```
### Intended Use-Case
My app has two distinct modes of operation; Full mode for Desktop environments (Windows / MacOS) and Player for mobile devices (Android / iOS). On desktop environments (Windows / MacOS), full screen is not a desired initial state for the application.
If the user has resized and positioned the window in a specific location of the screen - as long as that position + size is still valid the application should re-launch to that position and size.
Contributor guide
Research direction
Start by reviewing the proposed Window and Screen APIs in this issue and the existing desktop window behavior in .NET MAUI. Determine how initial size and position, screen bounds checking, and restoring values should work across Windows and macOS; done means desktop apps can set a default window geometry and relaunch with a still-valid previous geometry.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- desktop
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100