mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
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.
This commit is contained in:
parent
84ed1fa1e1
commit
340f2cbc04
1 changed files with 6 additions and 11 deletions
|
|
@ -467,20 +467,17 @@ namespace Flow.Launcher.Core.Resource
|
||||||
if (string.IsNullOrEmpty(path))
|
if (string.IsNullOrEmpty(path))
|
||||||
throw new DirectoryNotFoundException($"Theme path can't be found <{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;
|
_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)
|
if (_oldTheme != theme || theme == Constant.DefaultTheme)
|
||||||
{
|
{
|
||||||
_oldTheme = Path.GetFileNameWithoutExtension(_oldResource.Source.AbsolutePath);
|
_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
|
// Apply blur and drop shadow effect so that we do not need to call it again
|
||||||
_ = RefreshFrameAsync();
|
_ = 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
|
if (!Win32Helper.IsBackdropSupported()) // Windows 11 미만이면 무조건 false
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var resource = Application.Current.TryFindResource("ThemeBlurEnabled");
|
return dict.Contains("ThemeBlurEnabled") && dict["ThemeBlurEnabled"] is bool enabled && enabled;
|
||||||
|
|
||||||
return resource is bool b && b;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue