Add msw.dark-mode system option to allow turning it on easily
It doesn't make much sense to set this option programmatically, as the application could just call MSWEnableDarkMode() directly instead, but it's useful to have to allow enabling dark mode for any wx application by just setting WX_MSW_DARK_MODE environment variable.
This commit is contained in:
parent
9ca577f6d0
commit
7fd236bf4a
3 changed files with 18 additions and 0 deletions
|
|
@ -1193,6 +1193,10 @@ public:
|
|||
functions to enable dark mode support for the desktop applications
|
||||
under Windows 10 20H1 or later (including all Windows 11 versions).
|
||||
|
||||
Note that dark mode can also be enabled by setting the "msw.dark-mode"
|
||||
@ref wxSystemOptions "system option" via an environment variable from
|
||||
outside the application.
|
||||
|
||||
@param flags Can include @c wxApp::DarkMode_Always to force enabling
|
||||
dark mode for the application, even if the system doesn't use the
|
||||
dark mode by default. Otherwise dark mode is only used if it is the
|
||||
|
|
|
|||
|
|
@ -76,6 +76,11 @@
|
|||
If set to 1, disables the use of composited, i.e. double-buffered,
|
||||
windows by default in wxMSW. This is not recommended, but can be useful
|
||||
for debugging or working around redraw problems in the existing code.
|
||||
@flag{msw.dark-mode}
|
||||
If set to 1, enable experimental support of dark mode if the system is
|
||||
using it, i.e. this has the same effect as calling
|
||||
wxApp::MSWEnableDarkMode(). If set to 2, use dark mode unconditionally,
|
||||
as if this function were called with wxApp::DarkMode_Always argument.
|
||||
@endFlagTable
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@
|
|||
#include "wx/thread.h"
|
||||
#include "wx/platinfo.h"
|
||||
#include "wx/scopeguard.h"
|
||||
#include "wx/sysopt.h"
|
||||
#include "wx/vector.h"
|
||||
#include "wx/weakref.h"
|
||||
|
||||
|
|
@ -631,6 +632,14 @@ bool wxApp::Initialize(int& argc_, wxChar **argv_)
|
|||
|
||||
wxSetKeyboardHook(true);
|
||||
|
||||
// this is useful to allow users to enable dark mode for the applications
|
||||
// not enabling it themselves by setting the corresponding environment
|
||||
// variable
|
||||
if ( const int darkMode = wxSystemOptions::GetOptionInt("msw.dark-mode") )
|
||||
{
|
||||
MSWEnableDarkMode(darkMode > 1 ? DarkMode_Always : DarkMode_Auto);
|
||||
}
|
||||
|
||||
callBaseCleanup.Dismiss();
|
||||
|
||||
return true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue