Commit 91e54e5f authored by Helix Graziani's avatar Helix Graziani Committed by Alexandre Julliard

uxtheme: Add ShouldSystemUseDarkMode.

parent 26471dd0
...@@ -1256,3 +1256,20 @@ BOOL WINAPI ThemeHooksRemove(void) ...@@ -1256,3 +1256,20 @@ BOOL WINAPI ThemeHooksRemove(void)
UnregisterUserApiHook(); UnregisterUserApiHook();
return TRUE; return TRUE;
} }
/**********************************************************************
* ShouldSystemUseDarkMode (UXTHEME.138)
*
* RETURNS
* Whether or not the system should use dark mode.
*/
BOOL WINAPI ShouldSystemUseDarkMode(void)
{
DWORD light_theme = TRUE, light_theme_size = sizeof(light_theme);
RegGetValueW(HKEY_CURRENT_USER,
L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize",
L"SystemUsesLightTheme", RRF_RT_REG_DWORD, NULL, &light_theme, &light_theme_size);
return !light_theme;
}
...@@ -48,6 +48,7 @@ static HDC (WINAPI *pGetBufferedPaintTargetDC)(HPAINTBUFFER); ...@@ -48,6 +48,7 @@ static HDC (WINAPI *pGetBufferedPaintTargetDC)(HPAINTBUFFER);
static HRESULT (WINAPI *pGetBufferedPaintTargetRect)(HPAINTBUFFER, RECT *); static HRESULT (WINAPI *pGetBufferedPaintTargetRect)(HPAINTBUFFER, RECT *);
static HRESULT (WINAPI *pGetThemeIntList)(HTHEME, int, int, int, INTLIST *); static HRESULT (WINAPI *pGetThemeIntList)(HTHEME, int, int, int, INTLIST *);
static HRESULT (WINAPI *pGetThemeTransitionDuration)(HTHEME, int, int, int, int, DWORD *); static HRESULT (WINAPI *pGetThemeTransitionDuration)(HTHEME, int, int, int, int, DWORD *);
static BOOL (WINAPI *pShouldSystemUseDarkMode)(void);
static LONG (WINAPI *pDisplayConfigGetDeviceInfo)(DISPLAYCONFIG_DEVICE_INFO_HEADER *); static LONG (WINAPI *pDisplayConfigGetDeviceInfo)(DISPLAYCONFIG_DEVICE_INFO_HEADER *);
static LONG (WINAPI *pDisplayConfigSetDeviceInfo)(DISPLAYCONFIG_DEVICE_INFO_HEADER *); static LONG (WINAPI *pDisplayConfigSetDeviceInfo)(DISPLAYCONFIG_DEVICE_INFO_HEADER *);
...@@ -74,6 +75,8 @@ static void init_funcs(void) ...@@ -74,6 +75,8 @@ static void init_funcs(void)
HMODULE gdi32 = GetModuleHandleA("gdi32.dll"); HMODULE gdi32 = GetModuleHandleA("gdi32.dll");
HMODULE uxtheme = GetModuleHandleA("uxtheme.dll"); HMODULE uxtheme = GetModuleHandleA("uxtheme.dll");
pShouldSystemUseDarkMode = (void *)GetProcAddress(uxtheme, MAKEINTRESOURCEA(138));
#define GET_PROC(module, func) \ #define GET_PROC(module, func) \
p##func = (void *)GetProcAddress(module, #func); \ p##func = (void *)GetProcAddress(module, #func); \
if (!p##func) \ if (!p##func) \
...@@ -2597,6 +2600,35 @@ static void test_theme(void) ...@@ -2597,6 +2600,35 @@ static void test_theme(void)
DestroyWindow(hwnd); DestroyWindow(hwnd);
} }
static void test_ShouldSystemUseDarkMode(void)
{
DWORD light_theme, light_theme_size = sizeof(light_theme), last_error;
BOOL result;
LSTATUS ls;
if (!pShouldSystemUseDarkMode)
{
win_skip("ShouldSystemUseDarkMode() is unavailable.\n");
return;
}
ls = RegGetValueW(HKEY_CURRENT_USER,
L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize",
L"SystemUsesLightTheme", RRF_RT_REG_DWORD, NULL, &light_theme, &light_theme_size);
if (ls == ERROR_FILE_NOT_FOUND)
{
light_theme = 1;
ls = 0;
}
ok(ls == 0, "RegGetValue failed: %ld.\n", ls);
SetLastError(0xdeadbeef);
result = pShouldSystemUseDarkMode();
last_error = GetLastError();
ok(last_error == 0xdeadbeef, "ShouldSystemUseDarkMode set last error: %ld.\n", last_error);
ok(result == !light_theme, "Expected value %d, got %d.\n", !light_theme, result);
}
START_TEST(system) START_TEST(system)
{ {
ULONG_PTR ctx_cookie; ULONG_PTR ctx_cookie;
...@@ -2622,6 +2654,7 @@ START_TEST(system) ...@@ -2622,6 +2654,7 @@ START_TEST(system)
test_DrawThemeBackgroundEx(); test_DrawThemeBackgroundEx();
test_GetThemeBackgroundRegion(); test_GetThemeBackgroundRegion();
test_theme(); test_theme();
test_ShouldSystemUseDarkMode();
if (load_v6_module(&ctx_cookie, &ctx)) if (load_v6_module(&ctx_cookie, &ctx))
{ {
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
61 stdcall OpenThemeDataEx(ptr wstr long) 61 stdcall OpenThemeDataEx(ptr wstr long)
62 stub -noname ServerClearStockObjects 62 stub -noname ServerClearStockObjects
63 stub -noname MarkSelection 63 stub -noname MarkSelection
138 stdcall -noname ShouldSystemUseDarkMode()
# Standard functions # Standard functions
@ stdcall BeginBufferedAnimation(ptr ptr ptr long ptr ptr ptr ptr) @ stdcall BeginBufferedAnimation(ptr ptr ptr long ptr ptr ptr ptr)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment