Fixes https://bugs.winehq.org/show_bug.cgi?id=55640.
The lightening/darkening values are loosely based on Qt 6's fallback code: https://github.com/qt/qtbase/blob/ba98644180bcaf40341a9005abe93575cf45cc5a/s....
The values are not perfect, technically it should use Software\Microsoft\Windows\DWM\AccentColor. But since to my knowledge, wine doesn't use AccentColor in any way, this should do the trick for now. `COLOR_HIGHLIGHT` should be roughly the same color as the accent color in most cases. Qt 6 uses the accent color as its highlight color anyways.
-- v6: windows.ui: Support accent colors in uisettings3_GetColorValue.
From: Myah Caron qsniyg@protonmail.com
Signed-off-by: Myah Caron qsniyg@protonmail.com --- dlls/windows.ui/Makefile.in | 2 +- dlls/windows.ui/uisettings.c | 41 +++++++++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 2 deletions(-)
diff --git a/dlls/windows.ui/Makefile.in b/dlls/windows.ui/Makefile.in index 592d023f353..4fafcbfe869 100644 --- a/dlls/windows.ui/Makefile.in +++ b/dlls/windows.ui/Makefile.in @@ -1,5 +1,5 @@ MODULE = windows.ui.dll -IMPORTS = combase advapi32 +IMPORTS = combase advapi32 user32
C_SRCS = \ main.c \ diff --git a/dlls/windows.ui/uisettings.c b/dlls/windows.ui/uisettings.c index 041388da33b..76e0ba6b28b 100644 --- a/dlls/windows.ui/uisettings.c +++ b/dlls/windows.ui/uisettings.c @@ -274,9 +274,23 @@ static void set_color_value( BYTE a, BYTE r, BYTE g, BYTE b, Color *out ) out->B = b; }
+static BYTE darken_single_color( BYTE color, float darken ) +{ + return (BYTE)(color + ((color / 256.0) * darken)); +} + +static void darken_dword_to_color( DWORD color, float darken, Color *out ) +{ + out->R = darken_single_color(color & 0xFF, darken); + out->G = darken_single_color((color >> 8) & 0xFF, darken); + out->B = darken_single_color((color >> 16) & 0xFF, darken); + out->A = (color >> 24) & 0xFF; +} + static HRESULT WINAPI uisettings3_GetColorValue( IUISettings3 *iface, UIColorType type, Color *value ) { DWORD theme; + DWORD highlight;
TRACE( "iface %p, type %d, value %p.\n", iface, type, value );
@@ -286,6 +300,17 @@ static HRESULT WINAPI uisettings3_GetColorValue( IUISettings3 *iface, UIColorTyp case UIColorType_Background: theme = get_app_theme(); break; + case UIColorType_Accent: + case UIColorType_AccentDark1: + case UIColorType_AccentDark2: + case UIColorType_AccentDark3: + case UIColorType_AccentLight1: + case UIColorType_AccentLight2: + case UIColorType_AccentLight3: + if (type != UIColorType_Accent) + FIXME( "type %d: returning dummy color.\n", type ); + highlight = GetSysColor(COLOR_HIGHLIGHT); + break; default: FIXME( "type %d not implemented.\n", type ); return E_NOTIMPL; @@ -293,8 +318,22 @@ static HRESULT WINAPI uisettings3_GetColorValue( IUISettings3 *iface, UIColorTyp
if (type == UIColorType_Foreground) set_color_value( 255, theme ? 0 : 255, theme ? 0 : 255, theme ? 0 : 255, value ); - else + else if (type == UIColorType_Background) set_color_value( 255, theme ? 255 : 0, theme ? 255 : 0, theme ? 255 : 0, value ); + else if (type == UIColorType_Accent) + darken_dword_to_color( highlight, 0.0, value ); + else if (type == UIColorType_AccentDark1) + darken_dword_to_color( highlight, 0.2, value ); + else if (type == UIColorType_AccentDark2) + darken_dword_to_color( highlight, 0.4, value ); + else if (type == UIColorType_AccentDark3) + darken_dword_to_color( highlight, 0.6, value ); + else if (type == UIColorType_AccentLight1) + darken_dword_to_color( highlight, -0.2, value ); + else if (type == UIColorType_AccentLight2) + darken_dword_to_color( highlight, -0.4, value ); + else if (type == UIColorType_AccentLight3) + darken_dword_to_color( highlight, -0.6, 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;
You should add a Wine-Bug header with a link to your bug report in the commit
Also that if-else spam should probably be converted to a switch-case statement :frog: