Skip to content

Commit 0086a9e

Browse files
committed
Add a condition to disable blur on unsupported Windows versions.
1 parent ce55303 commit 0086a9e

File tree

2 files changed

+33
-15
lines changed

2 files changed

+33
-15
lines changed

Flow.Launcher.Core/Resource/Theme.cs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ public static int SetWindowAttribute(IntPtr hwnd, ParameterTypes.DWMWINDOWATTRIB
125125
=> DwmSetWindowAttribute(hwnd, attribute, ref parameter, Marshal.SizeOf<int>());
126126
}
127127

128+
private bool IsBackdropSupported()
129+
{
130+
// Windows 11 (22000) over mica and arcrylic.
131+
return RuntimeInformation.IsOSPlatform(OSPlatform.Windows) &&
132+
Environment.OSVersion.Version.Build >= 22000;
133+
}
128134
private System.Windows.Window GetMainWindow()
129135
{
130136
return Application.Current.Dispatcher.Invoke(() => Application.Current.MainWindow);
@@ -172,7 +178,7 @@ public void AutoDropShadow()
172178
RemoveDropShadowEffectFromCurrentTheme();
173179
if (_settings.UseDropShadowEffect)
174180
{
175-
if (BlurEnabled)
181+
if (BlurEnabled && IsBackdropSupported())
176182
{
177183
SetWindowCornerPreference("Round");
178184
}
@@ -184,7 +190,7 @@ public void AutoDropShadow()
184190
}
185191
else
186192
{
187-
if (BlurEnabled)
193+
if (BlurEnabled && IsBackdropSupported())
188194
{
189195
SetWindowCornerPreference("Default");
190196
}
@@ -251,7 +257,7 @@ public void SetBlurForWindow()
251257
_ => 0 // None
252258
};
253259

254-
if (BlurEnabled && hasBlur)
260+
if (BlurEnabled && hasBlur && IsBackdropSupported())
255261
{
256262
// If the BackdropType is Mica or MicaAlt, set the windowborderstyle's background to transparent
257263
if (_settings.BackdropType == BackdropTypes.Mica || _settings.BackdropType == BackdropTypes.MicaAlt)
@@ -446,7 +452,9 @@ public void ColorizeWindow(string Mode)
446452
Color selectedBG = useDarkMode ? DarkBG : LightBG;
447453
ApplyPreviewBackground(selectedBG);
448454

449-
if (!hasBlur)
455+
bool isBlurAvailable = hasBlur && IsBackdropSupported(); // Windows 11 미만이면 hasBlur를 강제 false
456+
457+
if (!isBlurAvailable)
450458
{
451459
mainWindow.Background = Brushes.Transparent;
452460
}
@@ -469,17 +477,12 @@ public void ColorizeWindow(string Mode)
469477

470478
public bool IsBlurTheme()
471479
{
472-
if (Environment.OSVersion.Version >= new Version(6, 2))
473-
{
474-
var resource = Application.Current.TryFindResource("ThemeBlurEnabled");
475-
476-
if (resource is bool)
477-
return (bool)resource;
478-
480+
if (!IsBackdropSupported()) // Windows 11 미만이면 무조건 false
479481
return false;
480-
}
481482

482-
return false;
483+
var resource = Application.Current.TryFindResource("ThemeBlurEnabled");
484+
485+
return resource is bool b && b;
483486
}
484487
public string GetSystemBG()
485488
{
@@ -536,7 +539,7 @@ public bool ChangeTheme(string theme)
536539
_oldTheme = Path.GetFileNameWithoutExtension(_oldResource.Source.AbsolutePath);
537540
}
538541

539-
BlurEnabled = Win32Helper.IsBlurTheme();
542+
BlurEnabled = IsBlurTheme();
540543
//if (_settings.UseDropShadowEffect)
541544
// AddDropShadowEffectToCurrentTheme();
542545

Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
using ModernWpf;
1616
using ThemeManager = Flow.Launcher.Core.Resource.ThemeManager;
1717
using ThemeManagerForColorSchemeSwitch = ModernWpf.ThemeManager;
18+
using System.Runtime.InteropServices;
1819

1920
namespace Flow.Launcher.SettingPages.ViewModels;
2021

@@ -56,7 +57,21 @@ public Theme.ThemeData SelectedTheme
5657
ThemeManager.Instance.RefreshFrame();
5758
}
5859
}
59-
public bool IsBackdropEnabled => SelectedTheme?.HasBlur ?? false;
60+
public bool IsBackdropEnabled
61+
{
62+
get
63+
{
64+
if (!IsBackdropSupported()) return false;
65+
return SelectedTheme?.HasBlur ?? false;
66+
}
67+
}
68+
69+
private bool IsBackdropSupported()
70+
{
71+
// Windows 11 (22000) 이상에서만 Mica 및 Acrylic 효과 지원
72+
return RuntimeInformation.IsOSPlatform(OSPlatform.Windows) &&
73+
Environment.OSVersion.Version.Build >= 22000;
74+
}
6075
public bool IsDropShadowEnabled => !ThemeManager.Instance.BlurEnabled;
6176

6277
public bool DropShadowEffect

0 commit comments

Comments
 (0)