From c18c7332b839a561bacd2ca8f255f98c20e32e30 Mon Sep 17 00:00:00 2001 From: "Dimitrie O. Paun" Date: Thu, 17 Oct 2002 21:55:41 +0000 Subject: [PATCH] Instrument SetItemT to change only _one_ item at a time. That is, if we have to change focus, we call it recursively to first remove the focus from the item that has it. This allows simpler, and more correct invalidation handling. --- dlls/comctl32/listview.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c index 899ca883223..33ac8dd4e01 100644 --- a/dlls/comctl32/listview.c +++ b/dlls/comctl32/listview.c @@ -2557,7 +2557,9 @@ static inline BOOL LISTVIEW_SetItemFocus(LISTVIEW_INFO *infoPtr, INT nItem) INT oldFocus = infoPtr->nFocusedItem; LVITEMW lvItem; - lvItem.state = LVIS_FOCUSED; + if (nItem == infoPtr->nFocusedItem) return FALSE; + + lvItem.state = nItem == -1 ? 0 : LVIS_FOCUSED; lvItem.stateMask = LVIS_FOCUSED; LISTVIEW_SetItemState(infoPtr, nItem, &lvItem); @@ -2979,6 +2981,7 @@ static BOOL set_main_item(LISTVIEW_INFO *infoPtr, LPLVITEMW lpLVItem, BOOL isW, { if (lpLVItem->state & LVIS_FOCUSED) { + LISTVIEW_SetItemFocus(infoPtr, -1); infoPtr->nFocusedItem = lpLVItem->iItem; LISTVIEW_EnsureVisible(infoPtr, lpLVItem->iItem, FALSE); } @@ -3087,7 +3090,6 @@ static BOOL set_sub_item(LISTVIEW_INFO *infoPtr, LPLVITEMW lpLVItem, BOOL isW, B static BOOL LISTVIEW_SetItemT(LISTVIEW_INFO *infoPtr, LPLVITEMW lpLVItem, BOOL isW) { UINT uView = infoPtr->dwStyle & LVS_TYPEMASK; - INT nOldFocus = infoPtr->nFocusedItem; LPWSTR pszText = NULL; BOOL bResult, bChanged = FALSE; @@ -3116,9 +3118,6 @@ static BOOL LISTVIEW_SetItemT(LISTVIEW_INFO *infoPtr, LPLVITEMW lpLVItem, BOOL i /* redraw item, if necessary */ if (bChanged && !infoPtr->bIsDrawing) { - if (nOldFocus != infoPtr->nFocusedItem && infoPtr->bFocus) - LISTVIEW_InvalidateRect(infoPtr, &infoPtr->rcFocus); - /* this little optimization eliminates some nasty flicker */ if ( uView == LVS_REPORT && !(infoPtr->dwStyle & LVS_OWNERDRAWFIXED) && (!(infoPtr->dwLvExStyle & LVS_EX_FULLROWSELECT) || lpLVItem->iSubItem) )