[PATCH v2 0/1] MR1878: comctl32/listview: Draw border and background separately in WM_NCPAINT.
Depending on the theme, if there was a header, the border ends up painted lower than it should be, and clipped by the header. 7-Zip file manager, the reason why the offset was added in 5f0dcf79185941c4faff35d1cc9c758160f3a27d in the first place, still renders correctly. Before:  After:  EDIT1: Actually compared screenshots of 7-Zip file manager and looks like the headers are now painted consistently after highlighting them.   -- v2: comctl32/listview: Exclude header area in WM_NCPAINT. https://gitlab.winehq.org/wine/wine/-/merge_requests/1878
From: Vladislav Timonin <timoninvlad(a)yandex.ru> An improvement of 5f0dcf79185941c4faff35d1cc9c758160f3a27d, which, depending on theme, had an issue with drawing the top border clipped inside the header. --- dlls/comctl32/listview.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c index 7c394d60273..1e9522de012 100644 --- a/dlls/comctl32/listview.c +++ b/dlls/comctl32/listview.c @@ -10712,15 +10712,21 @@ static LRESULT LISTVIEW_NCPaint(const LISTVIEW_INFO *infoPtr, HRGN region) if (region != (HRGN)1) CombineRgn (cliprgn, cliprgn, region, RGN_AND); - OffsetRect(&r, -r.left, -r.top); + dc = GetDCEx(infoPtr->hwndSelf, region, DCX_WINDOW | DCX_INTERSECTRGN); if (infoPtr->hwndHeader && LISTVIEW_IsHeaderEnabled(infoPtr)) { + LONG border_cx, border_cy; + GetWindowRect(infoPtr->hwndHeader, &window_rect); - r.top = min(r.bottom, r.top + window_rect.bottom - window_rect.top); - } + border_cx = window_rect.left - r.left; + border_cy = window_rect.top - r.top; - dc = GetDCEx(infoPtr->hwndSelf, region, DCX_WINDOW|DCX_INTERSECTRGN); + OffsetRect(&window_rect, -window_rect.left, -window_rect.top); + OffsetRect(&window_rect, border_cx, border_cy); + ExcludeClipRect(dc, window_rect.left, window_rect.top, window_rect.right, window_rect.bottom); + } + OffsetRect(&r, -r.left, -r.top); if (IsThemeBackgroundPartiallyTransparent (theme, 0, 0)) DrawThemeParentBackground(infoPtr->hwndSelf, dc, &r); DrawThemeBackground (theme, dc, 0, 0, &r, 0); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/1878
Was pointed out that the `DTBG_OMITCONTENT`/`DTBG_OMITBORDER` approach wasn't handling `BT_IMAGEFILE` quite right. So clipping it is. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/1878#note_20098
Zhiyi Zhang (@zhiyi) commented about dlls/comctl32/listview.c:
- OffsetRect(&r, -r.left, -r.top); + dc = GetDCEx(infoPtr->hwndSelf, region, DCX_WINDOW | DCX_INTERSECTRGN); if (infoPtr->hwndHeader && LISTVIEW_IsHeaderEnabled(infoPtr)) { + LONG border_cx, border_cy; + GetWindowRect(infoPtr->hwndHeader, &window_rect); - r.top = min(r.bottom, r.top + window_rect.bottom - window_rect.top); - } + border_cx = window_rect.left - r.left; + border_cy = window_rect.top - r.top;
- dc = GetDCEx(infoPtr->hwndSelf, region, DCX_WINDOW|DCX_INTERSECTRGN); + OffsetRect(&window_rect, -window_rect.left, -window_rect.top); + OffsetRect(&window_rect, border_cx, border_cy);
These two lines can be replaced with OffsetRect(&window_rect, -r.left, -r.top); and you can remove border_cx/cy. Otherwise, the patch looks good to me. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/1878#note_20110
participants (3)
-
Vladislav Timonin -
Vladislav Timonin (@vt) -
Zhiyi Zhang (@zhiyi)