Skip to content

Commit

Permalink
Fix High Contrast mode in Settings UI (#18130)
Browse files Browse the repository at this point in the history
"HighContrast" is not a possible requested theme. So `_UpdateBackgroundForMica()` would force the settings UI to be light or dark. To fix this, we just check if we're in high contrast mode and, if so, we don't bother setting the requested theme.

(cherry picked from commit d04381e)
Service-Card-Id: PVTI_lADOAF3p4s4AmhmszgUZ6MY
Service-Version: 1.21
  • Loading branch information
carlos-zamora authored and DHowett committed Nov 15, 2024
1 parent fa91fd6 commit ef89e13
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/cascadia/TerminalSettingsEditor/MainPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,12 @@ namespace winrt::Microsoft::Terminal::Settings::Editor::implementation
// can have mica too.
void MainPage::_UpdateBackgroundForMica()
{
// If we're in high contrast mode, don't override the theme.
if (Windows::UI::ViewManagement::AccessibilitySettings accessibilitySettings; accessibilitySettings.HighContrast())
{
return;
}

bool isMicaAvailable = false;

// Check to see if our hosting window supports Mica at all. We'll check
Expand Down
5 changes: 2 additions & 3 deletions src/cascadia/TerminalSettingsEditor/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,10 @@
<ResourceDictionary x:Key="HighContrast">
<!-- Define resources for HighContrast mode here -->
<StaticResource x:Key="SettingsPageBackground"
ResourceKey="SystemColorWindowColorBrush" />
ResourceKey="SystemColorWindowBrush" />
<StaticResource x:Key="SettingsPageMicaBackground"
ResourceKey="SystemColorWindowColorBrush" />
ResourceKey="SystemColorWindowBrush" />
</ResourceDictionary>

</ResourceDictionary.ThemeDictionaries>
</ResourceDictionary>

Expand Down
1 change: 1 addition & 0 deletions src/cascadia/TerminalSettingsEditor/pch.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <winrt/Windows.UI.Input.h>
#include <winrt/Windows.UI.Popups.h>
#include <winrt/Windows.UI.Text.h>
#include <winrt/Windows.UI.ViewManagement.h>
#include <winrt/Windows.UI.Xaml.h>
#include <winrt/Windows.UI.Xaml.Automation.h>
#include <winrt/Windows.UI.Xaml.Automation.Peers.h>
Expand Down

0 comments on commit ef89e13

Please sign in to comment.