Skip to content

Commit

Permalink
Use ShowWindowCommand.Hide when positioning a win32 window that has n…
Browse files Browse the repository at this point in the history
…ot yet been shown
  • Loading branch information
TomEdwardsEnscape committed Mar 19, 2024
1 parent 84b06b2 commit 6c6d1b2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/Windows/Avalonia.Win32/WindowImpl.AppWndProc.cs
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,9 @@ protected virtual unsafe IntPtr AppWndProc(IntPtr hWnd, uint msg, IntPtr wParam,
SizeCommand.Maximized => WindowState.Maximized,
SizeCommand.Minimized => WindowState.Minimized,
_ when _isFullScreenActive => WindowState.FullScreen,
// Ignore state changes for unshown windows. We always tell Windows that we are hidden
// until shown, so the OS value should be ignored while we are in the unshown state.
_ when !_shown => _lastWindowState,
_ => WindowState.Normal,
};

Expand Down
2 changes: 1 addition & 1 deletion src/Windows/Avalonia.Win32/WindowImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ public void Resize(Size value, WindowResizeReason reason)

windowPlacement.NormalPosition = requestedWindowRect;

windowPlacement.ShowCmd = _lastWindowState switch
windowPlacement.ShowCmd = !_shown ? ShowWindowCommand.Hide : _lastWindowState switch
{
WindowState.Minimized => ShowWindowCommand.ShowMinNoActive,
WindowState.Maximized => ShowWindowCommand.ShowMaximized,
Expand Down

0 comments on commit 6c6d1b2

Please sign in to comment.