Skip to content

Commit

Permalink
Merge pull request AvaloniaUI#7787 from AvaloniaUI/fixes/mica-acrylic…
Browse files Browse the repository at this point in the history
…-fallback-win32

make mica fallback to acrylic on compatible windows 10
  • Loading branch information
danwalmsley committed Mar 11, 2022
1 parent e84a13f commit f0999fd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/Avalonia.Controls/WindowTransparencyLevel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ public enum WindowTransparencyLevel
/// </summary>
AcrylicBlur,

/// <summary>
/// Force acrylic on some incompatible versions of Windows 10.
/// </summary>
ForceAcrylicBlur,

/// <summary>
/// The window background is based on desktop wallpaper tint with a blur. This will only work on Windows 11
/// </summary>
Expand Down
8 changes: 7 additions & 1 deletion src/Windows/Avalonia.Win32/WindowImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,11 @@ private WindowTransparencyLevel Win10EnableBlur(WindowTransparencyLevel transpar
}
}

if (Win32Platform.WindowsVersion.Major == 10 && effect == BlurEffect.Mica)
{
effect = BlurEffect.Acrylic;
}

_blurHost?.SetBlur(effect);

return transparencyLevel;
Expand Down Expand Up @@ -426,7 +431,8 @@ private WindowTransparencyLevel Win10EnableBlur(WindowTransparencyLevel transpar
break;

case WindowTransparencyLevel.AcrylicBlur:
case (WindowTransparencyLevel.AcrylicBlur + 1): // hack-force acrylic.
case WindowTransparencyLevel.ForceAcrylicBlur: // hack-force acrylic.
case WindowTransparencyLevel.Mica:
accent.AccentState = AccentState.ACCENT_ENABLE_ACRYLIC;
transparencyLevel = WindowTransparencyLevel.AcrylicBlur;
break;
Expand Down

0 comments on commit f0999fd

Please sign in to comment.