[01/10] comctl32/listview: Draw focus rectangle only when visible

Nikolay Sivov bunglehead at gmail.com
Sun May 24 16:20:02 CDT 2009


http://bugs.winehq.org/show_bug.cgi?id=3235

Focus rectangle is actually updated when a focused item is about to be drawn.
So if a new focused item isn't visible => it won't be repainted => focus rect won't be updated.

There's no need to update it always cause it results in bounding boxes recalculation and
will be done anyway on painting.

Changelog:
    - Draw focus rectangle only when visible

>From e1aed811903bb3ce292addb52c8650200b3510c9 Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <bunglehead at gmail.com>
Date: Sun, 24 May 2009 22:36:14 +0400
Subject: Draw focus rectangle only when visible

---
 dlls/comctl32/listview.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c
index 8ddaf3d..75ce291 100644
--- a/dlls/comctl32/listview.c
+++ b/dlls/comctl32/listview.c
@@ -4305,6 +4305,7 @@ static void LISTVIEW_Refresh(LISTVIEW_INFO *infoPtr, HDC hdc, const RECT *prcEra
     ITERATOR i;
     HDC hdcOrig = hdc;
     HBITMAP hbmp = NULL;
+    RANGE range;
 
     LISTVIEW_DUMP(infoPtr);
 
@@ -4370,11 +4371,11 @@ static void LISTVIEW_Refresh(LISTVIEW_INFO *infoPtr, HDC hdc, const RECT *prcEra
 
     /* figure out what we need to draw */
     iterator_visibleitems(&i, infoPtr, hdc);
-    
+    range = iterator_range(&i);
+
     /* send cache hint notification */
     if (infoPtr->dwStyle & LVS_OWNERDATA)
     {
-    	RANGE range = iterator_range(&i);
 	NMLVCACHEHINT nmlv;
 	
     	ZeroMemory(&nmlv, sizeof(NMLVCACHEHINT));
@@ -4392,8 +4393,9 @@ static void LISTVIEW_Refresh(LISTVIEW_INFO *infoPtr, HDC hdc, const RECT *prcEra
 	else /* LVS_LIST, LVS_ICON or LVS_SMALLICON */
 	    LISTVIEW_RefreshList(infoPtr, &i, hdc, cdmode);
 
-	/* if we have a focus rect, draw it */
-	if (infoPtr->bFocus)
+	/* if we have a focus rect and it's visible, draw it */
+	if (infoPtr->bFocus && range.lower <= infoPtr->nFocusedItem &&
+                        (range.upper - 1) >= infoPtr->nFocusedItem)
 	    LISTVIEW_DrawFocusRect(infoPtr, hdc);
     }
     iterator_destroy(&i);
-- 
1.5.6.5







More information about the wine-patches mailing list