Skip to content

Commit

Permalink
Don't update the settings, unless the theme actually changed (microso…
Browse files Browse the repository at this point in the history
…ft#16004)

`ImmersiveColorSet` gets sent more often than just on a theme change. It notably gets sent when the PC is locked, or the UAC prompt opens.

## Validation Steps Performed

Tested manually by setting the font to `garbo`and:
* locking, then logging back in. No dialog ✅ 
* UAC via run dialog + `regedit`. No dialog ✅ 
* Actually changing the OS theme. Dialog ✅  

Closes microsoft#15732
  • Loading branch information
zadjii-msft authored Sep 20, 2023
1 parent 75f3d4f commit c1bdcf8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/cascadia/WindowsTerminal/IslandWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ void IslandWindow::_HandleCreateWindow(const WPARAM, const LPARAM lParam) noexce
UpdateWindow(_window.get());

UpdateWindowIconForActiveMetrics(_window.get());

_currentSystemThemeIsDark = Theme::IsSystemInDarkTheme();
}

// Method Description:
Expand Down Expand Up @@ -745,7 +747,16 @@ long IslandWindow::_calculateTotalSize(const bool isWidth, const long clientSize
// themes, color schemes that might depend on the OS theme
if (param == L"ImmersiveColorSet")
{
_UpdateSettingsRequestedHandlers();
// GH#15732: Don't update the settings, unless the theme
// _actually_ changed. ImmersiveColorSet gets sent more often
// than just on a theme change. It notably gets sent when the PC
// is locked, or the UAC prompt opens.
auto isCurrentlyDark = Theme::IsSystemInDarkTheme();
if (isCurrentlyDark != _currentSystemThemeIsDark)
{
_currentSystemThemeIsDark = isCurrentlyDark;
_UpdateSettingsRequestedHandlers();
}
}
}
break;
Expand Down
1 change: 1 addition & 0 deletions src/cascadia/WindowsTerminal/IslandWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ class IslandWindow :
RECT _rcWindowBeforeFullscreen{};
RECT _rcWorkBeforeFullscreen{};
UINT _dpiBeforeFullscreen{ 96 };
bool _currentSystemThemeIsDark{ true };

void _coldInitialize();
void _warmInitialize();
Expand Down

0 comments on commit c1bdcf8

Please sign in to comment.