Skip to content

Commit 14db2d5

Browse files
committed
feature: supports to disable Mica effect on Windows 11 from theme overrides (#2191)
Add `UseMicaOnWindows11` to custom theme schema Signed-off-by: leo <longshuang@msn.cn>
1 parent 203dad3 commit 14db2d5

4 files changed

Lines changed: 11 additions & 1 deletion

File tree

src/App.axaml.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,8 @@ public static void SetTheme(string theme, string themeOverridesFile)
286286
else
287287
Models.CommitGraph.SetDefaultPens(overrides.GraphPenThickness);
288288

289+
Native.OS.UseMicaOnWindows11 = overrides.UseMicaOnWindows11;
290+
289291
app.Resources.MergedDictionaries.Add(resDic);
290292
app._themeOverrides = resDic;
291293
}

src/Models/ThemeOverrides.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ public class ThemeOverrides
99
public Dictionary<string, Color> BasicColors { get; set; } = new Dictionary<string, Color>();
1010
public double GraphPenThickness { get; set; } = 2;
1111
public double OpacityForNotMergedCommits { get; set; } = 0.5;
12+
public bool UseMicaOnWindows11 { get; set; } = true;
1213
public List<Color> GraphColors { get; set; } = new List<Color>();
1314
}
1415
}

src/Native/OS.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ public static string ExternalDiffArgs
107107
set;
108108
} = string.Empty;
109109

110+
public static bool UseMicaOnWindows11
111+
{
112+
get => OperatingSystem.IsWindows() && OperatingSystem.IsWindowsVersionAtLeast(10, 0, 22000) && _enableMicaOnWindows11;
113+
set => _enableMicaOnWindows11 = value;
114+
}
115+
110116
public static bool UseSystemWindowFrame
111117
{
112118
get => OperatingSystem.IsLinux() && _enableSystemWindowFrame;
@@ -294,5 +300,6 @@ private static void UpdateGitVersion()
294300
private static IBackend _backend = null;
295301
private static string _gitExecutable = string.Empty;
296302
private static bool _enableSystemWindowFrame = false;
303+
private static bool _enableMicaOnWindows11 = true;
297304
}
298305
}

src/Views/Launcher.axaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public Launcher()
6262
InitializeComponent();
6363
PositionChanged += OnPositionChanged;
6464

65-
if (OperatingSystem.IsWindows() && OperatingSystem.IsWindowsVersionAtLeast(10, 0, 22000))
65+
if (Native.OS.UseMicaOnWindows11)
6666
{
6767
Background = Brushes.Transparent;
6868
TransparencyLevelHint = [WindowTransparencyLevel.Mica];

0 commit comments

Comments
 (0)