Rewrite WIN_GetSystemTheme() so we don't need to bump Windows SDK versions
parent
edc8f0b841
commit
c044cff4c7
|
@ -41,7 +41,7 @@
|
||||||
#elif defined(HAVE_SHELLSCALINGAPI_H)
|
#elif defined(HAVE_SHELLSCALINGAPI_H)
|
||||||
#define _WIN32_WINNT 0x603 /* For DPI support */
|
#define _WIN32_WINNT 0x603 /* For DPI support */
|
||||||
#else
|
#else
|
||||||
#define _WIN32_WINNT 0x502 /* Need 0x410 for AlphaBlend() and 0x500 for EnumDisplayDevices(), 0x501 for raw input, 0x502 for RegGetValue() */
|
#define _WIN32_WINNT 0x501 /* Need 0x410 for AlphaBlend() and 0x500 for EnumDisplayDevices(), 0x501 for raw input */
|
||||||
#endif
|
#endif
|
||||||
#define WINVER _WIN32_WINNT
|
#define WINVER _WIN32_WINNT
|
||||||
|
|
||||||
|
|
|
@ -680,21 +680,22 @@ SDL_bool SDL_DXGIGetOutputInfo(SDL_DisplayID displayID, int *adapterIndex, int *
|
||||||
|
|
||||||
SDL_SystemTheme WIN_GetSystemTheme(void)
|
SDL_SystemTheme WIN_GetSystemTheme(void)
|
||||||
{
|
{
|
||||||
DWORD type;
|
SDL_SystemTheme theme = SDL_SYSTEM_THEME_LIGHT;
|
||||||
DWORD value;
|
HKEY hKey;
|
||||||
DWORD count = sizeof(value);
|
DWORD dwType = REG_DWORD;
|
||||||
LSTATUS status;
|
DWORD value = ~0;
|
||||||
|
DWORD length = sizeof(value);
|
||||||
|
|
||||||
/* Technically this isn't the system theme, but it's the preference for applications */
|
/* Technically this isn't the system theme, but it's the preference for applications */
|
||||||
status = RegGetValue(HKEY_CURRENT_USER,
|
if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", 0, KEY_READ, &hKey) == ERROR_SUCCESS) {
|
||||||
TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"),
|
if (RegQueryValueExW(hKey, L"AppsUseLightTheme", 0, &dwType, (LPBYTE)&value, &length) == ERROR_SUCCESS) {
|
||||||
TEXT("AppsUseLightTheme"),
|
if (value == 0) {
|
||||||
RRF_RT_REG_DWORD, &type, &value, &count);
|
theme = SDL_SYSTEM_THEME_DARK;
|
||||||
if (status == ERROR_SUCCESS && type == REG_DWORD && value == 0) {
|
|
||||||
return SDL_SYSTEM_THEME_DARK;
|
|
||||||
} else {
|
|
||||||
return SDL_SYSTEM_THEME_LIGHT;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
RegCloseKey(hKey);
|
||||||
|
}
|
||||||
|
return theme;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool WIN_IsPerMonitorV2DPIAware(_THIS)
|
SDL_bool WIN_IsPerMonitorV2DPIAware(_THIS)
|
||||||
|
|
Loading…
Reference in New Issue