Module: wine Branch: master Commit: 7ac3b0fd856422159592b15be0d5d6dc568976a5 URL: https://gitlab.winehq.org/wine/wine/-/commit/7ac3b0fd856422159592b15be0d5d6d...
Author: Mohamad Al-Jaf mohamadaljaf@gmail.com Date: Sat Jan 28 01:01:26 2023 -0500
windows.ui: Implement IUISettings3::GetColorValue().
---
dlls/windows.ui/Makefile.in | 2 +- dlls/windows.ui/tests/uisettings.c | 12 +++++----- dlls/windows.ui/uisettings.c | 46 ++++++++++++++++++++++++++++++++++++-- 3 files changed, 51 insertions(+), 9 deletions(-)
diff --git a/dlls/windows.ui/Makefile.in b/dlls/windows.ui/Makefile.in index cb9b48a664b..592d023f353 100644 --- a/dlls/windows.ui/Makefile.in +++ b/dlls/windows.ui/Makefile.in @@ -1,5 +1,5 @@ MODULE = windows.ui.dll -IMPORTS = combase +IMPORTS = combase advapi32
C_SRCS = \ main.c \ diff --git a/dlls/windows.ui/tests/uisettings.c b/dlls/windows.ui/tests/uisettings.c index 133173c528c..bd1e7a02d20 100644 --- a/dlls/windows.ui/tests/uisettings.c +++ b/dlls/windows.ui/tests/uisettings.c @@ -134,15 +134,15 @@ static void test_UISettings(void) reset_color( &value ); type = UIColorType_Foreground; hr = IUISettings3_GetColorValue( uisettings3, type, &value ); - todo_wine ok( hr == S_OK, "GetColorValue returned %#lx\n", hr ); - todo_wine ok( value.A == 255 && value.R == 0 && value.G == 0 && value.B == 0, + ok( hr == S_OK, "GetColorValue returned %#lx\n", hr ); + ok( value.A == 255 && value.R == 0 && value.G == 0 && value.B == 0, "got unexpected value.A == %d value.R == %d value.G == %d value.B == %d\n", value.A, value.R, value.G, value.B );
reset_color( &value ); type = UIColorType_Background; hr = IUISettings3_GetColorValue( uisettings3, type, &value ); - todo_wine ok( hr == S_OK, "GetColorValue returned %#lx\n", hr ); - todo_wine ok( value.A == 255 && value.R == 255 && value.G == 255 && value.B == 255, + ok( hr == S_OK, "GetColorValue returned %#lx\n", hr ); + ok( value.A == 255 && value.R == 255 && value.G == 255 && value.B == 255, "got unexpected value.A == %d value.R == %d value.G == %d value.B == %d\n", value.A, value.R, value.G, value.B );
/* Dark Theme */ @@ -151,14 +151,14 @@ static void test_UISettings(void) reset_color( &value ); type = UIColorType_Foreground; hr = IUISettings3_GetColorValue( uisettings3, type, &value ); - todo_wine ok( hr == S_OK, "GetColorValue returned %#lx\n", hr ); + ok( hr == S_OK, "GetColorValue returned %#lx\n", hr ); todo_wine ok( value.A == 255 && value.R == 255 && value.G == 255 && value.B == 255, "got unexpected value.A == %d value.R == %d value.G == %d value.B == %d\n", value.A, value.R, value.G, value.B );
reset_color( &value ); type = UIColorType_Background; hr = IUISettings3_GetColorValue( uisettings3, type, &value ); - todo_wine ok( hr == S_OK, "GetColorValue returned %#lx\n", hr ); + ok( hr == S_OK, "GetColorValue returned %#lx\n", hr ); todo_wine ok( value.A == 255 && value.R == 0 && value.G == 0 && value.B == 0, "got unexpected value.A == %d value.R == %d value.G == %d value.B == %d\n", value.A, value.R, value.G, value.B );
diff --git a/dlls/windows.ui/uisettings.c b/dlls/windows.ui/uisettings.c index 983a9b9f0cf..943fbb6a37e 100644 --- a/dlls/windows.ui/uisettings.c +++ b/dlls/windows.ui/uisettings.c @@ -92,10 +92,52 @@ static HRESULT WINAPI uisettings3_GetTrustLevel( IUISettings3 *iface, TrustLevel return E_NOTIMPL; }
+static DWORD get_app_theme(void) +{ + static const WCHAR *subkey = L"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize"; + static const WCHAR *name = L"AppsUseLightTheme"; + static const HKEY root = HKEY_CURRENT_USER; + DWORD ret = 0, len = sizeof(ret), type; + HKEY hkey; + + if (RegOpenKeyExW( root, subkey, 0, KEY_QUERY_VALUE, &hkey )) return 1; + if (RegQueryValueExW( hkey, name, NULL, &type, (BYTE *)&ret, &len ) || type != REG_DWORD) ret = 1; + RegCloseKey( hkey ); + return ret; +} + +static void set_color_value( BYTE a, BYTE r, BYTE g, BYTE b, Color *out ) +{ + out->A = a; + out->R = r; + out->G = g; + out->B = b; +} + static HRESULT WINAPI uisettings3_GetColorValue( IUISettings3 *iface, UIColorType type, Color *value ) { - FIXME( "iface %p, type %d, color %p stub!\n", iface, type, value ); - return E_NOTIMPL; + DWORD theme; + + TRACE( "iface %p, type %d, value %p.\n", iface, type, value ); + + switch (type) + { + case UIColorType_Foreground: + case UIColorType_Background: + theme = get_app_theme(); + break; + default: + FIXME( "type %d not implemented.\n", type ); + return E_NOTIMPL; + } + + if (type == UIColorType_Foreground) + set_color_value( 255, theme ? 0 : 255, theme ? 0 : 255, theme ? 0 : 255, value ); + else + set_color_value( 255, theme ? 255 : 0, theme ? 255 : 0, theme ? 255 : 0, value ); + + TRACE( "Returning value.A = %d, value.R = %d, value.G = %d, value.B = %d\n", value->A, value->R, value->G, value->B ); + return S_OK; }
static HRESULT WINAPI uisettings3_add_ColorValuesChanged( IUISettings3 *iface, ITypedEventHandler_UISettings_IInspectable *handler, EventRegistrationToken *cookie )