From 79665bfc742a85a76c9ba3db6ff3242e3c67393b Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Mon, 5 Apr 2021 20:42:23 +0100 Subject: [PATCH] maintain the client size when switching between extended and non extended client areas. Previously the client area would grow to fill the window. --- src/Windows/Avalonia.Win32/WindowImpl.cs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Windows/Avalonia.Win32/WindowImpl.cs b/src/Windows/Avalonia.Win32/WindowImpl.cs index a42dd5fc07..feffa03d15 100644 --- a/src/Windows/Avalonia.Win32/WindowImpl.cs +++ b/src/Windows/Avalonia.Win32/WindowImpl.cs @@ -883,20 +883,19 @@ namespace Avalonia.Win32 _isClientAreaExtended = false; return; } - - GetWindowRect(_hwnd, out var rcClient); + GetClientRect(_hwnd, out var rcClient); + GetWindowRect(_hwnd, out var rcWindow); // Inform the application of the frame change. SetWindowPos(_hwnd, - IntPtr.Zero, - rcClient.left, rcClient.top, - rcClient.Width, rcClient.Height, - SetWindowPosFlags.SWP_FRAMECHANGED); - + IntPtr.Zero, + rcWindow.left, rcWindow.top, + rcClient.Width, rcClient.Height, + SetWindowPosFlags.SWP_FRAMECHANGED); + if (_isClientAreaExtended && WindowState != WindowState.FullScreen) { var margins = UpdateExtendMargins(); - DwmExtendFrameIntoClientArea(_hwnd, ref margins); } else @@ -906,6 +905,8 @@ namespace Avalonia.Win32 _offScreenMargin = new Thickness(); _extendedMargins = new Thickness(); + + Resize(new Size(rcWindow.Width, rcWindow.Height)); } if(!_isClientAreaExtended || (_extendChromeHints.HasFlagCustom(ExtendClientAreaChromeHints.SystemChrome) &&