Skip to content
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

Use ShowWindowCommand.Hide when positioning an unshown win32 window #15035

Merged
merged 1 commit into from
Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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