From bb5b118ebe5a58c61d0d972b22f3184ccf70a01c Mon Sep 17 00:00:00 2001 From: Greg Depoire--Ferrer Date: Sun, 21 Jun 2020 23:04:10 +0200 Subject: [PATCH] Always use the dark window borders The `TerminalTrySetDarkTheme` function is a hack to make the window borders dark. We do this to make the Windows Terminal look like other UWP apps. If we do not do this, then the borders stay light, like other Win32 apps that customize their title bar such as `explorer.exe` and `regedit.exe`. Previously, we only did it when the theme set was the dark theme. Now, we always do it: the window border is always dark, like other UWP apps. --- .../WindowsTerminal/NonClientIslandWindow.cpp | 35 +++---------------- .../WindowsTerminal/NonClientIslandWindow.h | 1 - 2 files changed, 5 insertions(+), 31 deletions(-) diff --git a/src/cascadia/WindowsTerminal/NonClientIslandWindow.cpp b/src/cascadia/WindowsTerminal/NonClientIslandWindow.cpp index 1d4546c4fd7..3994fdcebde 100644 --- a/src/cascadia/WindowsTerminal/NonClientIslandWindow.cpp +++ b/src/cascadia/WindowsTerminal/NonClientIslandWindow.cpp @@ -788,39 +788,15 @@ void NonClientIslandWindow::_UpdateFrameMargins() const noexcept return ret; } - // Set the frame's theme before it is rendered (WM_NCPAINT) so that it is - // rendered with the correct theme. - _UpdateFrameTheme(); + // This is a hack to make the window borders dark instead of light. + // It must be done before WM_NCPAINT so that the borders are rendered with + // the correct theme. + // For more information, see GH#6620. + LOG_IF_FAILED(TerminalTrySetDarkTheme(_window.get(), true)); return TRUE; } -// Method Description: -// - Updates the window frame's theme depending on the application theme (light -// or dark). This doesn't invalidate the old frame so it will not be -// rerendered until the user resizes or focuses/unfocuses the window. -// Return Value: -// - -void NonClientIslandWindow::_UpdateFrameTheme() const -{ - bool isDarkMode; - - switch (_theme) - { - case ElementTheme::Light: - isDarkMode = false; - break; - case ElementTheme::Dark: - isDarkMode = true; - break; - default: - isDarkMode = Application::Current().RequestedTheme() == ApplicationTheme::Dark; - break; - } - - LOG_IF_FAILED(TerminalTrySetDarkTheme(_window.get(), isDarkMode)); -} - // Method Description: // - Called when the app wants to change its theme. We'll update the frame // theme to match the new theme. @@ -833,7 +809,6 @@ void NonClientIslandWindow::OnApplicationThemeChanged(const ElementTheme& reques IslandWindow::OnApplicationThemeChanged(requestedTheme); _theme = requestedTheme; - _UpdateFrameTheme(); } // Method Description: diff --git a/src/cascadia/WindowsTerminal/NonClientIslandWindow.h b/src/cascadia/WindowsTerminal/NonClientIslandWindow.h index 2aea43adaff..792ba6272c9 100644 --- a/src/cascadia/WindowsTerminal/NonClientIslandWindow.h +++ b/src/cascadia/WindowsTerminal/NonClientIslandWindow.h @@ -85,7 +85,6 @@ class NonClientIslandWindow : public IslandWindow void _UpdateFrameMargins() const noexcept; void _UpdateMaximizedState(); void _UpdateIslandPosition(const UINT windowWidth, const UINT windowHeight); - void _UpdateFrameTheme() const; void _OpenSystemMenu(const int mouseX, const int mouseY) const noexcept; };