# HG changeset patch # User Chris Cannam # Date 1595336354 -3600 # Node ID e5d0ea9ac8f10c057dad0cb9ddd8fdea5db5d677 # Parent 5671836cdac79812092de25733d144126fc9526b OK I give in, we are going to have to put this in a separate DLL so we can deploy a version on Win7 that doesn't have the WinRT dependency diff -r 5671836cdac7 -r e5d0ea9ac8f1 files.pri --- a/files.pri Thu Jun 25 12:20:20 2020 +0100 +++ b/files.pri Tue Jul 21 13:59:14 2020 +0100 @@ -253,6 +253,7 @@ rdf/RDFTransformFactory.cpp \ system/Init.cpp \ system/System.cpp \ + system/os-other.cpp \ transform/CSVFeatureWriter.cpp \ transform/FeatureExtractionModelTransformer.cpp \ transform/FileFeatureWriter.cpp \ diff -r 5671836cdac7 -r e5d0ea9ac8f1 system/System.cpp --- a/system/System.cpp Thu Jun 25 12:20:20 2020 +0100 +++ b/system/System.cpp Tue Jul 21 13:59:14 2020 +0100 @@ -27,12 +27,6 @@ #include #endif -#ifndef AVOID_WINRT_DEPENDENCY -#ifdef _MSC_VER -#include -#endif -#endif - #ifdef __APPLE__ #include #include @@ -340,45 +334,6 @@ } } -bool -OSReportsDarkThemeActive() -{ -#ifndef AVOID_WINRT_DEPENDENCY -#ifdef _MSC_VER - using namespace winrt::Windows::UI::ViewManagement; - UISettings settings; - auto background = settings.GetColorValue(UIColorType::Background); - if (int(background.R) + int(background.G) + int(background.B) < 384) { - return true; - } -#endif -#endif - return false; -} - -bool -OSQueryAccentColour(int &r, int &g, int &b) -{ - SVCERR << "OSQueryAccentColour() called" << endl; -#ifndef AVOID_WINRT_DEPENDENCY -#ifdef _MSC_VER - using namespace winrt::Windows::UI::ViewManagement; - bool dark = OSReportsDarkThemeActive(); - UISettings settings; - auto accent = settings.GetColorValue - (dark ? UIColorType::AccentLight1 : UIColorType::Accent); - r = accent.R; - g = accent.G; - b = accent.B; - return true; -#endif -#endif - (void)r; - (void)g; - (void)b; - return false; -} - double mod(double x, double y) { return x - (y * floor(x / y)); } float modf(float x, float y) { return x - (y * floorf(x / y)); } diff -r 5671836cdac7 -r e5d0ea9ac8f1 system/System.h --- a/system/System.h Thu Jun 25 12:20:20 2020 +0100 +++ b/system/System.h Tue Jul 21 13:59:14 2020 +0100 @@ -163,6 +163,8 @@ // if unknown. (Hence signed return type) extern ssize_t GetDiscSpaceMBAvailable(const char *path); +extern "C" { + // Return true if the OS desktop is set to use a dark mode // theme. Return false if it is set to a light theme or if the theme // is unknown. @@ -172,7 +174,9 @@ // the current theme; if so, also return by reference the r, g, and b // components of the colour (range 0-255). Return false if we can't // query such a thing. -extern bool OSQueryAccentColour(int &r, int &g, int &b); +extern bool OSQueryAccentColour(int *r, int *g, int *b); + +} extern void StoreStartupLocale(); extern void RestoreStartupLocale(); diff -r 5671836cdac7 -r e5d0ea9ac8f1 system/os-other.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/system/os-other.cpp Tue Jul 21 13:59:14 2020 +0100 @@ -0,0 +1,19 @@ + +extern "C" { + +bool +OSReportsDarkThemeActive() +{ + return false; +} + +bool +OSQueryAccentColour(int &r, int &g, int &b) +{ + (void)r; + (void)g; + (void)b; + return false; +} + +} diff -r 5671836cdac7 -r e5d0ea9ac8f1 system/os-win10.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/system/os-win10.cpp Tue Jul 21 13:59:14 2020 +0100 @@ -0,0 +1,49 @@ + +#ifndef AVOID_WINRT_DEPENDENCY +#ifdef _MSC_VER +#include +#endif +#endif + +extern "C" { + +bool +OSReportsDarkThemeActive() +{ +#ifndef AVOID_WINRT_DEPENDENCY +#ifdef _MSC_VER + using namespace winrt::Windows::UI::ViewManagement; + UISettings settings; + auto background = settings.GetColorValue(UIColorType::Background); + if (int(background.R) + int(background.G) + int(background.B) < 384) { + return true; + } +#endif +#endif + return false; +} + +bool +OSQueryAccentColour(int *r, int *g, int *b) +{ +#ifndef AVOID_WINRT_DEPENDENCY +#ifdef _MSC_VER + using namespace winrt::Windows::UI::ViewManagement; + bool dark = OSReportsDarkThemeActive(); + UISettings settings; + auto accent = settings.GetColorValue + (dark ? UIColorType::AccentLight1 : UIColorType::Accent); + *r = accent.R; + *g = accent.G; + *b = accent.B; + return true; +#endif +#endif + (void)r; + (void)g; + (void)b; + return false; +} + +} +