From b44cf368a200b33b5a99beae6a02800865d6f910 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Mon, 18 May 2026 19:07:22 +0500 Subject: [PATCH] Pass shadow extents to the platform (#21385) --- src/Avalonia.Controls/Platform/IWindowImpl.cs | 8 ++++++++ src/Avalonia.Controls/Window.cs | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/src/Avalonia.Controls/Platform/IWindowImpl.cs b/src/Avalonia.Controls/Platform/IWindowImpl.cs index d864ca35c3..888748fd89 100644 --- a/src/Avalonia.Controls/Platform/IWindowImpl.cs +++ b/src/Avalonia.Controls/Platform/IWindowImpl.cs @@ -172,5 +172,13 @@ namespace Avalonia.Platform /// Gets or sets a callback invoked when changes. /// Action? AllowedWindowActionsChanged { get => null; set { } } + + /// + /// Informs the platform about the thickness of application-drawn shadow decorations + /// so that the platform can distinguish the window content area from shadows. + /// It's platform's responsibility to synchronize this with window resize and rendering of the next frame + /// + /// The shadow thickness on each side, in DIPs. + void SetShadowExtents(Thickness extents) { } } } diff --git a/src/Avalonia.Controls/Window.cs b/src/Avalonia.Controls/Window.cs index 37b75b1b27..217147094f 100644 --- a/src/Avalonia.Controls/Window.cs +++ b/src/Avalonia.Controls/Window.cs @@ -805,6 +805,7 @@ namespace Avalonia.Controls // Only use platform margins if drawn decorations are not active WindowDecorationMargin = PlatformImpl?.ExtendedMargins ?? default; TopLevelHost.DecorationInset = default; + PlatformImpl?.SetShadowExtents(default); return; } @@ -815,6 +816,9 @@ namespace Avalonia.Controls ? decorations.FrameThickness : default; var shadow = parts.HasFlag(Chrome.DrawnWindowDecorationParts.Shadow) ? decorations.ShadowThickness : default; + + PlatformImpl?.SetShadowExtents(shadow); + var margin = new Thickness( frame.Left + shadow.Left, titleBarHeight + frame.Top + shadow.Top,