File tree Expand file tree Collapse file tree 1 file changed +20
-6
lines changed
src/Windows/Avalonia.Win32 Expand file tree Collapse file tree 1 file changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -581,13 +581,27 @@ public void Resize(Size value, WindowResizeReason reason)
581
581
return ;
582
582
}
583
583
584
- var position = Position ;
585
- requestedWindowRect . left = position . X ;
586
- requestedWindowRect . top = position . Y ;
587
- requestedWindowRect . right = position . X + windowWidth ;
588
- requestedWindowRect . bottom = position . Y + windowHeight ;
584
+ // If the window is minimized, don't change the restore position, because this.Position is currently
585
+ // out of screen with values similar to -32000,-32000. Windows considers such a position invalid on restore
586
+ // and instead moves the window back to 0,0.
587
+ if ( windowPlacement . ShowCmd == ShowWindowCommand . ShowMinimized )
588
+ {
589
+ // The window is minimized but will be restored to maximized: don't change our normal size,
590
+ // or it will incorrectly be set to the maximized size.
591
+ if ( ( windowPlacement . Flags & WindowPlacementFlags . RestoreToMaximized ) != 0 )
592
+ {
593
+ return ;
594
+ }
595
+ }
596
+ else
597
+ {
598
+ var position = Position ;
599
+ windowPlacement . NormalPosition . left = position . X ;
600
+ windowPlacement . NormalPosition . top = position . Y ;
601
+ }
589
602
590
- windowPlacement . NormalPosition = requestedWindowRect ;
603
+ windowPlacement . NormalPosition . right = windowPlacement . NormalPosition . left + windowWidth ;
604
+ windowPlacement . NormalPosition . bottom = windowPlacement . NormalPosition . top + windowHeight ;
591
605
592
606
windowPlacement . ShowCmd = ! _shown ? ShowWindowCommand . Hide : _lastWindowState switch
593
607
{
You can’t perform that action at this time.
0 commit comments