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
  • Loading branch information
emmauss committed Mar 13, 2024
1 parent fb632f0 commit 207efa1
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/Windows/Avalonia.Win32/WindowImpl.cs
Original file line number Diff line number Diff line change
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 207efa1

Please sign in to comment.