From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/user32/listbox.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/dlls/user32/listbox.c b/dlls/user32/listbox.c index 286a33b1c1..3eee691086 100644 --- a/dlls/user32/listbox.c +++ b/dlls/user32/listbox.c @@ -120,6 +120,11 @@ static TIMER_DIRECTION LISTBOX_Timer = LB_TIMER_NONE;
static LRESULT LISTBOX_GetItemRect( const LB_DESCR *descr, INT index, RECT *rect );
+static BOOL is_item_selected( const LB_DESCR *descr, UINT index ) +{ + return descr->items[index].selected; +} + /********************************************************************* * listbox class descriptor */ @@ -2866,7 +2871,7 @@ LRESULT ListBoxWndProc_common( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam case LB_GETSEL: if (((INT)wParam < 0) || ((INT)wParam >= descr->nb_items)) return LB_ERR; - return descr->items[wParam].selected; + return is_item_selected(descr, wParam);
case LB_SETSEL: ret = LISTBOX_SetSelection( descr, lParam, wParam, FALSE );
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/user32/listbox.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/dlls/user32/listbox.c b/dlls/user32/listbox.c index 3eee691086..6dbf8d9c4f 100644 --- a/dlls/user32/listbox.c +++ b/dlls/user32/listbox.c @@ -516,7 +516,13 @@ static void LISTBOX_PaintItem( LB_DESCR *descr, HDC hdc, const RECT *rect, INT index, UINT action, BOOL ignoreFocus ) { LB_ITEMDATA *item = NULL; - if (index < descr->nb_items) item = &descr->items[index]; + BOOL selected = FALSE; + + if (index < descr->nb_items) + { + item = &descr->items[index]; + selected = is_item_selected(descr, index); + }
if (IS_OWNERDRAW(descr)) { @@ -547,7 +553,8 @@ static void LISTBOX_PaintItem( LB_DESCR *descr, HDC hdc, const RECT *rect, dis.hDC = hdc; dis.itemID = index; dis.itemState = 0; - if (item->selected) dis.itemState |= ODS_SELECTED; + if (selected) + dis.itemState |= ODS_SELECTED; if (!ignoreFocus && (descr->focus_item == index) && (descr->caret_on) && (descr->in_focus)) dis.itemState |= ODS_FOCUS; @@ -570,7 +577,7 @@ static void LISTBOX_PaintItem( LB_DESCR *descr, HDC hdc, const RECT *rect, DrawFocusRect( hdc, rect ); return; } - if (item && item->selected) + if (selected) { oldBk = SetBkColor( hdc, GetSysColor( COLOR_HIGHLIGHT ) ); oldText = SetTextColor( hdc, GetSysColor(COLOR_HIGHLIGHTTEXT)); @@ -595,7 +602,7 @@ static void LISTBOX_PaintItem( LB_DESCR *descr, HDC hdc, const RECT *rect, item->str, strlenW(item->str), descr->nb_tabs, descr->tabs, 0); } - if (item && item->selected) + if (selected) { SetBkColor( hdc, oldBk ); SetTextColor( hdc, oldText );
Hi,
While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=45349
Your paranoid android.
=== debian9 (32 bit Chinese:China report) ===
user32: clipboard.c:760: Test failed: 2: gle 5 clipboard.c:765: Test failed: 2.0: got 0000 instead of 000d clipboard.c:805: Test failed: 2: gle 1418 clipboard.c:815: Test failed: 2: count 4 clipboard.c:818: Test failed: 2: gle 1418 clipboard.c:833: Test failed: 2: gle 5 clipboard.c:838: Test failed: 2.0: got 0000 instead of 000d clipboard.c:868: Test failed: 2: gle 1418 clipboard.c:717: Test failed: 3: gle 5 clipboard.c:719: Test failed: 3: gle 1418 clipboard.c:746: Test failed: 3: count 4 clipboard.c:749: Test failed: 3: gle 1418 clipboard.c:755: Test failed: 3: 000e not available clipboard.c:755: Test failed: 3: 0003 not available clipboard.c:757: Test failed: 3: count 4 instead of 2 clipboard.c:765: Test failed: 3.0: got 000d instead of 000e
=== debian9 (32 bit WoW report) ===
user32: input.c:2054: Test failed: expected WM_NCHITTEST message
=== debian9 (64 bit WoW report) ===
user32: clipboard.c:833: Test failed: 4: gle 5 clipboard.c:838: Test failed: 4.0: got 0000 instead of 0003 clipboard.c:868: Test failed: 4: gle 1418
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/user32/listbox.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/dlls/user32/listbox.c b/dlls/user32/listbox.c index 6dbf8d9c4f..6a33f81df5 100644 --- a/dlls/user32/listbox.c +++ b/dlls/user32/listbox.c @@ -515,8 +515,8 @@ static INT LISTBOX_GetItemFromPoint( const LB_DESCR *descr, INT x, INT y ) static void LISTBOX_PaintItem( LB_DESCR *descr, HDC hdc, const RECT *rect, INT index, UINT action, BOOL ignoreFocus ) { + BOOL selected = FALSE, focused; LB_ITEMDATA *item = NULL; - BOOL selected = FALSE;
if (index < descr->nb_items) { @@ -524,6 +524,8 @@ static void LISTBOX_PaintItem( LB_DESCR *descr, HDC hdc, const RECT *rect, selected = is_item_selected(descr, index); }
+ focused = !ignoreFocus && descr->focus_item == index && descr->caret_on && descr->in_focus; + if (IS_OWNERDRAW(descr)) { DRAWITEMSTRUCT dis; @@ -555,9 +557,8 @@ static void LISTBOX_PaintItem( LB_DESCR *descr, HDC hdc, const RECT *rect, dis.itemState = 0; if (selected) dis.itemState |= ODS_SELECTED; - if (!ignoreFocus && (descr->focus_item == index) && - (descr->caret_on) && - (descr->in_focus)) dis.itemState |= ODS_FOCUS; + if (focused) + dis.itemState |= ODS_FOCUS; if (!IsWindowEnabled(descr->self)) dis.itemState |= ODS_DISABLED; dis.itemData = item->data; dis.rcItem = *rect; @@ -607,9 +608,8 @@ static void LISTBOX_PaintItem( LB_DESCR *descr, HDC hdc, const RECT *rect, SetBkColor( hdc, oldBk ); SetTextColor( hdc, oldText ); } - if (!ignoreFocus && (descr->focus_item == index) && - (descr->caret_on) && - (descr->in_focus)) DrawFocusRect( hdc, rect ); + if (focused) + DrawFocusRect( hdc, rect ); } }
From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/user32/listbox.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dlls/user32/listbox.c b/dlls/user32/listbox.c index 6a33f81df5..b104bfd47b 100644 --- a/dlls/user32/listbox.c +++ b/dlls/user32/listbox.c @@ -560,10 +560,10 @@ static void LISTBOX_PaintItem( LB_DESCR *descr, HDC hdc, const RECT *rect, if (focused) dis.itemState |= ODS_FOCUS; if (!IsWindowEnabled(descr->self)) dis.itemState |= ODS_DISABLED; - dis.itemData = item->data; + dis.itemData = item ? item->data : 0; dis.rcItem = *rect; TRACE("[%p]: drawitem %d (%s) action=%02x state=%02x rect=%s\n", - descr->self, index, debugstr_w(item->str), action, + descr->self, index, item ? debugstr_w(item->str) : "", action, dis.itemState, wine_dbgstr_rect(rect) ); SendMessageW(descr->owner, WM_DRAWITEM, dis.CtlID, (LPARAM)&dis); SelectClipRgn( hdc, hrgn );
Hi,
While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=45351
Your paranoid android.
=== debian9 (32 bit Chinese:China report) ===
user32: clipboard.c:760: Test failed: 6: gle 5 clipboard.c:765: Test failed: 6.0: got 0000 instead of 0008 clipboard.c:805: Test failed: 6: gle 1418 clipboard.c:815: Test failed: 6: count 3 clipboard.c:818: Test failed: 6: gle 1418 clipboard.c:852: Test failed: 6: format 0008 got data 0x1294d8 clipboard.c:853: Test failed: 6.0: formats 00000000 have been rendered clipboard.c:858: Test failed: 6.0: formats 00000000 have been rendered clipboard.c:852: Test failed: 6: format 0002 got data 0x50045 clipboard.c:853: Test failed: 6.1: formats 00000000 have been rendered clipboard.c:858: Test failed: 6.1: formats 00000000 have been rendered clipboard.c:852: Test failed: 6: format 0011 got data 0x129d60 clipboard.c:853: Test failed: 6.2: formats 00000000 have been rendered clipboard.c:858: Test failed: 6.2: formats 00000000 have been rendered
=== debian9 (64 bit WoW report) ===
user32: menu.c:2354: Test failed: test 30 menu: Timeout
From: Gabriel Ivăncescu gabrielopcode@gmail.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/user32/listbox.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/dlls/user32/listbox.c b/dlls/user32/listbox.c index b104bfd47b..594c956b94 100644 --- a/dlls/user32/listbox.c +++ b/dlls/user32/listbox.c @@ -67,6 +67,7 @@ typedef struct INT height; /* Window height */ LB_ITEMDATA *items; /* Array of items */ INT nb_items; /* Number of items */ + UINT items_size; /* Total number of allocated items in the array */ INT top_item; /* Top visible item */ INT selected_item; /* Selected item */ INT focus_item; /* Item that has the focus */ @@ -713,7 +714,7 @@ static LRESULT LISTBOX_InitStorage( LB_DESCR *descr, INT nb_items ) nb_items += LB_ARRAY_GRANULARITY - 1; nb_items -= (nb_items % LB_ARRAY_GRANULARITY); if (descr->items) { - nb_items += HeapSize( GetProcessHeap(), 0, descr->items ) / sizeof(*item); + nb_items += descr->items_size; item = HeapReAlloc( GetProcessHeap(), 0, descr->items, nb_items * sizeof(LB_ITEMDATA)); } @@ -727,6 +728,7 @@ static LRESULT LISTBOX_InitStorage( LB_DESCR *descr, INT nb_items ) SEND_NOTIFICATION( descr, LBN_ERRSPACE ); return LB_ERRSPACE; } + descr->items_size = nb_items; descr->items = item; return LB_OKAY; } @@ -1537,12 +1539,10 @@ static LRESULT LISTBOX_InsertItem( LB_DESCR *descr, INT index,
if (index == -1) index = descr->nb_items; else if ((index < 0) || (index > descr->nb_items)) return LB_ERR; - if (!descr->items) max_items = 0; - else max_items = HeapSize( GetProcessHeap(), 0, descr->items ) / sizeof(*item); - if (descr->nb_items == max_items) + if (descr->nb_items == descr->items_size) { /* We need to grow the array */ - max_items += LB_ARRAY_GRANULARITY; + max_items = descr->items_size + LB_ARRAY_GRANULARITY; if (descr->items) item = HeapReAlloc( GetProcessHeap(), 0, descr->items, max_items * sizeof(LB_ITEMDATA) ); @@ -1554,6 +1554,7 @@ static LRESULT LISTBOX_InsertItem( LB_DESCR *descr, INT index, SEND_NOTIFICATION( descr, LBN_ERRSPACE ); return LB_ERRSPACE; } + descr->items_size = max_items; descr->items = item; }
@@ -1713,13 +1714,17 @@ static LRESULT LISTBOX_RemoveItem( LB_DESCR *descr, INT index )
/* Shrink the item array if possible */
- max_items = HeapSize( GetProcessHeap(), 0, descr->items ) / sizeof(LB_ITEMDATA); + max_items = descr->items_size; if (descr->nb_items < max_items - 2*LB_ARRAY_GRANULARITY) { max_items -= LB_ARRAY_GRANULARITY; item = HeapReAlloc( GetProcessHeap(), 0, descr->items, max_items * sizeof(LB_ITEMDATA) ); - if (item) descr->items = item; + if (item) + { + descr->items_size = max_items; + descr->items = item; + } } /* Repaint the items */
@@ -1765,6 +1770,7 @@ static void LISTBOX_ResetContent( LB_DESCR *descr ) descr->selected_item = -1; descr->focus_item = 0; descr->anchor_item = -1; + descr->items_size = 0; descr->items = NULL; }
@@ -2506,6 +2512,7 @@ static BOOL LISTBOX_Create( HWND hwnd, LPHEADCOMBO lphc ) descr->width = rect.right - rect.left; descr->height = rect.bottom - rect.top; descr->items = NULL; + descr->items_size = 0; descr->nb_items = 0; descr->top_item = 0; descr->selected_item = -1;
Hi,
While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=45348
Your paranoid android.
=== debian9 (32 bit report) ===
user32: msg.c:8713: Test failed: WaitForSingleObject failed 102 msg.c:8719: Test failed: destroy child on thread exit: 0: the msg 0x0082 was expected, but got msg 0x000f instead msg.c:8719: Test failed: destroy child on thread exit: 1: the msg 0x000f was expected, but got msg 0x0014 instead msg.c:8719: Test failed: destroy child on thread exit: 2: the msg sequence is not complete: expected 0014 - actual 0000
=== debian9 (32 bit Chinese:China report) ===
user32: msg.c:8713: Test failed: WaitForSingleObject failed 102 msg.c:8719: Test failed: destroy child on thread exit: 0: the msg 0x0082 was expected, but got msg 0x000f instead msg.c:8719: Test failed: destroy child on thread exit: 1: the msg 0x000f was expected, but got msg 0x0014 instead msg.c:8719: Test failed: destroy child on thread exit: 2: the msg sequence is not complete: expected 0014 - actual 0000