Win32: Dark Mode Title Bar Color
Blender will respect Windows "Dark Mode" setting for title bar color. See D14847 for details. Differential Revision: https://developer.blender.org/D14847 Reviewed by Ray Molenkamp
This commit is contained in:
parent
836fbb90aa
commit
ddbac88c08
@ -104,7 +104,7 @@ string(APPEND CMAKE_MODULE_LINKER_FLAGS " /SAFESEH:NO /ignore:4099")
|
||||
list(APPEND PLATFORM_LINKLIBS
|
||||
ws2_32 vfw32 winmm kernel32 user32 gdi32 comdlg32 Comctl32 version
|
||||
advapi32 shfolder shell32 ole32 oleaut32 uuid psapi Dbghelp Shlwapi
|
||||
pathcch Shcore
|
||||
pathcch Shcore Dwmapi
|
||||
)
|
||||
|
||||
if(WITH_INPUT_IME)
|
||||
|
@ -14,6 +14,7 @@
|
||||
#endif
|
||||
|
||||
#include <commctrl.h>
|
||||
#include <dwmapi.h>
|
||||
#include <psapi.h>
|
||||
#include <shellapi.h>
|
||||
#include <shellscalingapi.h>
|
||||
@ -1985,6 +1986,11 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
|
||||
::SetFocus(hwnd);
|
||||
}
|
||||
break;
|
||||
case WM_SETTINGCHANGE:
|
||||
if (wcscmp(LPCWSTR(lParam), L"ImmersiveColorSet") == 0) {
|
||||
window->ThemeRefresh();
|
||||
}
|
||||
break;
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Window events, ignored
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
@ -16,9 +16,7 @@
|
||||
|
||||
#include "GHOST_ContextWGL.h"
|
||||
|
||||
#ifdef WIN32_COMPOSITING
|
||||
# include <Dwmapi.h>
|
||||
#endif
|
||||
#include <Dwmapi.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
@ -172,6 +170,8 @@ GHOST_WindowWin32::GHOST_WindowWin32(GHOST_SystemWin32 *system,
|
||||
break;
|
||||
}
|
||||
|
||||
ThemeRefresh();
|
||||
|
||||
::ShowWindow(m_hWnd, nCmdShow);
|
||||
|
||||
#ifdef WIN32_COMPOSITING
|
||||
@ -1016,6 +1016,25 @@ GHOST_TabletData GHOST_WindowWin32::getTabletData()
|
||||
}
|
||||
}
|
||||
|
||||
void GHOST_WindowWin32::ThemeRefresh()
|
||||
{
|
||||
DWORD lightMode;
|
||||
DWORD pcbData = sizeof(lightMode);
|
||||
if (RegGetValueW(HKEY_CURRENT_USER,
|
||||
L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize\\",
|
||||
L"AppsUseLightTheme",
|
||||
RRF_RT_REG_DWORD,
|
||||
NULL,
|
||||
&lightMode,
|
||||
&pcbData) == ERROR_SUCCESS) {
|
||||
BOOL DarkMode = !lightMode;
|
||||
|
||||
/* 20 == DWMWA_USE_IMMERSIVE_DARK_MODE in Windows 11 SDK. This value was undocumented for
|
||||
* Windows 10 versions 2004 and later, supported for Windows 11 Build 22000 and later. */
|
||||
DwmSetWindowAttribute(this->m_hWnd, 20, &DarkMode, sizeof(DarkMode));
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t GHOST_WindowWin32::getDPIHint()
|
||||
{
|
||||
if (m_user32) {
|
||||
|
@ -294,6 +294,9 @@ class GHOST_WindowWin32 : public GHOST_Window {
|
||||
/** True if the window currently resizing. */
|
||||
bool m_inLiveResize;
|
||||
|
||||
/** Called when OS colors change and when the window is created. */
|
||||
void ThemeRefresh();
|
||||
|
||||
#ifdef WITH_INPUT_IME
|
||||
GHOST_ImeWin32 *getImeInput()
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user