Преглед изворни кода

Merge pull request #7787 from AvaloniaUI/fixes/mica-acrylic-fallback-win32

make mica fallback to acrylic on compatible windows 10
Dan Walmsley пре 3 година
родитељ
комит
c47e88ffe7

+ 5 - 0
src/Avalonia.Controls/WindowTransparencyLevel.cs

@@ -22,6 +22,11 @@
         /// </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>

+ 7 - 1
src/Windows/Avalonia.Win32/WindowImpl.cs

@@ -396,6 +396,11 @@ namespace Avalonia.Win32
                     }
                 }
 
+                if (Win32Platform.WindowsVersion.Major == 10 && effect == BlurEffect.Mica)
+                {
+                    effect = BlurEffect.Acrylic;
+                }
+
                 _blurHost?.SetBlur(effect);
 
                 return transparencyLevel;
@@ -428,7 +433,8 @@ namespace Avalonia.Win32
                         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;