diff --git a/samples/ControlCatalog/ViewModels/MainWindowViewModel.cs b/samples/ControlCatalog/ViewModels/MainWindowViewModel.cs index e8dd12269b..4356a032fa 100644 --- a/samples/ControlCatalog/ViewModels/MainWindowViewModel.cs +++ b/samples/ControlCatalog/ViewModels/MainWindowViewModel.cs @@ -78,12 +78,12 @@ namespace ControlCatalog.ViewModels if(x.Item1) { - hints |= ExtendClientAreaChromeHints.SystemTitleBar; + hints |= ExtendClientAreaChromeHints.SystemChrome; } if(x.Item2) { - hints |= ExtendClientAreaChromeHints.PreferSystemChromeButtons; + hints |= ExtendClientAreaChromeHints.PreferSystemChrome; } ChromeHints = hints; diff --git a/src/Avalonia.Controls/Platform/ExtendClientAreaChromeHints.cs b/src/Avalonia.Controls/Platform/ExtendClientAreaChromeHints.cs index fb6a4056db..deb9e417ab 100644 --- a/src/Avalonia.Controls/Platform/ExtendClientAreaChromeHints.cs +++ b/src/Avalonia.Controls/Platform/ExtendClientAreaChromeHints.cs @@ -6,9 +6,9 @@ namespace Avalonia.Platform public enum ExtendClientAreaChromeHints { NoChrome, - Default = SystemTitleBar, - SystemTitleBar = 0x01, - PreferSystemChromeButtons = 0x02, + Default = SystemChrome, + SystemChrome = 0x01, + PreferSystemChrome = 0x02, OSXThickTitleBar = 0x08, } } diff --git a/src/Windows/Avalonia.Win32/WindowImpl.cs b/src/Windows/Avalonia.Win32/WindowImpl.cs index 6025f96d22..4b64eabc26 100644 --- a/src/Windows/Avalonia.Win32/WindowImpl.cs +++ b/src/Windows/Avalonia.Win32/WindowImpl.cs @@ -694,7 +694,7 @@ namespace Avalonia.Win32 borderCaptionThickness.left *= -1; borderCaptionThickness.top *= -1; - bool wantsTitleBar = _extendChromeHints.HasFlag(ExtendClientAreaChromeHints.SystemTitleBar) || _extendTitleBarHint == -1; + bool wantsTitleBar = _extendChromeHints.HasFlag(ExtendClientAreaChromeHints.SystemChrome) || _extendTitleBarHint == -1; if (!wantsTitleBar) { @@ -711,7 +711,7 @@ namespace Avalonia.Win32 borderCaptionThickness.top = (int)(_extendTitleBarHint * Scaling); } - margins.cyTopHeight = _extendChromeHints.HasFlag(ExtendClientAreaChromeHints.SystemTitleBar) ? borderCaptionThickness.top : 1; + margins.cyTopHeight = _extendChromeHints.HasFlag(ExtendClientAreaChromeHints.SystemChrome) && !_extendChromeHints.HasFlag(ExtendClientAreaChromeHints.PreferSystemChrome) ? borderCaptionThickness.top : 1; if (WindowState == WindowState.Maximized) { @@ -727,7 +727,7 @@ namespace Avalonia.Win32 return margins; } - private void ExtendClientArea () + private void ExtendClientArea() { if (DwmIsCompositionEnabled(out bool compositionEnabled) < 0 || !compositionEnabled) { @@ -735,36 +735,28 @@ namespace Avalonia.Win32 return; } - if (!_isClientAreaExtended || WindowState == WindowState.FullScreen) + GetWindowRect(_hwnd, out var rcClient); + + // Inform the application of the frame change. + SetWindowPos(_hwnd, + IntPtr.Zero, + rcClient.left, rcClient.top, + rcClient.Width, rcClient.Height, + SetWindowPosFlags.SWP_FRAMECHANGED); + + if (_isClientAreaExtended && WindowState != WindowState.FullScreen) { - _extendedMargins = new Thickness(0, 0, 0, 0); - _offScreenMargin = new Thickness(); + var margins = UpdateExtendMargins(); + + DwmExtendFrameIntoClientArea(_hwnd, ref margins); } else { - GetWindowRect(_hwnd, out var rcClient); - - // Inform the application of the frame change. - SetWindowPos(_hwnd, - IntPtr.Zero, - rcClient.left, rcClient.top, - rcClient.Width, rcClient.Height, - SetWindowPosFlags.SWP_FRAMECHANGED); - - if (_isClientAreaExtended) - { - var margins = UpdateExtendMargins(); + var margins = new MARGINS(); + DwmExtendFrameIntoClientArea(_hwnd, ref margins); - DwmExtendFrameIntoClientArea(_hwnd, ref margins); - } - else - { - var margins = new MARGINS(); - DwmExtendFrameIntoClientArea(_hwnd, ref margins); - - _offScreenMargin = new Thickness(); - _extendedMargins = new Thickness(); - } + _offScreenMargin = new Thickness(); + _extendedMargins = new Thickness(); } ExtendClientAreaToDecorationsChanged?.Invoke(_isClientAreaExtended); @@ -1061,7 +1053,7 @@ namespace Avalonia.Win32 public Action ExtendClientAreaToDecorationsChanged { get; set; } /// - public bool NeedsManagedDecorations => _isClientAreaExtended && _extendChromeHints.HasFlag(ExtendClientAreaChromeHints.PreferSystemChromeButtons); + public bool NeedsManagedDecorations => _isClientAreaExtended && _extendChromeHints.HasFlag(ExtendClientAreaChromeHints.PreferSystemChrome); /// public Thickness ExtendedMargins => _extendedMargins;