diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 130871976..64977b242 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -1,7 +1,8 @@
0.99.4
-* added `PortAudio` output driver
-* added support for Haiku OS
+* added `dark mode` awareness to Windows build.
+* added `PortAudio` output driver.
+* added support for Haiku OS.
--------------------------------------------------------------------------------
diff --git a/src/musikcore/version.h b/src/musikcore/version.h
index 6d599123f..9e60122fc 100644
--- a/src/musikcore/version.h
+++ b/src/musikcore/version.h
@@ -39,7 +39,7 @@
#define VERSION_MAJOR 0
#define VERSION_MINOR 99
#define VERSION_PATCH 4
-#define VERSION_COMMIT_HASH "#4c812339"
+#define VERSION_COMMIT_HASH "#0abdac4f"
#define VERSION "0.99.4"
namespace musik {
diff --git a/src/musikcube/cursespp/App.cpp b/src/musikcube/cursespp/App.cpp
index f83b22177..93363f0ac 100755
--- a/src/musikcube/cursespp/App.cpp
+++ b/src/musikcube/cursespp/App.cpp
@@ -308,6 +308,7 @@ void App::InitCurses() {
PDC_set_default_menu_visibility(0);
PDC_set_window_resized_callback(&pdcWinguiResizeCallback);
PDC_set_title(this->appTitle.c_str());
+ win32::ConfigureThemeAwareness();
win32::InterceptWndProc();
win32::SetAppTitle(this->appTitle);
if (this->iconId) {
diff --git a/src/musikcube/cursespp/Win32Util.cpp b/src/musikcube/cursespp/Win32Util.cpp
index d58181196..bf497e953 100644
--- a/src/musikcube/cursespp/Win32Util.cpp
+++ b/src/musikcube/cursespp/Win32Util.cpp
@@ -40,6 +40,8 @@
#ifdef WIN32
+using namespace winrt::Windows::UI::ViewManagement;
+
#define WM_TRAYICON (WM_USER + 2000)
#define WM_SHOW_OTHER_INSTANCE (WM_USER + 2001)
@@ -175,6 +177,12 @@ static LRESULT CALLBACK wndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpara
resetMutex();
}
+ if (msg == WM_SETTINGCHANGE) {
+ if (lparam && !lstrcmp(LPCTSTR(lparam), L"ImmersiveColorSet")) {
+ cursespp::win32::ConfigureThemeAwareness();
+ }
+ }
+
return DefSubclassProc(hwnd, msg, wparam, lparam);
}
@@ -273,6 +281,27 @@ namespace cursespp {
}
}
+ void ConfigureThemeAwareness() {
+ typedef HRESULT(__stdcall* DwmSetWindowAttributeProc)(HWND, DWORD, LPCVOID, DWORD);
+ static const DWORD DWMWA_USE_IMMERSIVE_DARK_MODE = 20;
+
+ HMODULE dwmapiDll = LoadLibrary(L"dwmapi.dll");
+ if (dwmapiDll) {
+ DwmSetWindowAttributeProc dwmSetWindowAttribute =
+ (DwmSetWindowAttributeProc) GetProcAddress(dwmapiDll, "DwmSetWindowAttribute");
+
+ if (dwmSetWindowAttribute) {
+ const auto settings = UISettings();
+ const auto foreground = settings.GetColorValue(UIColorType::Foreground);
+ BOOL isDarkMode = (((5 * foreground.G) + (2 * foreground.R) + foreground.B) > (8 * 128));
+ HWND mainHwnd = GetMainWindow();
+ dwmSetWindowAttribute(mainHwnd, DWMWA_USE_IMMERSIVE_DARK_MODE, &isDarkMode, sizeof(isDarkMode));
+ }
+
+ FreeLibrary(dwmapiDll);
+ }
+ }
+
int RegisterFont(const std::string& filename) {
return AddFontResourceEx(u8to16(filename).c_str(), FR_PRIVATE, 0);
}
diff --git a/src/musikcube/cursespp/cursespp/Win32Util.h b/src/musikcube/cursespp/cursespp/Win32Util.h
index 77c0f4dbc..b93b156a7 100644
--- a/src/musikcube/cursespp/cursespp/Win32Util.h
+++ b/src/musikcube/cursespp/cursespp/Win32Util.h
@@ -53,6 +53,7 @@ namespace cursespp {
bool AlreadyRunning();
void ShowOtherInstance(const std::string& title);
void ConfigureDpiAwareness();
+ void ConfigureThemeAwareness();
int RegisterFont(const std::string& filename);
int UnregisterFont(const std::string& filename);
}
diff --git a/src/musikcube/musikcube.vcxproj b/src/musikcube/musikcube.vcxproj
index 70071bd72..2f8edfc15 100755
--- a/src/musikcube/musikcube.vcxproj
+++ b/src/musikcube/musikcube.vcxproj
@@ -304,7 +304,7 @@
MachineX86
- pdh.lib;psapi.lib;Ws2_32.lib;wldap32.lib;Comctl32.lib;Winmm.lib;libcurl.lib;libssl-1_1.lib;libcrypto-1_1.lib;%(AdditionalDependencies)
+ Dwmapi.lib;pdh.lib;psapi.lib;Ws2_32.lib;wldap32.lib;Comctl32.lib;Winmm.lib;libcurl.lib;libssl-1_1.lib;libcrypto-1_1.lib;%(AdditionalDependencies)
false
@@ -351,7 +351,7 @@ xcopy "$(SolutionDir)src\3rdparty\bin\win\font\*.ttf" "$(TargetDir)fonts\" /Y /e
MachineX86
- pdh.lib;psapi.lib;Ws2_32.lib;wldap32.lib;Comctl32.lib;Winmm.lib;libcurl.lib;libssl-1_1.lib;libcrypto-1_1.lib;%(AdditionalDependencies)
+ Dwmapi.lib;pdh.lib;psapi.lib;Ws2_32.lib;wldap32.lib;Comctl32.lib;Winmm.lib;libcurl.lib;libssl-1_1.lib;libcrypto-1_1.lib;%(AdditionalDependencies)
false
@@ -398,7 +398,7 @@ xcopy "$(SolutionDir)src\3rdparty\bin\win\font\*.ttf" "$(TargetDir)fonts\" /Y /e
MachineX86
- pdh.lib;psapi.lib;Ws2_32.lib;wldap32.lib;Comctl32.lib;Winmm.lib;libcurl.lib;libssl-1_1.lib;libcrypto-1_1.lib;%(AdditionalDependencies)
+ Dwmapi.lib;pdh.lib;psapi.lib;Ws2_32.lib;wldap32.lib;Comctl32.lib;Winmm.lib;libcurl.lib;libssl-1_1.lib;libcrypto-1_1.lib;%(AdditionalDependencies)
false
@@ -443,7 +443,7 @@ xcopy "$(SolutionDir)src\3rdparty\bin\win\font\*.ttf" "$(TargetDir)fonts\" /Y /e
Windows
- pdh.lib;psapi.lib;Ws2_32.lib;wldap32.lib;Comctl32.lib;Winmm.lib;libcurl.lib;libssl-1_1-x64.lib;libcrypto-1_1-x64.lib;%(AdditionalDependencies)
+ Dwmapi.lib;pdh.lib;psapi.lib;Ws2_32.lib;wldap32.lib;Comctl32.lib;Winmm.lib;libcurl.lib;libssl-1_1-x64.lib;libcrypto-1_1-x64.lib;%(AdditionalDependencies)
false
@@ -488,7 +488,7 @@ xcopy "$(SolutionDir)src\3rdparty\bin\win\font\*.ttf" "$(TargetDir)fonts\" /Y /e
Windows
- pdh.lib;psapi.lib;Ws2_32.lib;wldap32.lib;Comctl32.lib;Winmm.lib;libcurl.lib;libssl-1_1-x64.lib;libcrypto-1_1-x64.lib;%(AdditionalDependencies)
+ Dwmapi.lib;pdh.lib;psapi.lib;Ws2_32.lib;wldap32.lib;Comctl32.lib;Winmm.lib;libcurl.lib;libssl-1_1-x64.lib;libcrypto-1_1-x64.lib;%(AdditionalDependencies)
false
@@ -533,7 +533,7 @@ xcopy "$(SolutionDir)src\3rdparty\bin\win\font\*.ttf" "$(TargetDir)fonts\" /Y /e
Console
- pdh.lib;psapi.lib;Ws2_32.lib;wldap32.lib;Comctl32.lib;Winmm.lib;libcurl.lib;libssl-1_1-x64.lib;libcrypto-1_1-x64.lib;%(AdditionalDependencies)
+ Dwmapi.lib;pdh.lib;psapi.lib;Ws2_32.lib;wldap32.lib;Comctl32.lib;Winmm.lib;libcurl.lib;libssl-1_1-x64.lib;libcrypto-1_1-x64.lib;%(AdditionalDependencies)
false
@@ -586,7 +586,7 @@ xcopy "$(SolutionDir)src\3rdparty\bin\win\font\*.ttf" "$(TargetDir)fonts\" /Y /e
MachineX86
- pdh.lib;psapi.lib;Ws2_32.lib;wldap32.lib;Comctl32.lib;Winmm.lib;libcurl.lib;libssl-1_1.lib;libcrypto-1_1.lib;%(AdditionalDependencies)
+ Dwmapi.lib;pdh.lib;psapi.lib;Ws2_32.lib;wldap32.lib;Comctl32.lib;Winmm.lib;libcurl.lib;libssl-1_1.lib;libcrypto-1_1.lib;%(AdditionalDependencies)
true
@@ -639,7 +639,7 @@ xcopy "$(SolutionDir)src\3rdparty\bin\win\font\*.ttf" "$(TargetDir)fonts\" /Y /e
MachineX86
- pdh.lib;psapi.lib;Ws2_32.lib;wldap32.lib;Comctl32.lib;Winmm.lib;libcurl.lib;libssl-1_1.lib;libcrypto-1_1.lib;%(AdditionalDependencies)
+ Dwmapi.lib;pdh.lib;psapi.lib;Ws2_32.lib;wldap32.lib;Comctl32.lib;Winmm.lib;libcurl.lib;libssl-1_1.lib;libcrypto-1_1.lib;%(AdditionalDependencies)
true
@@ -692,7 +692,7 @@ xcopy "$(SolutionDir)src\3rdparty\bin\win\font\*.ttf" "$(TargetDir)fonts\" /Y /e
MachineX86
- pdh.lib;psapi.lib;Ws2_32.lib;wldap32.lib;Comctl32.lib;Winmm.lib;libcurl.lib;libssl-1_1.lib;libcrypto-1_1.lib;%(AdditionalDependencies)
+ Dwmapi.lib;pdh.lib;psapi.lib;Ws2_32.lib;wldap32.lib;Comctl32.lib;Winmm.lib;libcurl.lib;libssl-1_1.lib;libcrypto-1_1.lib;%(AdditionalDependencies)
true
@@ -744,7 +744,7 @@ xcopy "$(SolutionDir)src\3rdparty\bin\win\font\*.ttf" "$(TargetDir)fonts\" /Y /e
- pdh.lib;psapi.lib;Ws2_32.lib;wldap32.lib;Comctl32.lib;Winmm.lib;libcurl.lib;libssl-1_1-x64.lib;libcrypto-1_1-x64.lib;%(AdditionalDependencies)
+ Dwmapi.lib;pdh.lib;psapi.lib;Ws2_32.lib;wldap32.lib;Comctl32.lib;Winmm.lib;libcurl.lib;libssl-1_1-x64.lib;libcrypto-1_1-x64.lib;%(AdditionalDependencies)
false
@@ -796,7 +796,7 @@ xcopy "$(SolutionDir)src\3rdparty\bin\win\font\*.ttf" "$(TargetDir)fonts\" /Y /e
- pdh.lib;psapi.lib;Ws2_32.lib;wldap32.lib;Comctl32.lib;Winmm.lib;libcurl.lib;libssl-1_1-x64.lib;libcrypto-1_1-x64.lib;%(AdditionalDependencies)
+ Dwmapi.lib;pdh.lib;psapi.lib;Ws2_32.lib;wldap32.lib;Comctl32.lib;Winmm.lib;libcurl.lib;libssl-1_1-x64.lib;libcrypto-1_1-x64.lib;%(AdditionalDependencies)
false
@@ -848,7 +848,7 @@ xcopy "$(SolutionDir)src\3rdparty\bin\win\font\*.ttf" "$(TargetDir)fonts\" /Y /e
- pdh.lib;psapi.lib;Ws2_32.lib;wldap32.lib;Comctl32.lib;Winmm.lib;libcurl.lib;libssl-1_1-x64.lib;libcrypto-1_1-x64.lib;%(AdditionalDependencies)
+ Dwmapi.lib;pdh.lib;psapi.lib;Ws2_32.lib;wldap32.lib;Comctl32.lib;Winmm.lib;libcurl.lib;libssl-1_1-x64.lib;libcrypto-1_1-x64.lib;%(AdditionalDependencies)
false
diff --git a/src/musikcube/stdafx.h b/src/musikcube/stdafx.h
index 96cd0769d..e1b9d9071 100644
--- a/src/musikcube/stdafx.h
+++ b/src/musikcube/stdafx.h
@@ -72,6 +72,8 @@ asio's streambuf. include it up front so work around this */
#include
#pragma warning(pop)
+#include
+
#include
#include
#include