[PATCH] comctl32/listview: Do no alter custom draw text colors between notification stages.

Nikolay Sivov nsivov at codeweavers.com
Tue Jul 21 07:00:18 CDT 2020


Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
 dlls/comctl32/listview.c       | 23 +++++++++--------------
 dlls/comctl32/tests/listview.c | 14 ++++----------
 2 files changed, 13 insertions(+), 24 deletions(-)

diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c
index 6cee291dd69..dba16d13a4c 100644
--- a/dlls/comctl32/listview.c
+++ b/dlls/comctl32/listview.c
@@ -1055,31 +1055,31 @@ static inline DWORD notify_customdraw (const LISTVIEW_INFO *infoPtr, DWORD dwDra
     return result;
 }
 
-static void prepaint_setup (const LISTVIEW_INFO *infoPtr, HDC hdc, NMLVCUSTOMDRAW *lpnmlvcd, BOOL SubItem)
+static void prepaint_setup (const LISTVIEW_INFO *infoPtr, HDC hdc, const NMLVCUSTOMDRAW *cd, BOOL SubItem)
 {
     COLORREF backcolor, textcolor;
 
+    backcolor = cd->clrTextBk;
+    textcolor = cd->clrText;
+
     /* apparently, for selected items, we have to override the returned values */
     if (!SubItem)
     {
-        if (lpnmlvcd->nmcd.uItemState & CDIS_SELECTED)
+        if (cd->nmcd.uItemState & CDIS_SELECTED)
         {
             if (infoPtr->bFocus)
             {
-                lpnmlvcd->clrTextBk = comctl32_color.clrHighlight;
-                lpnmlvcd->clrText   = comctl32_color.clrHighlightText;
+                backcolor = comctl32_color.clrHighlight;
+                textcolor = comctl32_color.clrHighlightText;
             }
             else if (infoPtr->dwStyle & LVS_SHOWSELALWAYS)
             {
-                lpnmlvcd->clrTextBk = comctl32_color.clr3dFace;
-                lpnmlvcd->clrText   = comctl32_color.clrBtnText;
+                backcolor = comctl32_color.clr3dFace;
+                textcolor = comctl32_color.clrBtnText;
             }
         }
     }
 
-    backcolor = lpnmlvcd->clrTextBk;
-    textcolor = lpnmlvcd->clrText;
-
     if (backcolor == CLR_DEFAULT)
         backcolor = comctl32_color.clrWindow;
     if (textcolor == CLR_DEFAULT)
@@ -4812,11 +4812,6 @@ static BOOL LISTVIEW_DrawItem(LISTVIEW_INFO *infoPtr, HDC hdc, INT nItem, ITERAT
 
             if (cdsubitemmode & CDRF_NOTIFYSUBITEMDRAW)
                 subitemstage = notify_customdraw(infoPtr, CDDS_SUBITEM | CDDS_ITEMPREPAINT, &nmlvcd);
-            else
-            {
-                nmlvcd.clrTextBk = infoPtr->clrTextBk;
-                nmlvcd.clrText   = infoPtr->clrText;
-            }
 
             if (subitems->nItem == 0 || (cdmode & CDRF_NOTIFYITEMDRAW))
                 prepaint_setup(infoPtr, hdc, &nmlvcd, FALSE);
diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c
index c19de7f03f9..a9b853eda85 100644
--- a/dlls/comctl32/tests/listview.c
+++ b/dlls/comctl32/tests/listview.c
@@ -1941,11 +1941,8 @@ static LRESULT WINAPI cd_wndproc(HWND hwnd, UINT message, WPARAM wParam, LPARAM
                 return CDRF_NOTIFYSUBITEMDRAW|CDRF_NOTIFYPOSTPAINT;
             case CDDS_ITEMPREPAINT | CDDS_SUBITEM:
                 clr = GetBkColor(nmlvcd->nmcd.hdc);
-                todo_wine_if(showsel_always && is_selected && nmlvcd->iSubItem)
-                {
-                    ok(nmlvcd->clrTextBk == CLR_DEFAULT, "Unexpected text background %#x.\n", nmlvcd->clrTextBk);
-                    ok(nmlvcd->clrText == RGB(0, 255, 0), "Unexpected text color %#x.\n", nmlvcd->clrText);
-                }
+                ok(nmlvcd->clrTextBk == CLR_DEFAULT, "Unexpected text background %#x.\n", nmlvcd->clrTextBk);
+                ok(nmlvcd->clrText == RGB(0, 255, 0), "Unexpected text color %#x.\n", nmlvcd->clrText);
                 if (showsel_always && is_selected && nmlvcd->iSubItem)
                     ok(clr == GetSysColor(COLOR_3DFACE), "Unexpected background color %#x.\n", clr);
                 else
@@ -1962,11 +1959,8 @@ static LRESULT WINAPI cd_wndproc(HWND hwnd, UINT message, WPARAM wParam, LPARAM
                     ok(clr == c0ffee, "Unexpected background color %#x.\n", clr);
                 }
 
-                todo_wine_if(showsel_always)
-                {
-                    ok(nmlvcd->clrTextBk == CLR_DEFAULT, "Unexpected text background color %#x.\n", nmlvcd->clrTextBk);
-                    ok(nmlvcd->clrText == RGB(0, 255, 0), "got 0x%x\n", nmlvcd->clrText);
-                }
+                ok(nmlvcd->clrTextBk == CLR_DEFAULT, "Unexpected text background color %#x.\n", nmlvcd->clrTextBk);
+                ok(nmlvcd->clrText == RGB(0, 255, 0), "got 0x%x\n", nmlvcd->clrText);
                 return CDRF_DODEFAULT;
             }
             return CDRF_DODEFAULT;
-- 
2.27.0




More information about the wine-devel mailing list