Signed-off-by: Dmitry Timoshkov dmitry@baikal.ru --- dlls/comctl32/listview.c | 10 ++++++---- dlls/comctl32/tests/listview.c | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c index cd7fec28e27..5c3b1a1636c 100644 --- a/dlls/comctl32/listview.c +++ b/dlls/comctl32/listview.c @@ -4260,11 +4260,12 @@ static BOOL set_main_item(LISTVIEW_INFO *infoPtr, const LVITEMW *lpLVItem, BOOL nmlv.uChanged = uChanged ? uChanged : lpLVItem->mask; nmlv.lParam = item.lParam;
- /* Send LVN_ITEMCHANGING notification, if the item is not being inserted + /* Send LVN_ITEMCHANGING notification if the item is not being + inserted or its state includes LVIS_FOCUSED | LVIS_SELECTED, and we are _NOT_ virtual (LVS_OWNERDATA), and change notifications are enabled. Even nothing really changed we still need to send this, in this case uChanged mask is just set to passed item mask. */ - if (lpItem && !isNew && (infoPtr->notify_mask & NOTIFY_MASK_ITEM_CHANGE)) + if (lpItem && (!isNew || ((uChanged & LVIF_STATE) && (lpLVItem->state & (LVIS_FOCUSED | LVIS_SELECTED)))) && (infoPtr->notify_mask & NOTIFY_MASK_ITEM_CHANGE)) { HWND hwndSelf = infoPtr->hwndSelf;
@@ -4352,8 +4353,9 @@ static BOOL set_main_item(LISTVIEW_INFO *infoPtr, const LVITEMW *lpLVItem, BOOL } }
- /* if we're inserting the item, we're done */ - if (isNew) return TRUE; + /* if we're inserting the item and its state doesn't specify LVIS_FOCUSED | LVIS_SELECTED, we're done */ + if (isNew && !((uChanged & LVIF_STATE) && (lpLVItem->state & (LVIS_FOCUSED | LVIS_SELECTED)))) + return TRUE;
/* send LVN_ITEMCHANGED notification */ if (lpLVItem->mask & LVIF_PARAM) nmlv.lParam = lpLVItem->lParam; diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c index 4c2dd534dbd..92e11685331 100644 --- a/dlls/comctl32/tests/listview.c +++ b/dlls/comctl32/tests/listview.c @@ -6023,7 +6023,7 @@ static void test_LVM_INSERTITEM(void) if ((insert_item[i].mask & LVIF_STATE) && (insert_item[i].state & (LVIS_FOCUSED | LVIS_SELECTED))) { sprintf(buf, "%d: insert focused", i); - ok_sequence(sequences, PARENT_SEQ_INDEX, parent_insert_focused0_seq, buf, TRUE); + ok_sequence(sequences, PARENT_SEQ_INDEX, parent_insert_focused0_seq, buf, insert_item[i].mask != LVIF_STATE); } else { @@ -6060,7 +6060,7 @@ static void test_insertitem(void) item.iSubItem = 0; ret = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM)&item); ok(ret == 0, "got %d\n", ret); - ok_sequence(sequences, PARENT_SEQ_INDEX, parent_insert_focused0_seq, "insert focused 0", TRUE); + ok_sequence(sequences, PARENT_SEQ_INDEX, parent_insert_focused0_seq, "insert focused 0", FALSE);
state = SendMessageA(hwnd, LVM_GETITEMSTATE, 0, LVIS_FOCUSED); ok(state == LVIS_FOCUSED, "got %x\n", state); @@ -6073,7 +6073,7 @@ static void test_insertitem(void) item.iSubItem = 0; ret = SendMessageA(hwnd, LVM_INSERTITEMA, 0, (LPARAM)&item); ok(ret == 1, "got %d\n", ret); - ok_sequence(sequences, PARENT_SEQ_INDEX, parent_insert_focused1_seq, "insert focused 1", TRUE); + ok_sequence(sequences, PARENT_SEQ_INDEX, parent_insert_focused1_seq, "insert focused 1", FALSE);
state = SendMessageA(hwnd, LVM_GETITEMSTATE, 1, LVIS_FOCUSED); ok(state == LVIS_FOCUSED, "got %x\n", state);
Does attached patch work for you? It moves condition to a single place, and simplifies CHANGED message path a bit.
Nikolay Sivov nsivov@codeweavers.com wrote:
Does attached patch work for you? It moves condition to a single place, and simplifies CHANGED message path a bit.
Thanks for keeping working at this.
Since this patch also fixes the tests it should also work the application that I have here. The simplification looks good to me.