Skip to content

Commit c63bb21

Browse files
committed
Added Windows 10 check code
1 parent b8748d6 commit c63bb21

File tree

1 file changed

+30
-20
lines changed

1 file changed

+30
-20
lines changed

Flow.Launcher.Core/Resource/Theme.cs

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,12 @@ public void RefreshFrame()
140140
if (mainWindowSrc == null)
141141
return;
142142

143+
// Check Windows version and disable BlurEnabled if Mica is not supported
144+
bool isWindows11OrHigher = Environment.OSVersion.Version.Build >= 22000;
145+
if (!isWindows11OrHigher)
146+
{
147+
BlurEnabled = false;
148+
}
143149

144150
ParameterTypes.MARGINS margins = new ParameterTypes.MARGINS();
145151
margins.cxLeftWidth = -1;
@@ -149,10 +155,10 @@ public void RefreshFrame()
149155
Methods.ExtendFrame(mainWindowSrc.Handle, margins);
150156

151157
// Remove OS minimizing/maximizing animation
152-
//Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_TRANSITIONS_FORCEDISABLED, 3);
158+
// Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_TRANSITIONS_FORCEDISABLED, 3);
153159

154-
//Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_BORDER_COLOR, 0x00FF0000);
155-
//Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_SYSTEMBACKDROP_TYPE, 3);
160+
// Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_BORDER_COLOR, 0x00FF0000);
161+
// Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_SYSTEMBACKDROP_TYPE, 3);
156162

157163
// The timing of adding the shadow effect should vary depending on whether the theme is transparent.
158164
if (BlurEnabled)
@@ -165,9 +171,9 @@ public void RefreshFrame()
165171
{
166172
AutoDropShadow();
167173
}
168-
169174
}
170175

176+
171177
public void AutoDropShadow()
172178
{
173179
if (_settings.UseDropShadowEffect)
@@ -241,42 +247,46 @@ public void SetCornerForWindow()
241247
/// </summary>
242248
public void SetBlurForWindow()
243249
{
244-
245-
//SetWindowAccent();
250+
// Check Windows version (Windows 11 or higher)
251+
bool isWindows11OrHigher = Environment.OSVersion.Version.Build >= 22000;
252+
253+
// If Mica is not supported, force disable BlurEnabled
254+
if (!isWindows11OrHigher)
255+
{
256+
BlurEnabled = false;
257+
}
258+
246259
var dict = GetThemeResourceDictionary(_settings.Theme);
247260
if (dict == null)
248-
return;
261+
return;
249262

250263
var windowBorderStyle = dict["WindowBorderStyle"] as Style;
251264
if (windowBorderStyle == null)
252265
return;
253-
254-
//Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_SYSTEMBACKDROP_TYPE, 3);
266+
267+
// Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_SYSTEMBACKDROP_TYPE, 3);
255268
if (BlurEnabled)
256269
{
257-
//mainWindow.WindowStyle = WindowStyle.SingleBorderWindow;
258-
//BlurColor(BlurMode());
270+
// mainWindow.WindowStyle = WindowStyle.SingleBorderWindow;
271+
// BlurColor(BlurMode());
259272
Debug.WriteLine("~~~~~~~~~~~~~~~~~~~~");
260273
Debug.WriteLine(BlurMode());
261274
Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_SYSTEMBACKDROP_TYPE, 3);
262275
windowBorderStyle.Setters.Remove(windowBorderStyle.Setters.OfType<Setter>().FirstOrDefault(x => x.Property.Name == "Background"));
263276
windowBorderStyle.Setters.Add(new Setter(Border.BackgroundProperty, new SolidColorBrush(Colors.Transparent)));
264-
//SetWindowCornerPreference("Round");
277+
// SetWindowCornerPreference("Round");
265278
}
266279
else
267280
{
268-
//mainWindow.WindowStyle = WindowStyle.None;
269-
//if (windowBorderStyle.Setters.OfType<Setter>().FirstOrDefault(x => x.Property.Name == "Background") != null)
270-
//{
271-
// windowBorderStyle.Setters.Add(windowBorderStyle.Setters.OfType<Setter>().FirstOrDefault(x => x.Property.Name == "Background"));
272-
//}
281+
// mainWindow.WindowStyle = WindowStyle.None;
282+
// if (windowBorderStyle.Setters.OfType<Setter>().FirstOrDefault(x => x.Property.Name == "Background") != null)
283+
// {
284+
// windowBorderStyle.Setters.Add(windowBorderStyle.Setters.OfType<Setter>().FirstOrDefault(x => x.Property.Name == "Background"));
285+
// }
273286
Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_SYSTEMBACKDROP_TYPE, 1);
274287
}
275288
ThemeModeColor(BlurMode());
276289
UpdateResourceDictionary(dict);
277-
278-
279-
280290
}
281291

282292
// Get Background Color from WindowBorderStyle when there not color for BG.

0 commit comments

Comments
 (0)