From 68e8541f7534a0c5191c1255aaf801472cb219fa Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Wed, 20 May 2020 17:57:21 -0300 Subject: [PATCH] use thickness as the ExtendClientArea hint. --- src/Avalonia.Controls/Platform/IWindowImpl.cs | 2 +- src/Avalonia.Controls/Window.cs | 10 +++++----- .../Remote/PreviewerWindowImpl.cs | 2 +- src/Avalonia.DesignerSupport/Remote/Stubs.cs | 2 +- src/Avalonia.Native/WindowImpl.cs | 2 +- src/Avalonia.X11/X11Window.cs | 2 +- src/Windows/Avalonia.Win32/WindowImpl.cs | 19 +++++++++---------- 7 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/Avalonia.Controls/Platform/IWindowImpl.cs b/src/Avalonia.Controls/Platform/IWindowImpl.cs index 9c4808a41c..604c3a61aa 100644 --- a/src/Avalonia.Controls/Platform/IWindowImpl.cs +++ b/src/Avalonia.Controls/Platform/IWindowImpl.cs @@ -95,7 +95,7 @@ namespace Avalonia.Platform /// void SetMinMaxSize(Size minSize, Size maxSize); - bool ExtendClientAreaToDecorationsHint { get; set; } + Thickness ExtendClientAreaToDecorationsHint { get; set; } Action ExtendClientAreaToDecorationsChanged { get; set; } diff --git a/src/Avalonia.Controls/Window.cs b/src/Avalonia.Controls/Window.cs index 04b48d7f9f..cbb69fbeb7 100644 --- a/src/Avalonia.Controls/Window.cs +++ b/src/Avalonia.Controls/Window.cs @@ -92,8 +92,8 @@ namespace Avalonia.Controls /// /// Defines the property. /// - public static readonly StyledProperty ExtendClientAreaToDecorationsHintProperty = - AvaloniaProperty.Register(nameof(ExtendClientAreaToDecorationsHint), false); + public static readonly StyledProperty ExtendClientAreaToDecorationsHintProperty = + AvaloniaProperty.Register(nameof(ExtendClientAreaToDecorationsHint), default); /// @@ -109,7 +109,7 @@ namespace Avalonia.Controls /// public static readonly DirectProperty WindowDecorationMarginsProperty = AvaloniaProperty.RegisterDirect(nameof(WindowDecorationMargins), - o => o.WindowDecorationMargins); + o => o.WindowDecorationMargins); /// @@ -190,7 +190,7 @@ namespace Avalonia.Controls (w, e) => { if (w.PlatformImpl != null) w.PlatformImpl.WindowState = (WindowState)e.NewValue; }); ExtendClientAreaToDecorationsHintProperty.Changed.AddClassHandler( - (w, e) => { if (w.PlatformImpl != null) w.PlatformImpl.ExtendClientAreaToDecorationsHint = (bool)e.NewValue; }); + (w, e) => { if (w.PlatformImpl != null) w.PlatformImpl.ExtendClientAreaToDecorationsHint = (Thickness)e.NewValue; }); MinWidthProperty.Changed.AddClassHandler((w, e) => w.PlatformImpl?.SetMinMaxSize(new Size((double)e.NewValue, w.MinHeight), new Size(w.MaxWidth, w.MaxHeight))); MinHeightProperty.Changed.AddClassHandler((w, e) => w.PlatformImpl?.SetMinMaxSize(new Size(w.MinWidth, (double)e.NewValue), new Size(w.MaxWidth, w.MaxHeight))); @@ -269,7 +269,7 @@ namespace Avalonia.Controls /// /// Gets or sets if the ClientArea is Extended into the Window Decorations (chrome or border). /// - public bool ExtendClientAreaToDecorationsHint + public Thickness ExtendClientAreaToDecorationsHint { get { return GetValue(ExtendClientAreaToDecorationsHintProperty); } set { SetValue(ExtendClientAreaToDecorationsHintProperty, value); } diff --git a/src/Avalonia.DesignerSupport/Remote/PreviewerWindowImpl.cs b/src/Avalonia.DesignerSupport/Remote/PreviewerWindowImpl.cs index 441a79531a..26c3bed86d 100644 --- a/src/Avalonia.DesignerSupport/Remote/PreviewerWindowImpl.cs +++ b/src/Avalonia.DesignerSupport/Remote/PreviewerWindowImpl.cs @@ -85,7 +85,7 @@ namespace Avalonia.DesignerSupport.Remote public IScreenImpl Screen { get; } = new ScreenStub(); public Action GotInputWhenDisabled { get; set; } - public bool ExtendClientAreaToDecorationsHint { get; set; } + public Thickness ExtendClientAreaToDecorationsHint { get; set; } public Action ExtendClientAreaToDecorationsChanged { get; set; } diff --git a/src/Avalonia.DesignerSupport/Remote/Stubs.cs b/src/Avalonia.DesignerSupport/Remote/Stubs.cs index f962382575..605e0e45a8 100644 --- a/src/Avalonia.DesignerSupport/Remote/Stubs.cs +++ b/src/Avalonia.DesignerSupport/Remote/Stubs.cs @@ -39,7 +39,7 @@ namespace Avalonia.DesignerSupport.Remote public Action TransparencyLevelChanged { get; set; } - public bool ExtendClientAreaToDecorationsHint { get; set; } + public Thickness ExtendClientAreaToDecorationsHint { get; set; } public Action ExtendClientAreaToDecorationsChanged { get; set; } diff --git a/src/Avalonia.Native/WindowImpl.cs b/src/Avalonia.Native/WindowImpl.cs index 3495c4b392..2e81a66d1f 100644 --- a/src/Avalonia.Native/WindowImpl.cs +++ b/src/Avalonia.Native/WindowImpl.cs @@ -98,7 +98,7 @@ namespace Avalonia.Native public Action WindowStateChanged { get; set; } - public bool ExtendClientAreaToDecorationsHint { get; set; } + public Thickness ExtendClientAreaToDecorationsHint { get; set; } public Action ExtendClientAreaToDecorationsChanged { get; set; } diff --git a/src/Avalonia.X11/X11Window.cs b/src/Avalonia.X11/X11Window.cs index ac9048adad..4bff5b9b03 100644 --- a/src/Avalonia.X11/X11Window.cs +++ b/src/Avalonia.X11/X11Window.cs @@ -311,7 +311,7 @@ namespace Avalonia.X11 set => _transparencyHelper.TransparencyLevelChanged = value; } - public bool ExtendClientAreaToDecorationsHint { get; set; } + public Thickness ExtendClientAreaToDecorationsHint { get; set; } public Action ExtendClientAreaToDecorationsChanged { get; set; } diff --git a/src/Windows/Avalonia.Win32/WindowImpl.cs b/src/Windows/Avalonia.Win32/WindowImpl.cs index 7474bdd10a..fe8f175a5e 100644 --- a/src/Windows/Avalonia.Win32/WindowImpl.cs +++ b/src/Windows/Avalonia.Win32/WindowImpl.cs @@ -69,7 +69,7 @@ namespace Avalonia.Win32 private Size _maxSize; private POINT _maxTrackSize; private WindowImpl _parent; - private bool _extendClientAreaToDecorationsHint; + private Thickness _extendClientAreaToDecorationsHint; public WindowImpl() { @@ -666,7 +666,7 @@ namespace Avalonia.Win32 TaskBarList.MarkFullscreen(_hwnd, fullscreen); } - private void ExtendClientArea () + private void ExtendClientArea (Thickness thickness) { if (!_isClientAreaExtended) { @@ -690,10 +690,10 @@ namespace Avalonia.Win32 } // Extend the frame into the client area. - margins.cxLeftWidth = border_thickness.left; - margins.cxRightWidth = border_thickness.right; - margins.cyBottomHeight = border_thickness.bottom; - margins.cyTopHeight = border_thickness.top; + margins.cxLeftWidth = thickness.Left == -1 ? border_thickness.left : (int)(thickness.Left * Scaling); + margins.cxRightWidth = thickness.Right == -1 ? border_thickness.right : (int)(thickness.Right * Scaling); + margins.cyBottomHeight = thickness.Bottom == -1 ? border_thickness.bottom : (int)(thickness.Bottom * Scaling); + margins.cyTopHeight = thickness.Top == -1 ? border_thickness.top : (int)(thickness.Top * Scaling); var hr = DwmExtendFrameIntoClientArea(_hwnd, ref margins); @@ -948,15 +948,14 @@ namespace Avalonia.Win32 IntPtr EglGlPlatformSurface.IEglWindowGlPlatformSurfaceInfo.Handle => Handle.Handle; - public bool ExtendClientAreaToDecorationsHint + public Thickness ExtendClientAreaToDecorationsHint { get => _extendClientAreaToDecorationsHint; set { - _extendClientAreaToDecorationsHint = true; + _extendClientAreaToDecorationsHint = value; - ExtendClientArea(); - // TODO Trigger transition. + ExtendClientArea(value); } }