-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow a win32 window's restored size to be defined even when it is maximised or minimised #14470
Allow a win32 window's restored size to be defined even when it is maximised or minimised #14470
Conversation
I don't think this is the correct fix. |
It might be a placeholder, but nevertheless the size of a minimised window is stored by Windows and is sent back to the application as a This is the behaviour that Avalonia expects, so I think that removing the inconsistency between minimised and non-minimised windows is a good approach.
This is OK in principle, but it doesn't map well onto the Avalonia API, in which windows have public |
The behavior in other win32 applications is just to return the window size before it was last minimized, and any resize operation is ignored after the window was minimized. This is exactly what Avalonia currently doing, so I'm not sure whether this should be fixed. |
Avalonia doesn't ignore the resize. It accepts it the new value for its own window object without transferring it to the OS, which is inconsistent. It should either apply the new value in both places, or in neither (i.e. throw an exception). |
It should either outright reject the change or buffer it from the sound of things. Quickly making it visible then invisible feels like a hack to me, and I imagine on some slow systems may lead to noticeable flickering. If you do go with rejecting the change, you probably also need to add a new property/method that says if the window can be resized. |
I don't think the window would ever appear, because we are executing on the UI thread and thus blocking it. But yeah, buffering the value is the (more complicated) alternative if we don't like re-minimising. I'm not a fan of blocking changes to the properties because these limitations may not exist on other platforms. |
Wouldn't it be better to defer resizing to when the window is restored? |
Coming from WinForms, I know there's a concept called "RestoreBounds" on a form:
Maybe something like this would be a good approach. |
It sounds like most people would prefer buffering the value until the window is restored. |
Can't this be fixed using |
Well well well:
WPF stands here for "Window Placement Flags". So it's not the silver bullet I had expected. Still worth looking at though. |
866c181
to
7633f87
Compare
|
@@ -1426,6 +1450,23 @@ private static void EnableCloseButton(IntPtr hwnd) | |||
MF_BYCOMMAND | MF_ENABLED); | |||
} | |||
|
|||
private RECT ClientRectToWindowRect(RECT clientRect, WindowStyles? styleOverride = null, WindowStyles? extendedStyleOverride = null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are several other uses of AdjustWindowRectEx
which could be redirected to this method. These other locations currently don't account for per-window DPI, so using this method may fix some bugs. But I decided not to make unnecessary changes in this PR.
You can test this PR using the following package version. |
797927b
to
4defeb2
Compare
|
||
// do comparison after scaling to avoid rounding issues | ||
if (requestedClientWidth != clientRect.Width || requestedClientHeight != clientRect.Height) | ||
if (_lastWindowState == WindowState.FullScreen) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still can't resize a fullscreen window, but I don't think this will ever be supported for the reasons outlined in the comment here. This is not a regression, it's the same behaviour as on master.
You can test this PR using the following package version. |
4defeb2
to
bc36c4c
Compare
You can test this PR using the following package version. |
@emmauss this is ready for review again. |
LGTM, just want to have @emmauss opinion as well, as it might affect XPF. |
Could you rebase your branch? |
bc36c4c
to
92ab0e3
Compare
You can test this PR using the following package version. |
@TomEdwardsEnscape it looks like there are conflicts. It cannot be automatically resolved, and we can't push to your remote branch. |
Head branch was pushed to by a user without write access
92ab0e3
to
e2f0b68
Compare
You can test this PR using the following package version. |
This PR rewrites
WindowImpl.Resize
to useSetWindowPlacement
, which allows us to set the size of the window even when it is minimised or maximised.Breaking changes
None
Obsoletions / Deprecations
None
Fixed issues
Fixes #13300