Skip to content

fix: set WindowDrawnDecorations background to transparent#21354

Merged
MrJul merged 1 commit into
AvaloniaUI:masterfrom
ent3m:fix/window-decorations-transparency
May 14, 2026
Merged

fix: set WindowDrawnDecorations background to transparent#21354
MrJul merged 1 commit into
AvaloniaUI:masterfrom
ent3m:fix/window-decorations-transparency

Conversation

@ent3m

@ent3m ent3m commented May 13, 2026

Copy link
Copy Markdown
Contributor

What does the pull request do?

Fixes a regression where WindowDrawnDecorations used an opaque background, blocking transparency effects (Mica/Acrylic/Blur) when ExtendClientAreaToDecorationsHint is enabled.

What is the current behavior?

WindowDrawnDecorations renders a solid background, obscuring the window's transparency effects when ExtendClientAreaToDecorationsHint="True".

What is the updated/expected behavior with this PR?

WindowDrawnDecorations backgrounds are now transparent , allowing the window background to show through correctly.

Proof (ExtendClientArea = True):

Theme Before After
Fluent before-fluent-extend-true after-fluent-extend-true
Simple before-simple-extend-true after-simple-extend-true

How was the solution implemented?

  • Set WindowDrawnDecorationsContent.Underlay backgrounds to SystemControlTransparentBrush in Avalonia.Themes.Fluent/Controls/WindowDrawnDecorations.xaml.
  • Set WindowDrawnDecorationsContent.Underlay backgrounds to Transparent in Avalonia.Themes.Simple/Controls/WindowDrawnDecorations.xaml.
  • Verified that title bar hit-testing/dragging remains functional.

Checklist

Fixed issues

Fixes #21082

@MrJul MrJul added bug backport-candidate-12.0.x Consider this PR for backporting to 12.0 branch labels May 13, 2026
@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.1.999-cibuild0065345-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@cla-avalonia

cla-avalonia commented May 13, 2026

Copy link
Copy Markdown
Collaborator
  • All contributors have signed the CLA.

@ent3m

ent3m commented May 13, 2026

Copy link
Copy Markdown
Contributor Author

@cla-avalonia agree

@ent3m ent3m force-pushed the fix/window-decorations-transparency branch from f7e9f1d to cf20c4b Compare May 14, 2026 02:16
@avaloniaui-bot

Copy link
Copy Markdown

You can test this PR using the following package version. 12.1.999-cibuild0065371-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@MrJul MrJul left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes make sense, the window's background will always be on top of the underlay anyway.
LGTM!

@MrJul MrJul enabled auto-merge May 14, 2026 10:20
@MrJul MrJul added this pull request to the merge queue May 14, 2026
Merged via the queue into AvaloniaUI:master with commit 06810f7 May 14, 2026
11 checks passed
@kekekeks

Copy link
Copy Markdown
Member

Was this change actually tested?

This is what happens if you enable client area extension:

image

@ent3m

ent3m commented May 27, 2026

Copy link
Copy Markdown
Contributor Author

Looks good to me.
transparent
acrylic

@ent3m

ent3m commented May 27, 2026

Copy link
Copy Markdown
Contributor Author

Did you mean to say that the title bar shouldn't be transparent when TransparencyLevelHint is None?

@kekekeks

Copy link
Copy Markdown
Member
  1. Win32 isn't the only platform that uses drawn decorations
  2. Titlebar can be drawn when client area isn't extended (i. e. when it's NOT covered by Window.Background)

@kekekeks

Copy link
Copy Markdown
Member

Also, titlebar being transparent doesn't match what we have with macOS when client area is extended.

@kekekeks

Copy link
Copy Markdown
Member

We should probably have a flag to disable titlebar background uniformly across platforms in client area extension mode

MrJul pushed a commit to MrJul/Avalonia that referenced this pull request May 28, 2026
@MrJul MrJul added backported-12.0.x and removed backport-candidate-12.0.x Consider this PR for backporting to 12.0 branch labels May 28, 2026
@ent3m

ent3m commented Jun 1, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for clarifying. I understand the issue now. WindowDrawnDecorations is used when client area isn't extended due to platforms not supporting native title bars.

private bool UseManagedDecorations => _extendingClientAreaToDecorations || _platform.Options.ForceDrawnDecorationsInternal;

Instead of adding a new flag, how about we make the background brush conditional? We can make it transparent only when ExtendClientAreaToDecorationsHint=True and a transparency effect is active (WindowTransparencyLevel != None). This keeps the public API minimal, protects Linux CSD, and aligns with the macOS behavior when transparency is off. A simple implementation would be:

<Style Selector="^:has-transparency /template/ Border#PART_WindowBorder">
  <Setter Property="Background" Value="{DynamicResource SystemControlTransparentBrush}" />
</Style>

<Style Selector="^:has-transparency /template/ Panel#PART_TitleBar">
  <Setter Property="Background" Value="{DynamicResource SystemControlTransparentBrush}" />
</Style>

I'd be happy to submit another PR if that sounds agreeable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[v12] [Regression] ExtendClientAreaToDecorationsHint Breaks Transparency/Acrylic Blur/Mica Due To WindowDrawnDecorations

5 participants