From b68e95abd86a3db26f873d37f6317f3ad68763c6 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Fri, 11 Jan 2013 03:06:27 +0400 Subject: [PATCH] comctl32/listview: Add a special case for deselect all attempt when nothing is selected. --- dlls/comctl32/listview.c | 4 ++++ dlls/comctl32/tests/listview.c | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c index 79d55da964..bb6d1b224f 100644 --- a/dlls/comctl32/listview.c +++ b/dlls/comctl32/listview.c @@ -8857,6 +8857,10 @@ static BOOL LISTVIEW_SetItemState(LISTVIEW_INFO *infoPtr, INT nItem, const LVITE UINT oldstate = 0; BOOL notify; + /* special case optimization for recurring attemp to deselect all */ + if (lvItem.state == 0 && lvItem.stateMask == LVIS_SELECTED && !LISTVIEW_GetSelectedCount(infoPtr)) + return TRUE; + /* select all isn't allowed in LVS_SINGLESEL */ if ((lvItem.state & lvItem.stateMask & LVIS_SELECTED) && (infoPtr->dwStyle & LVS_SINGLESEL)) return FALSE; diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c index 25321c3f97..cff6e9268e 100644 --- a/dlls/comctl32/tests/listview.c +++ b/dlls/comctl32/tests/listview.c @@ -2271,7 +2271,7 @@ static void test_multiselect(void) item.state = 0; item.stateMask = LVIS_SELECTED; SendMessageA(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item); - ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq, "deselect all notification 2", TRUE); + ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq, "deselect all notification 2", FALSE); /* any non-zero state value does the same */ flush_sequences(sequences, NUM_MSG_SEQUENCES); @@ -3111,7 +3111,7 @@ static void test_ownerdata(void) res = SendMessageA(hwnd, LVM_SETITEMSTATE, -1, (LPARAM)&item); expect(TRUE, res); - ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq, "ownerdata deselect all notification", TRUE); + ok_sequence(sequences, PARENT_SEQ_INDEX, empty_seq, "ownerdata deselect all notification", FALSE); /* select one, then deselect all */ item.stateMask = LVIS_SELECTED; -- 2.32.0.93.g670b81a890