win32: follow Windows settings and update dark mode state

Microsoft documented how to enable dark mode for title bar:

https://learn.microsoft.com/windows/apps/desktop/modernize/apply-windows-themes
https://learn.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute

Documentation says to set the DWMWA_USE_IMMERSIVE_DARK_MODE attribute to
TRUE to honor dark mode for the window, FALSE to always use light mode.
While in fact setting it to TRUE causes dark mode to be always enabled,
regardless of the settings. Since it is quite unlikely that it will be
fixed, just use UxTheme API to check if dark mode should be applied and
while at it enable it fully. Ideally this function should only call the
DwmSetWindowAttribute(), but it just doesn't work as documented.

Fixes: #6901
This commit is contained in:
Kacper Michajłow
2023-03-19 06:40:53 +01:00
committed by sfan5
parent 68b3239b52
commit 9feeb324ed
3 changed files with 57 additions and 1 deletions

View File

@@ -477,6 +477,7 @@ if features['win32-desktop']
cc.find_library('gdi32'),
cc.find_library('ole32'),
cc.find_library('uuid'),
cc.find_library('uxtheme'),
cc.find_library('version'),
cc.find_library('winmm')]
dependencies += win32_desktop_libs