[PATCH 1/2] user32: SetSysColors updates brushes from GetSysColorBrush and add test
Fabian Maurer
dark.shadow4 at web.de
Sat Jan 14 13:33:39 CST 2017
Signed-off-by: Fabian Maurer <dark.shadow4 at web.de>
---
dlls/gdi32/gdi32.spec | 2 ++
dlls/gdi32/gdiobj.c | 12 ++++++++++++
dlls/user32/sysparams.c | 23 +++++++++++++++++------
dlls/user32/tests/sysparams.c | 16 ++++++++++++++++
include/wine/gdi_driver.h | 2 ++
5 files changed, 49 insertions(+), 6 deletions(-)
diff --git a/dlls/gdi32/gdi32.spec b/dlls/gdi32/gdi32.spec
index 7792731b9e..f9c3fb9293 100644
--- a/dlls/gdi32/gdi32.spec
+++ b/dlls/gdi32/gdi32.spec
@@ -518,6 +518,8 @@
# GDI objects
@ cdecl __wine_make_gdi_object_system(long long)
@ cdecl __wine_set_visible_region(long long ptr ptr ptr)
+@ cdecl __wine_GDI_ReleaseObj(ptr)
+@ cdecl __wine_GDI_GetObjPtr(ptr long)
# Graphics drivers
@ cdecl __wine_set_display_driver(long)
diff --git a/dlls/gdi32/gdiobj.c b/dlls/gdi32/gdiobj.c
index 46b2241945..aa2ced1025 100644
--- a/dlls/gdi32/gdiobj.c
+++ b/dlls/gdi32/gdiobj.c
@@ -880,6 +880,18 @@ void GDI_ReleaseObj( HGDIOBJ handle )
LeaveCriticalSection( &gdi_section );
}
+/* Exports for user32, we need to be able to manipulate GDI objects where the official API doesn't allow us */
+
+void* CDECL __wine_GDI_GetObjPtr( HGDIOBJ handle, WORD type )
+{
+ return GDI_GetObjPtr( handle, type );
+}
+
+void CDECL __wine_GDI_ReleaseObj( HGDIOBJ handle )
+{
+ GDI_ReleaseObj( handle );
+}
+
/***********************************************************************
* GDI_CheckNotLock
diff --git a/dlls/user32/sysparams.c b/dlls/user32/sysparams.c
index 63c4ffe070..88848c9df5 100644
--- a/dlls/user32/sysparams.c
+++ b/dlls/user32/sysparams.c
@@ -890,18 +890,12 @@ done:
static BOOL set_rgb_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT flags )
{
WCHAR buf[32];
- HBRUSH brush;
HPEN pen;
wsprintfW( buf, CSrgb, GetRValue(int_param), GetGValue(int_param), GetBValue(int_param) );
if (!save_entry_string( &entry->hdr, buf, flags )) return FALSE;
entry->rgb.val = int_param;
entry->hdr.loaded = TRUE;
- if ((brush = InterlockedExchangePointer( (void **)&entry->rgb.brush, 0 )))
- {
- __wine_make_gdi_object_system( brush, FALSE );
- DeleteObject( brush );
- }
if ((pen = InterlockedExchangePointer( (void **)&entry->rgb.pen, 0 )))
{
__wine_make_gdi_object_system( pen, FALSE );
@@ -2647,6 +2641,20 @@ COLORREF WINAPI DECLSPEC_HOTPATCH GetSysColor( INT nIndex )
return ret;
}
+static void set_syscolors_gdi( INT index, COLORREF color )
+{
+ HBRUSH brush = system_colors[index].brush;
+ LOGBRUSH *brush_info;
+
+ if(brush)
+ {
+ /* Since LOGBRUSH is the first member in BRUSHOBJ we just do a cast here */
+ brush_info = __wine_GDI_GetObjPtr( brush, OBJ_BRUSH );
+ if(brush_info->lbColor != color)
+ brush_info->lbColor = color;
+ __wine_GDI_ReleaseObj( brush );
+ }
+}
/*************************************************************************
* SetSysColors (USER32.@)
@@ -2659,7 +2667,10 @@ BOOL WINAPI SetSysColors( INT count, const INT *colors, const COLORREF *values )
for (i = 0; i < count; i++)
if (colors[i] >= 0 && colors[i] <= NUM_SYS_COLORS)
+ {
set_entry( &system_colors[colors[i]], values[i], 0, 0 );
+ set_syscolors_gdi( colors[i], values[i] );
+ }
/* Send WM_SYSCOLORCHANGE message to all windows */
diff --git a/dlls/user32/tests/sysparams.c b/dlls/user32/tests/sysparams.c
index 075a0c71f6..5d1895982c 100644
--- a/dlls/user32/tests/sysparams.c
+++ b/dlls/user32/tests/sysparams.c
@@ -2917,6 +2917,21 @@ static void test_GetSysColorBrush(void)
win_skip("COLOR_MENUBAR unsupported\n");
}
+static void test_SetSysColors(void)
+{
+ INT element = COLOR_WINDOW;
+ DWORD color_backup = GetSysColor(COLOR_WINDOW); /* Backup system colors */
+ COLORREF color = RGB(0, 0, 255);
+ LOGBRUSH brush_info;
+
+ HBRUSH brush = GetSysColorBrush(COLOR_WINDOW);
+ SetSysColors(1, &element, &color);
+ GetObjectW(brush, sizeof(LOGBRUSH), &brush_info);
+ ok(color == brush_info.lbColor, "Brush didn't update after SetSysColors\n");
+
+ SetSysColors(1, &element, &color_backup); /* Restore system colors */
+}
+
START_TEST(sysparams)
{
int argc;
@@ -2948,6 +2963,7 @@ START_TEST(sysparams)
trace("testing EnumDisplaySettings vs GetDeviceCaps\n");
test_EnumDisplaySettings( );
test_GetSysColorBrush( );
+ test_SetSysColors( );
change_counter = 0;
change_last_param = 0;
diff --git a/include/wine/gdi_driver.h b/include/wine/gdi_driver.h
index 6f67653b51..6064a2d13c 100644
--- a/include/wine/gdi_driver.h
+++ b/include/wine/gdi_driver.h
@@ -276,6 +276,8 @@ WINGDIAPI WORD WINAPI SetHookFlags(HDC,WORD);
extern void CDECL __wine_make_gdi_object_system( HGDIOBJ handle, BOOL set );
extern void CDECL __wine_set_visible_region( HDC hdc, HRGN hrgn, const RECT *vis_rect,
const RECT *device_rect, struct window_surface *surface );
+void* CDECL __wine_GDI_GetObjPtr( HGDIOBJ handle, WORD type );
+void CDECL __wine_GDI_ReleaseObj( HGDIOBJ handle );
extern void CDECL __wine_set_display_driver( HMODULE module );
extern struct opengl_funcs * CDECL __wine_get_wgl_driver( HDC hdc, UINT version );
--
2.11.0
More information about the wine-patches
mailing list