Enable dark mode on windows when built with wx 3.3

This commit is contained in:
Mark Roszko 2025-06-14 13:55:02 -04:00
parent 1922cab5f4
commit b83f433506
2 changed files with 8 additions and 24 deletions

View File

@ -20,6 +20,7 @@
#include <kiplatform/app.h>
#include <wx/app.h>
#include <wx/log.h>
#include <wx/string.h>
#include <wx/window.h>
@ -99,6 +100,10 @@ bool KIPLATFORM::APP::Init()
wxLog::SetActiveTarget( new wxLogStderr );
}
#if wxCHECK_VERSION( 3, 3, 0 )
wxTheApp->MSWEnableDarkMode();
#endif
return true;
}

View File

@ -30,30 +30,9 @@
bool KIPLATFORM::UI::IsDarkTheme()
{
// 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 );
#if wxCHECK_VERSION( 3, 3, 0 )
wxSystemAppearance appearance = wxSystemSettings::GetAppearance();
return appearance.IsDark();
#else
wxColour bg = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW );