Browse Source

only set window position on extended margins update when window is visible (#14954)

pull/15037/head
Emmanuel Hansen 2 years ago
committed by GitHub
parent
commit
4c949ee628
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 30
      src/Windows/Avalonia.Win32/WindowImpl.cs

30
src/Windows/Avalonia.Win32/WindowImpl.cs

@ -1199,7 +1199,7 @@ namespace Avalonia.Win32
newWindowProperties.WindowState = state; newWindowProperties.WindowState = state;
UpdateWindowProperties(newWindowProperties); UpdateWindowProperties(newWindowProperties, newWindowProperties.Decorations != SystemDecorations.Full);
if (command.HasValue) if (command.HasValue)
{ {
@ -1468,21 +1468,25 @@ namespace Avalonia.Win32
DwmExtendFrameIntoClientArea(_hwnd, ref margins); 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, if (newProperties.Decorations == SystemDecorations.Full)
SetWindowPosFlags.SWP_NOZORDER | SetWindowPosFlags.SWP_NOACTIVATE | {
SetWindowPosFlags.SWP_FRAMECHANGED); 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 // Ensure window state if decorations change

Loading…
Cancel
Save