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;
}
var position = Position;
requestedWindowRect.left = position.X;
requestedWindowRect.top = position.Y;
requestedWindowRect.right = position.X + windowWidth;
requestedWindowRect.bottom = position.Y + windowHeight;
// If the window is minimized, don't change the restore position, because this.Position is currently
// out of screen with values similar to -32000,-32000. Windows considers such a position invalid on restore
// and instead moves the window back to 0,0.
if (windowPlacement.ShowCmd == ShowWindowCommand.ShowMinimized)
{
// 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
{

Loading…
Cancel
Save