Don't return true from wxSystemAppearance::IsDark() in light mode

Even if the system is configured to use the dark mode, we shouldn't
return true from this function unless the application itself uses dark
mode, otherwise we're going to use wrong colours not providing enough
contrast with the system-provided ones.

This basically reverts #22020 as now that we have real dark mode
support, we should be using it instead.
This commit is contained in:
Vadim Zeitlin
2022-12-25 19:45:53 +00:00
parent dfe25222ed
commit 32daebe883
2 changed files with 8 additions and 17 deletions
+5
View File
@@ -286,6 +286,11 @@ public:
This method should be used to check whether custom colours more
appropriate for the default (light) or dark appearance should be used.
Note that this checks the appearance of the current application and not
the other applications on the system, so under MSW, for example, it
will return @false even if dark mode is used system-wide unless the
application opted in using dark mode using wxApp::MSWEnableDarkMode().
*/
bool IsDark() const;
+3 -17
View File
@@ -33,7 +33,6 @@
#include "wx/msw/missing.h" // for SM_CXCURSOR, SM_CYCURSOR, SM_TABLETPC
#include "wx/msw/private/darkmode.h"
#include "wx/msw/private/metrics.h"
#include "wx/msw/registry.h"
#include "wx/fontutil.h"
#include "wx/fontenum.h"
@@ -370,14 +369,6 @@ extern wxFont wxGetCCDefaultFont()
#endif // wxUSE_LISTCTRL || wxUSE_TREECTRL
// There is no official API for determining whether dark mode is being used,
// but // HKCU\Software\Microsoft\Windows\CurrentVersion\Themes\Personalize has
// a value AppsUseLightTheme = 0 for dark mode and 1 for normal mode, so use it
// and fall back to the generic algorithm in IsUsingDarkBackground() if it's
// absent.
//
// Adapted from https://stackoverflow.com/a/51336913/15275 ("How to detect
// Windows 10 light/dark mode in Win32 application?").
bool wxSystemAppearance::IsDark() const
{
// If the application opted in using dark mode, use the undocumented API
@@ -385,13 +376,8 @@ bool wxSystemAppearance::IsDark() const
if ( wxMSWDarkMode::IsActive() )
return true;
wxRegKey rk(wxRegKey::HKCU, "Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize");
if ( rk.Exists() && rk.HasValue("AppsUseLightTheme") )
{
long value = -1;
if ( rk.QueryValue("AppsUseLightTheme", &value) )
return value <= 0;
}
// Note that we should _not_ check if the system is configured to use the
// dark mode for the other applications here, what matters is whether this
// application itself uses dark colour schema or not.
return IsUsingDarkBackground();
}