From cc563d254f00cfc35dda3676dc1e95d95e1c4963 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Sat, 10 Oct 2020 14:15:30 -0400 Subject: [PATCH] Add MSW implementation for IsDarkTheme (for future) As noted, we can't enable this yet as wxWidgets does not automatically apply a dark theme to the system colors. --- libs/kiplatform/msw/ui.cpp | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/libs/kiplatform/msw/ui.cpp b/libs/kiplatform/msw/ui.cpp index 78a7a05115..1a180b55b3 100644 --- a/libs/kiplatform/msw/ui.cpp +++ b/libs/kiplatform/msw/ui.cpp @@ -23,12 +23,38 @@ #include #include #include +#include bool KIPLATFORM::UI::IsDarkTheme() { - // TODO(ISM): Write this function + // NOTE: Disabled for now because we can't yet react to dark mode in Windows reasonably: + // Windows 10 dark mode does not change the values returned by wxSystemSettings::GetColour() + // so our window backgrounds, text colors, etc will stay in "light mode" until either wxWidgets + // implements something or we apply a custom theme ourselves. +#ifdef NOTYET + const wxString lightModeKey = wxT( "AppsUseLightTheme" ); + + // Note: registry used because there is not yet an official API for this yet. + // This may stop working on future Windows versions + wxRegKey themeKey( wxRegKey::HKCU, + wxT( "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize" ) ); + + if( !themeKey.Exists() ) + return false; + + if( !themeKey.HasValue( lightModeKey ) ) + return false; + + long val = 0; + + if( !themeKey.QueryValue( lightModeKey, &val ) ) + return false; + + return ( val == 0 ); +#else return false; +#endif }