[PATCH v2 2/2] user32: SetSysColors updates pens from SYSCOLOR_GetPen

Fabian Maurer dark.shadow4 at web.de
Sat Jan 14 15:05:16 CST 2017


No tests since it's an internal function,
but it's the same as with the brushes.

v2: Rewrote patch to make it cleaner

Signed-off-by: Fabian Maurer <dark.shadow4 at web.de>
---
 dlls/gdi32/gdi_private.h |  3 +++
 dlls/gdi32/gdiobj.c      |  6 ++++++
 dlls/gdi32/pen.c         |  6 ++++++
 dlls/user32/sysparams.c  | 10 ++++------
 4 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/dlls/gdi32/gdi_private.h b/dlls/gdi32/gdi_private.h
index f0835723ee..3d63a7b62f 100644
--- a/dlls/gdi32/gdi_private.h
+++ b/dlls/gdi32/gdi_private.h
@@ -312,6 +312,9 @@ extern void lp_to_dp( DC *dc, POINT *points, INT count ) DECLSPEC_HIDDEN;
 extern HMETAFILE MF_Create_HMETAFILE(METAHEADER *mh) DECLSPEC_HIDDEN;
 extern METAHEADER *MF_CreateMetaHeaderDisk(METAHEADER *mr, LPCVOID filename, BOOL unicode ) DECLSPEC_HIDDEN;
 
+/* pen.c */
+extern EXTLOGPEN* PEN_internal_GetObject( HGDIOBJ handle ) DECLSPEC_HIDDEN;
+
 /* Format of comment record added by GetWinMetaFileBits */
 #include <pshpack2.h>
 typedef struct
diff --git a/dlls/gdi32/gdiobj.c b/dlls/gdi32/gdiobj.c
index 6928557915..4d4f0c87a8 100644
--- a/dlls/gdi32/gdiobj.c
+++ b/dlls/gdi32/gdiobj.c
@@ -907,6 +907,12 @@ void CDECL __wine_set_gdi_object_color( HGDIOBJ handle, WORD type, COLORREF colo
         brush->lbColor = color;
         GDI_ReleaseObj( handle );
     }
+    else if(type == OBJ_PEN)
+    {
+        EXTLOGPEN *pen = PEN_internal_GetObject( handle );
+        pen->elpColor = color;
+        GDI_ReleaseObj( handle );
+    }
 
     LeaveCriticalSection( &gdi_section );
 }
diff --git a/dlls/gdi32/pen.c b/dlls/gdi32/pen.c
index d6c1dc4576..e42887ec0e 100644
--- a/dlls/gdi32/pen.c
+++ b/dlls/gdi32/pen.c
@@ -333,3 +333,9 @@ static INT PEN_GetObject( HGDIOBJ handle, INT count, LPVOID buffer )
     GDI_ReleaseObj( handle );
     return ret;
 }
+
+EXTLOGPEN* PEN_internal_GetObject( HGDIOBJ handle )
+{
+    PENOBJ *pen = GDI_GetObjPtr( handle, OBJ_PEN );
+    return &pen->logpen;
+}
diff --git a/dlls/user32/sysparams.c b/dlls/user32/sysparams.c
index ef464bff55..8caf41cd1c 100644
--- a/dlls/user32/sysparams.c
+++ b/dlls/user32/sysparams.c
@@ -890,17 +890,12 @@ done:
 static BOOL set_rgb_entry( union sysparam_all_entry *entry, UINT int_param, void *ptr_param, UINT flags )
 {
     WCHAR buf[32];
-    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 ((pen = InterlockedExchangePointer( (void **)&entry->rgb.pen, 0 )))
-    {
-        __wine_make_gdi_object_system( pen, FALSE );
-        DeleteObject( pen );
-    }
+
     return TRUE;
 }
 
@@ -2644,9 +2639,12 @@ COLORREF WINAPI DECLSPEC_HOTPATCH GetSysColor( INT nIndex )
 static void set_syscolors_gdi( INT index, COLORREF color )
 {
     HBRUSH brush = system_colors[index].brush;
+    HPEN pen = system_colors[index].pen;
 
     if(brush)
         __wine_set_gdi_object_color( brush, OBJ_BRUSH, color);
+    if(pen)
+        __wine_set_gdi_object_color( pen, OBJ_PEN, color);
 }
 
 /*************************************************************************
-- 
2.11.0




More information about the wine-patches mailing list