Browse Source

Win32: fix position being changed on Resize while minimized (#17559)

release/11.2.2
Julien Lebosquain 1 year ago
committed by Max Katz
parent
commit
8f5d5061da
  1. 26
      src/Windows/Avalonia.Win32/WindowImpl.cs

26
src/Windows/Avalonia.Win32/WindowImpl.cs

@ -581,13 +581,27 @@ namespace Avalonia.Win32
return; return;
} }
var position = Position; // If the window is minimized, don't change the restore position, because this.Position is currently
requestedWindowRect.left = position.X; // out of screen with values similar to -32000,-32000. Windows considers such a position invalid on restore
requestedWindowRect.top = position.Y; // and instead moves the window back to 0,0.
requestedWindowRect.right = position.X + windowWidth; if (windowPlacement.ShowCmd == ShowWindowCommand.ShowMinimized)
requestedWindowRect.bottom = position.Y + windowHeight; {
// The window is minimized but will be restored to maximized: don't change our normal size,
// or it will incorrectly be set to the maximized size.
if ((windowPlacement.Flags & WindowPlacementFlags.RestoreToMaximized) != 0)
{
return;
}
}
else
{
var position = Position;
windowPlacement.NormalPosition.left = position.X;
windowPlacement.NormalPosition.top = position.Y;
}
windowPlacement.NormalPosition = requestedWindowRect; windowPlacement.NormalPosition.right = windowPlacement.NormalPosition.left + windowWidth;
windowPlacement.NormalPosition.bottom = windowPlacement.NormalPosition.top + windowHeight;
windowPlacement.ShowCmd = !_shown ? ShowWindowCommand.Hide : _lastWindowState switch windowPlacement.ShowCmd = !_shown ? ShowWindowCommand.Hide : _lastWindowState switch
{ {

Loading…
Cancel
Save