1
0
mirror of synced 2024-11-24 07:40:17 +01:00

feat: Support DWM immersive dark mode on Windows (#1636)

### Problem description
Implements support for DWM immersive dark mode.  
Closes #1635.

### Implementation description
Uses the DwmSetWindowAttribute API to enable this feature.

Documentation can be found
[here](https://learn.microsoft.com/en-us/windows/apps/desktop/modernize/apply-windows-themes#enable-a-dark-mode-title-bar-for-win32-applications).

### Screenshots
Before:

![image](https://github.com/WerWolv/ImHex/assets/51166756/a2be204f-aa2d-44d7-8628-643a903d6679)

After:

![image](https://github.com/WerWolv/ImHex/assets/51166756/f6c9ab41-c811-45f7-826f-401dd712674b)

### Additional things
Nothing.
This commit is contained in:
Nora 2024-04-27 10:03:44 +02:00 committed by GitHub
parent 3794aa425d
commit a7033b68f7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -526,6 +526,14 @@ namespace hex {
}
}
});
RequestChangeTheme::subscribe([this](const std::string &theme) {
const int immersiveDarkMode = 20;
auto hwnd = glfwGetWin32Window(m_window);
BOOL value = theme == "Dark" ? TRUE : FALSE;
// Using the C++ "bool" type seems to not work correctly.
DwmSetWindowAttribute(hwnd, immersiveDarkMode, &value, sizeof(value));
});
ImGui::GetIO().ConfigDebugIsDebuggerPresent = ::IsDebuggerPresent();
}