Skip to content

Commit c71da54

Browse files
committed
Support for color scheme change
1 parent 15d979b commit c71da54

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

Flow.Launcher.Infrastructure/Win32Helper.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -801,16 +801,22 @@ public static unsafe void OpenFolderAndSelectFile(string filePath)
801801
[DllImport("uxtheme.dll", EntryPoint = "#135", SetLastError = true)]
802802
private static extern int SetPreferredAppMode(int appMode);
803803

804-
public static void EnableWin32DarkMode()
804+
public static void EnableWin32DarkMode(string colorScheme)
805805
{
806806
try
807807
{
808-
// From Windows 10 1809
809-
// AppMode: 0=Default, 1=AllowDark, 2=ForceDark, 3=ForceLight, 4=Max
808+
// Undocumented API from Windows 10 1809
810809
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) &&
811810
Environment.OSVersion.Version.Build >= 17763)
812811
{
813-
_ = SetPreferredAppMode(1);
812+
var flag = colorScheme switch
813+
{
814+
Constant.Light => 3, // ForceLight
815+
Constant.Dark => 2, // ForceDark
816+
Constant.System => 1, // AllowDark
817+
_ => 0 // Default
818+
};
819+
_ = SetPreferredAppMode(flag);
814820
}
815821

816822
}

Flow.Launcher/App.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ await API.StopwatchLogInfoAsync(ClassName, "Startup cost", async () =>
189189
Notification.Install();
190190

191191
// Enable Win32 dark mode if the system is in dark mode before creating all windows
192-
Win32Helper.EnableWin32DarkMode();
192+
Win32Helper.EnableWin32DarkMode(_settings.ColorScheme);
193193

194194
Ioc.Default.GetRequiredService<Portable>().PreStartCleanUpAfterPortabilityUpdate();
195195

Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ public string ColorScheme
136136
};
137137
Settings.ColorScheme = value;
138138
_ = _theme.RefreshFrameAsync();
139+
Win32Helper.EnableWin32DarkMode(value);
139140
}
140141
}
141142

0 commit comments

Comments
 (0)