From 340f2cbc04b859b40fb6d93baf6da01336b901da Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Sun, 1 Mar 2026 12:19:26 +0800 Subject: [PATCH] Refactor blur theme detection for accuracy Improve IsBlurTheme to check blur support directly in the current theme's resource dictionary, ensuring precise and context-specific detection. Updated related logic and comments for clarity. --- Flow.Launcher.Core/Resource/Theme.cs | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/Flow.Launcher.Core/Resource/Theme.cs b/Flow.Launcher.Core/Resource/Theme.cs index be849228a..1b6b016bd 100644 --- a/Flow.Launcher.Core/Resource/Theme.cs +++ b/Flow.Launcher.Core/Resource/Theme.cs @@ -467,20 +467,17 @@ namespace Flow.Launcher.Core.Resource if (string.IsNullOrEmpty(path)) throw new DirectoryNotFoundException($"Theme path can't be found <{path}>"); - // Retrieve theme resource – always use the resource with font settings applied. - var resourceDict = GetResourceDictionary(theme); - - UpdateResourceDictionary(resourceDict); - _settings.Theme = theme; - //always allow re-loading default theme, in case of failure of switching to a new theme from default theme + // Always allow re-loading default theme, in case of failure of switching to a new theme from default theme if (_oldTheme != theme || theme == Constant.DefaultTheme) { _oldTheme = Path.GetFileNameWithoutExtension(_oldResource.Source.AbsolutePath); } - BlurEnabled = IsBlurTheme(); + // Check if blur is enabled + var dict = GetThemeResourceDictionary(theme); + BlurEnabled = IsBlurTheme(dict); // Apply blur and drop shadow effect so that we do not need to call it again _ = RefreshFrameAsync(); @@ -991,14 +988,12 @@ namespace Flow.Launcher.Core.Resource } } - private static bool IsBlurTheme() + private static bool IsBlurTheme(ResourceDictionary dict) { if (!Win32Helper.IsBackdropSupported()) // Windows 11 미만이면 무조건 false return false; - var resource = Application.Current.TryFindResource("ThemeBlurEnabled"); - - return resource is bool b && b; + return dict.Contains("ThemeBlurEnabled") && dict["ThemeBlurEnabled"] is bool enabled && enabled; } #endregion