Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix non-legacy backdrop when switching themes and applying Mica or other effect #1094

Merged
merged 1 commit into from
Jun 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/Wpf.Ui/Appearance/WindowBackgroundManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,14 @@ WindowBackdropType backdrop
}

// This was required to update the background when moving from a HC theme to light/dark theme. However, this breaks theme proper light/dark theme changing on Windows 10.
// else
// {
// _ = WindowBackdrop.RemoveBackground(window);
// }
// But window backdrop effects are not applied when it has an opaque (or any) background on W11 (so removing this breaks backdrop effects when switching themes), however, for legacy MICA it may not be required
// using existing variable, though the OS build which (officially) supports setting DWM_SYSTEMBACKDROP_TYPE attribute is build 22621
// source: https://learn.microsoft.com/en-us/windows/win32/api/dwmapi/ne-dwmapi-dwm_systembackdrop_type
if (Win32.Utilities.IsOSWindows11Insider1OrNewer && backdrop is not WindowBackdropType.None)
{
_ = WindowBackdrop.RemoveBackground(window);
}

_ = WindowBackdrop.ApplyBackdrop(window, backdrop);
if (applicationTheme is ApplicationTheme.Dark)
{
Expand Down
Loading