From 423e23e3c0b6d3b4d6e12d095bd74bb6e36e40f2 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Mon, 8 Aug 2022 11:22:59 +0200 Subject: [PATCH] fix: Windows native theme detection not working correctly --- lib/libimhex/source/api/imhex_api.cpp | 1 + plugins/windows/source/plugin_windows.cpp | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/libimhex/source/api/imhex_api.cpp b/lib/libimhex/source/api/imhex_api.cpp index 2b895e80c..726bbf165 100644 --- a/lib/libimhex/source/api/imhex_api.cpp +++ b/lib/libimhex/source/api/imhex_api.cpp @@ -443,6 +443,7 @@ namespace hex { s_systemThemeDetection = enabled; EventManager::post(); + EventManager::post(); } bool usesSystemThemeDetection() { diff --git a/plugins/windows/source/plugin_windows.cpp b/plugins/windows/source/plugin_windows.cpp index 0b9a93e98..403fb3444 100644 --- a/plugins/windows/source/plugin_windows.cpp +++ b/plugins/windows/source/plugin_windows.cpp @@ -23,9 +23,10 @@ namespace hex::plugin::windows { static void detectSystemTheme() { // Setup system theme change detector - bool themeFollowSystem = ContentRegistry::Settings::getSetting("hex.builtin.setting.interface", "hex.builtin.setting.interface.color") == 0; - EventManager::subscribe([themeFollowSystem] { - if (!themeFollowSystem) return; + EventManager::subscribe([] { + bool themeFollowSystem = ContentRegistry::Settings::getSetting("hex.builtin.setting.interface", "hex.builtin.setting.interface.color") == 0; + if (!themeFollowSystem) + return; HKEY hkey; if (RegOpenKey(HKEY_CURRENT_USER, R"(Software\Microsoft\Windows\CurrentVersion\Themes\Personalize)", &hkey) == ERROR_SUCCESS) { @@ -42,6 +43,8 @@ static void detectSystemTheme() { }); EventManager::subscribe([=] { + bool themeFollowSystem = ContentRegistry::Settings::getSetting("hex.builtin.setting.interface", "hex.builtin.setting.interface.color") == 0; + if (themeFollowSystem) EventManager::post(); });