From 2e6fb61248d1df56a3a97648b56102b1bb7066e1 Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sun, 1 Mar 2026 14:13:32 +0800 Subject: [PATCH] Refactor blur theme logic and helper function Renamed IsBlurTheme to IsThemeBlurEnabled and moved system backdrop support checks out of the helper function. Blur availability is now determined by combining theme settings and system capability in the calling code. Updated all usages to reflect the new logic for improved clarity. --- Flow.Launcher.Core/Resource/Theme.cs | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/Flow.Launcher.Core/Resource/Theme.cs b/Flow.Launcher.Core/Resource/Theme.cs index 1e891745d..ca30d6b5b 100644 --- a/Flow.Launcher.Core/Resource/Theme.cs +++ b/Flow.Launcher.Core/Resource/Theme.cs @@ -478,7 +478,7 @@ namespace Flow.Launcher.Core.Resource // Check if blur is enabled var dict = GetThemeResourceDictionary(theme); - BlurEnabled = IsBlurTheme(dict); + BlurEnabled = Win32Helper.IsBackdropSupported() && IsThemeBlurEnabled(dict); // Apply blur and drop shadow effect so that we do not need to call it again _ = RefreshFrameAsync(); @@ -773,7 +773,7 @@ namespace Flow.Launcher.Core.Resource if (mainWindow == null) return; // Check if the theme supports blur - bool hasBlur = dict.Contains("ThemeBlurEnabled") && dict["ThemeBlurEnabled"] is bool b && b; + var hasBlur = IsThemeBlurEnabled(dict); if (BlurEnabled && hasBlur && Win32Helper.IsBackdropSupported()) { // If the BackdropType is Mica or MicaAlt, set the windowborderstyle's background to transparent @@ -955,13 +955,13 @@ namespace Flow.Launcher.Core.Resource if (mainWindow == null) return; // Check if the theme supports blur - bool hasBlur = dict.Contains("ThemeBlurEnabled") && dict["ThemeBlurEnabled"] is bool b && b; + var hasBlur = IsThemeBlurEnabled(dict); // SystemBG value check (Auto, Light, Dark) - string systemBG = dict.Contains("SystemBG") ? dict["SystemBG"] as string : "Auto"; // 기본값 Auto + var systemBG = dict.Contains("SystemBG") ? dict["SystemBG"] as string : "Auto"; // 기본값 Auto // Check the user's ColorScheme setting - string colorScheme = _settings.ColorScheme; + var colorScheme = _settings.ColorScheme; // Check system dark mode setting (read AppsUseLightTheme value) int themeValue = (int)Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize", "AppsUseLightTheme", 1); @@ -1020,8 +1020,8 @@ namespace Flow.Launcher.Core.Resource Color selectedBG = useDarkMode ? DarkBG : LightBG; ApplyPreviewBackground(selectedBG); - bool isBlurAvailable = hasBlur && Win32Helper.IsBackdropSupported(); // Windows 11 미만이면 hasBlur를 강제 false - + // If Windows does not support backdrop, treat as blur unavailable + var isBlurAvailable = hasBlur && Win32Helper.IsBackdropSupported(); if (!isBlurAvailable) { mainWindow.Background = Brushes.Transparent; @@ -1040,11 +1040,8 @@ namespace Flow.Launcher.Core.Resource } } - private static bool IsBlurTheme(ResourceDictionary dict) + private static bool IsThemeBlurEnabled(ResourceDictionary dict) { - if (!Win32Helper.IsBackdropSupported()) // Windows 11 미만이면 무조건 false - return false; - return dict.Contains("ThemeBlurEnabled") && dict["ThemeBlurEnabled"] is bool enabled && enabled; }