Skip to content

Commit

Permalink
only set window position on extended margins update when window is vi…
Browse files Browse the repository at this point in the history
…sible (#14954)
  • Loading branch information
emmauss authored and maxkatz6 committed Apr 6, 2024
1 parent ead5789 commit 5034b28
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions src/Windows/Avalonia.Win32/WindowImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,7 @@ private void ShowWindow(WindowState state, bool activate)

newWindowProperties.WindowState = state;

UpdateWindowProperties(newWindowProperties);
UpdateWindowProperties(newWindowProperties, newWindowProperties.Decorations != SystemDecorations.Full);

if (command.HasValue)
{
Expand Down Expand Up @@ -1468,21 +1468,25 @@ private void UpdateWindowProperties(WindowProperties newProperties, bool forceCh

DwmExtendFrameIntoClientArea(_hwnd, ref margins);

GetClientRect(_hwnd, out var oldClientRect);
var oldClientRectOrigin = new POINT();
ClientToScreen(_hwnd, ref oldClientRectOrigin);
oldClientRect.Offset(oldClientRectOrigin);

var newRect = oldClientRect;

if (newProperties.Decorations == SystemDecorations.Full)
if (_shown || forceChanges)
{
AdjustWindowRectEx(ref newRect, (uint)style, false, (uint)GetExtendedStyle());
}
GetClientRect(_hwnd, out var oldClientRect);
var oldClientRectOrigin = new POINT();
ClientToScreen(_hwnd, ref oldClientRectOrigin);
oldClientRect.Offset(oldClientRectOrigin);

var newRect = oldClientRect;

SetWindowPos(_hwnd, IntPtr.Zero, newRect.left, newRect.top, newRect.Width, newRect.Height,
SetWindowPosFlags.SWP_NOZORDER | SetWindowPosFlags.SWP_NOACTIVATE |
SetWindowPosFlags.SWP_FRAMECHANGED);
if (newProperties.Decorations == SystemDecorations.Full)
{
AdjustWindowRectEx(ref newRect, (uint)style, false, (uint)GetExtendedStyle());
}

SetWindowPos(_hwnd, IntPtr.Zero, newRect.left, newRect.top, newRect.Width, newRect.Height,
SetWindowPosFlags.SWP_NOZORDER | SetWindowPosFlags.SWP_NOACTIVATE |
SetWindowPosFlags.SWP_FRAMECHANGED);
}
}

// Ensure window state if decorations change
Expand Down

0 comments on commit 5034b28

Please sign in to comment.