Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/user32/combo.c | 163 +++++++++++++++----------------------------- 1 file changed, 55 insertions(+), 108 deletions(-)
diff --git a/dlls/user32/combo.c b/dlls/user32/combo.c index 4ddccd6c95..07d53f7341 100644 --- a/dlls/user32/combo.c +++ b/dlls/user32/combo.c @@ -319,111 +319,70 @@ static void CBForceDummyResize( * * Set up component coordinates given valid lphc->RectCombo. */ -static void CBCalcPlacement( - HWND hwnd, - LPHEADCOMBO lphc, - LPRECT lprEdit, - LPRECT lprButton, - LPRECT lprLB) +static void CBCalcPlacement(HEADCOMBO *combo) { - /* - * Again, start with the client rectangle. - */ - GetClientRect(hwnd, lprEdit); + /* Start with the client rectangle. */ + GetClientRect(combo->self, &combo->textRect);
- /* - * Remove the borders - */ - InflateRect(lprEdit, -COMBO_XBORDERSIZE(), -COMBO_YBORDERSIZE()); + /* Remove the borders */ + InflateRect(&combo->textRect, -COMBO_XBORDERSIZE(), -COMBO_YBORDERSIZE());
- /* - * Chop off the bottom part to fit with the height of the text area. - */ - lprEdit->bottom = lprEdit->top + CBGetTextAreaHeight(hwnd, lphc); - - /* - * The button starts the same vertical position as the text area. - */ - CopyRect(lprButton, lprEdit); + /* Chop off the bottom part to fit with the height of the text area. */ + combo->textRect.bottom = combo->textRect.top + CBGetTextAreaHeight(combo->self, combo);
- /* - * If the combobox is "simple" there is no button. - */ - if( CB_GETTYPE(lphc) == CBS_SIMPLE ) - lprButton->left = lprButton->right = lprButton->bottom = 0; - else - { - /* - * Let's assume the combobox button is the same width as the - * scrollbar button. - * size the button horizontally and cut-off the text area. - */ - lprButton->left = lprButton->right - GetSystemMetrics(SM_CXVSCROLL); - lprEdit->right = lprButton->left; - } + /* The button starts the same vertical position as the text area. */ + combo->buttonRect = combo->textRect;
- /* - * In the case of a dropdown, there is an additional spacing between the - * text area and the button. - */ - if( CB_GETTYPE(lphc) == CBS_DROPDOWN ) - { - lprEdit->right -= COMBO_EDITBUTTONSPACE(); - } + /* If the combobox is "simple" there is no button. */ + if (CB_GETTYPE(combo) == CBS_SIMPLE) + combo->buttonRect.left = combo->buttonRect.right = combo->buttonRect.bottom = 0; + else + { + /* + * Let's assume the combobox button is the same width as the + * scrollbar button. + * size the button horizontally and cut-off the text area. + */ + combo->buttonRect.left = combo->buttonRect.right - GetSystemMetrics(SM_CXVSCROLL); + combo->textRect.right = combo->buttonRect.left; + }
- /* - * If we have an edit control, we space it away from the borders slightly. - */ - if (CB_GETTYPE(lphc) != CBS_DROPDOWNLIST) - { - InflateRect(lprEdit, -EDIT_CONTROL_PADDING(), -EDIT_CONTROL_PADDING()); - } + /* In the case of a dropdown, there is an additional spacing between the text area and the button. */ + if (CB_GETTYPE(combo) == CBS_DROPDOWN) + combo->textRect.right -= COMBO_EDITBUTTONSPACE();
- /* - * Adjust the size of the listbox popup. - */ - if( CB_GETTYPE(lphc) == CBS_SIMPLE ) - { - /* - * Use the client rectangle to initialize the listbox rectangle - */ - GetClientRect(hwnd, lprLB); + /* If we have an edit control, we space it away from the borders slightly. */ + if (CB_GETTYPE(combo) != CBS_DROPDOWNLIST) + InflateRect(&combo->textRect, -EDIT_CONTROL_PADDING(), -EDIT_CONTROL_PADDING());
- /* - * Then, chop-off the top part. - */ - lprLB->top = lprEdit->bottom + COMBO_YBORDERSIZE(); - } - else - { - /* - * Make sure the dropped width is as large as the combobox itself. - */ - if (lphc->droppedWidth < (lprButton->right + COMBO_XBORDERSIZE())) + /* Adjust the size of the listbox popup. */ + if (CB_GETTYPE(combo) == CBS_SIMPLE) { - lprLB->right = lprLB->left + (lprButton->right + COMBO_XBORDERSIZE()); - - /* - * In the case of a dropdown, the popup listbox is offset to the right. - * so, we want to make sure it's flush with the right side of the - * combobox - */ - if( CB_GETTYPE(lphc) == CBS_DROPDOWN ) - lprLB->right -= COMBO_EDITBUTTONSPACE(); + GetClientRect(combo->self, &combo->droppedRect); + combo->droppedRect.top = combo->textRect.bottom + COMBO_YBORDERSIZE(); } else - lprLB->right = lprLB->left + lphc->droppedWidth; - } - - /* don't allow negative window width */ - if (lprEdit->right < lprEdit->left) - lprEdit->right = lprEdit->left; + { + /* Make sure the dropped width is as large as the combobox itself. */ + if (combo->droppedWidth < (combo->buttonRect.right + COMBO_XBORDERSIZE())) + { + combo->droppedRect.right = combo->droppedRect.left + (combo->buttonRect.right + COMBO_XBORDERSIZE());
- TRACE("\ttext\t= (%s)\n", wine_dbgstr_rect(lprEdit)); + /* In the case of a dropdown, the popup listbox is offset to the right. We want to make sure it's flush + with the right side of the combobox. */ + if (CB_GETTYPE(combo) == CBS_DROPDOWN) + combo->droppedRect.right -= COMBO_EDITBUTTONSPACE(); + } + else + combo->droppedRect.right = combo->droppedRect.left + combo->droppedWidth; + }
- TRACE("\tbutton\t= (%s)\n", wine_dbgstr_rect(lprButton)); + /* Disallow negative window width */ + if (combo->textRect.right < combo->textRect.left) + combo->textRect.right = combo->textRect.left;
- TRACE("\tlbox\t= (%s)\n", wine_dbgstr_rect(lprLB)); + TRACE("text %s, button %s, lbox %s.\n", wine_dbgstr_rect(&combo->textRect), wine_dbgstr_rect(&combo->buttonRect), + wine_dbgstr_rect(&combo->droppedRect)); }
/*********************************************************************** @@ -479,7 +438,7 @@ static LRESULT COMBO_Create( HWND hwnd, LPHEADCOMBO lphc, HWND hwndParent, LONG * recalculated. */ GetClientRect( hwnd, &lphc->droppedRect ); - CBCalcPlacement(hwnd, lphc, &lphc->textRect, &lphc->buttonRect, &lphc->droppedRect ); + CBCalcPlacement(lphc);
/* * Adjust the position of the popup listbox if it's necessary @@ -1530,11 +1489,7 @@ static void COMBO_Size( LPHEADCOMBO lphc ) SWP_NOZORDER|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOREDRAW); }
- CBCalcPlacement(lphc->self, - lphc, - &lphc->textRect, - &lphc->buttonRect, - &lphc->droppedRect); + CBCalcPlacement(lphc);
CBResetPos( lphc, &lphc->textRect, &lphc->droppedRect, FALSE ); } @@ -1562,11 +1517,7 @@ static void COMBO_Font( LPHEADCOMBO lphc, HFONT hFont, BOOL bRedraw ) */ if ( CB_GETTYPE(lphc) == CBS_SIMPLE) { - CBCalcPlacement(lphc->self, - lphc, - &lphc->textRect, - &lphc->buttonRect, - &lphc->droppedRect); + CBCalcPlacement(lphc);
CBResetPos( lphc, &lphc->textRect, &lphc->droppedRect, TRUE ); } @@ -1595,11 +1546,7 @@ static LRESULT COMBO_SetItemHeight( LPHEADCOMBO lphc, INT index, INT height ) */ if ( CB_GETTYPE(lphc) == CBS_SIMPLE) { - CBCalcPlacement(lphc->self, - lphc, - &lphc->textRect, - &lphc->buttonRect, - &lphc->droppedRect); + CBCalcPlacement(lphc);
CBResetPos( lphc, &lphc->textRect, &lphc->droppedRect, TRUE ); } @@ -2100,7 +2047,7 @@ LRESULT ComboWndProc_common( HWND hwnd, UINT message, WPARAM wParam, LPARAM lPar lphc->droppedWidth = 0;
/* recalculate the combobox area */ - CBCalcPlacement(hwnd, lphc, &lphc->textRect, &lphc->buttonRect, &lphc->droppedRect ); + CBCalcPlacement(lphc);
/* fall through */ case CB_GETDROPPEDWIDTH:
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/user32/combo.c | 67 ++++++++++++++++++++------------------------- 1 file changed, 29 insertions(+), 38 deletions(-)
diff --git a/dlls/user32/combo.c b/dlls/user32/combo.c index 07d53f7341..d0affc0618 100644 --- a/dlls/user32/combo.c +++ b/dlls/user32/combo.c @@ -1408,45 +1408,36 @@ static LRESULT COMBO_GetTextA( LPHEADCOMBO lphc, INT count, LPSTR buf ) * This function sets window positions according to the updated * component placement struct. */ -static void CBResetPos( - LPHEADCOMBO lphc, - const RECT *rectEdit, - const RECT *rectLB, - BOOL bRedraw) +static void CBResetPos(HEADCOMBO *combo, BOOL redraw) { - BOOL bDrop = (CB_GETTYPE(lphc) != CBS_SIMPLE); - - /* NOTE: logs sometimes have WM_LBUTTONUP before a cascade of - * sizing messages */ - - if( lphc->wState & CBF_EDIT ) - SetWindowPos( lphc->hWndEdit, 0, - rectEdit->left, rectEdit->top, - rectEdit->right - rectEdit->left, - rectEdit->bottom - rectEdit->top, - SWP_NOZORDER | SWP_NOACTIVATE | ((bDrop) ? SWP_NOREDRAW : 0) ); - - SetWindowPos( lphc->hWndLBox, 0, - rectLB->left, rectLB->top, - rectLB->right - rectLB->left, - rectLB->bottom - rectLB->top, - SWP_NOACTIVATE | SWP_NOZORDER | ((bDrop) ? SWP_NOREDRAW : 0) ); - - if( bDrop ) - { - if( lphc->wState & CBF_DROPPED ) - { - lphc->wState &= ~CBF_DROPPED; - ShowWindow( lphc->hWndLBox, SW_HIDE ); - } + BOOL drop = CB_GETTYPE(combo) != CBS_SIMPLE; + + /* NOTE: logs sometimes have WM_LBUTTONUP before a cascade of + * sizing messages */ + if (combo->wState & CBF_EDIT) + SetWindowPos(combo->hWndEdit, 0, combo->textRect.left, combo->textRect.top, + combo->textRect.right - combo->textRect.left, + combo->textRect.bottom - combo->textRect.top, + SWP_NOZORDER | SWP_NOACTIVATE | (drop ? SWP_NOREDRAW : 0)); + + SetWindowPos(combo->hWndLBox, 0, combo->droppedRect.left, combo->droppedRect.top, + combo->droppedRect.right - combo->droppedRect.left, + combo->droppedRect.bottom - combo->droppedRect.top, + SWP_NOACTIVATE | SWP_NOZORDER | (drop ? SWP_NOREDRAW : 0)); + + if (drop) + { + if (combo->wState & CBF_DROPPED) + { + combo->wState &= ~CBF_DROPPED; + ShowWindow(combo->hWndLBox, SW_HIDE); + }
- if( bRedraw && !(lphc->wState & CBF_NOREDRAW) ) - RedrawWindow( lphc->self, NULL, 0, - RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW ); - } + if (redraw && !(combo->wState & CBF_NOREDRAW)) + RedrawWindow(combo->self, NULL, 0, RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW); + } }
- /*********************************************************************** * COMBO_Size */ @@ -1491,7 +1482,7 @@ static void COMBO_Size( LPHEADCOMBO lphc )
CBCalcPlacement(lphc);
- CBResetPos( lphc, &lphc->textRect, &lphc->droppedRect, FALSE ); + CBResetPos(lphc, FALSE); }
@@ -1519,7 +1510,7 @@ static void COMBO_Font( LPHEADCOMBO lphc, HFONT hFont, BOOL bRedraw ) { CBCalcPlacement(lphc);
- CBResetPos( lphc, &lphc->textRect, &lphc->droppedRect, TRUE ); + CBResetPos(lphc, TRUE); } else { @@ -1548,7 +1539,7 @@ static LRESULT COMBO_SetItemHeight( LPHEADCOMBO lphc, INT index, INT height ) { CBCalcPlacement(lphc);
- CBResetPos( lphc, &lphc->textRect, &lphc->droppedRect, TRUE ); + CBResetPos(lphc, TRUE); } else {
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/user32/combo.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-)
diff --git a/dlls/user32/combo.c b/dlls/user32/combo.c index d0affc0618..40ff0ef521 100644 --- a/dlls/user32/combo.c +++ b/dlls/user32/combo.c @@ -193,9 +193,7 @@ static LRESULT COMBO_NCDestroy( LPHEADCOMBO lphc ) * This height was determined through experimentation. * CBCalcPlacement will add 2*COMBO_YBORDERSIZE pixels for the border */ -static INT CBGetTextAreaHeight( - HWND hwnd, - LPHEADCOMBO lphc) +static INT CBGetTextAreaHeight(HEADCOMBO *lphc) { INT iTextItemHeight;
@@ -206,7 +204,7 @@ static INT CBGetTextAreaHeight( else { TEXTMETRICW tm; - HDC hDC = GetDC(hwnd); + HDC hDC = GetDC(lphc->self); HFONT hPrevFont = 0; INT baseUnitY;
@@ -220,7 +218,7 @@ static INT CBGetTextAreaHeight( if( hPrevFont ) SelectObject( hDC, hPrevFont );
- ReleaseDC(hwnd, hDC); + ReleaseDC(lphc->self, hDC);
iTextItemHeight = baseUnitY + 4; } @@ -240,7 +238,7 @@ static INT CBGetTextAreaHeight( /* * We use the client rect for the width of the item. */ - GetClientRect(hwnd, &clientRect); + GetClientRect(lphc->self, &clientRect);
lphc->wState &= ~CBF_MEASUREITEM;
@@ -294,7 +292,7 @@ static void CBForceDummyResize( RECT windowRect; int newComboHeight;
- newComboHeight = CBGetTextAreaHeight(lphc->self,lphc) + 2*COMBO_YBORDERSIZE(); + newComboHeight = CBGetTextAreaHeight(lphc) + 2*COMBO_YBORDERSIZE();
GetWindowRect(lphc->self, &windowRect);
@@ -328,7 +326,7 @@ static void CBCalcPlacement(HEADCOMBO *combo) InflateRect(&combo->textRect, -COMBO_XBORDERSIZE(), -COMBO_YBORDERSIZE());
/* Chop off the bottom part to fit with the height of the text area. */ - combo->textRect.bottom = combo->textRect.top + CBGetTextAreaHeight(combo->self, combo); + combo->textRect.bottom = combo->textRect.top + CBGetTextAreaHeight(combo);
/* The button starts the same vertical position as the text area. */ combo->buttonRect = combo->textRect; @@ -1455,7 +1453,7 @@ static void COMBO_Size( LPHEADCOMBO lphc ) GetWindowRect(lphc->self, &rc); curComboHeight = rc.bottom - rc.top; curComboWidth = rc.right - rc.left; - newComboHeight = CBGetTextAreaHeight(lphc->self, lphc) + 2*COMBO_YBORDERSIZE(); + newComboHeight = CBGetTextAreaHeight(lphc) + 2*COMBO_YBORDERSIZE();
/* * Resizing a combobox has another side effect, it resizes the dropped @@ -2004,7 +2002,7 @@ LRESULT ComboWndProc_common( HWND hwnd, UINT message, WPARAM wParam, LPARAM lPar case CB_GETITEMHEIGHT: if( (INT)wParam >= 0 ) /* listbox item */ return SendMessageW(lphc->hWndLBox, LB_GETITEMHEIGHT, wParam, 0); - return CBGetTextAreaHeight(hwnd, lphc); + return CBGetTextAreaHeight(lphc); case CB_RESETCONTENT: SendMessageW(lphc->hWndLBox, LB_RESETCONTENT, 0, 0); if( (lphc->wState & CBF_EDIT) && CB_HASSTRINGS(lphc) )
Hi,
While running your changed tests, 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=60866
Your paranoid android.
=== debian10 (64 bit WoW report) ===
user32: clipboard.c:833: Test failed: 0: gle 5 clipboard.c:838: Test failed: 0.0: got 0000 instead of 0001 clipboard.c:868: Test failed: 0: gle 1418 clipboard.c:717: Test failed: 1: gle 5 clipboard.c:719: Test failed: 1: gle 1418 clipboard.c:746: Test failed: 1: count 4 clipboard.c:749: Test failed: 1: gle 1418 clipboard.c:760: Test failed: 1: gle 5 clipboard.c:765: Test failed: 1.0: got 0000 instead of 0007 clipboard.c:805: Test failed: 1: gle 1418 clipboard.c:815: Test failed: 1: count 4 clipboard.c:818: Test failed: 1: gle 1418 clipboard.c:833: Test failed: 1: gle 5 clipboard.c:838: Test failed: 1.0: got 0000 instead of 0007 clipboard.c:868: Test failed: 1: gle 1418 clipboard.c:717: Test failed: 2: gle 5 clipboard.c:719: Test failed: 2: gle 1418 clipboard.c:746: Test failed: 2: count 4 clipboard.c:749: Test failed: 2: gle 1418 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 5 clipboard.c:749: Test failed: 3: gle 1418 clipboard.c:755: Test failed: 3: 0003 not available clipboard.c:757: Test failed: 3: count 5 instead of 2 clipboard.c:760: Test failed: 3: gle 5 clipboard.c:765: Test failed: 3.0: got 0000 instead of 000e clipboard.c:805: Test failed: 3: gle 1418 clipboard.c:815: Test failed: 3: count 5 clipboard.c:818: Test failed: 3: gle 1418 clipboard.c:826: Test failed: 3: 0003 not available clipboard.c:828: Test failed: 3: count 5 instead of 2 clipboard.c:833: Test failed: 3: gle 5 clipboard.c:838: Test failed: 3.0: got 0000 instead of 000e clipboard.c:868: Test failed: 3: gle 1418 clipboard.c:717: Test failed: 4: gle 5 clipboard.c:719: Test failed: 4: gle 1418 clipboard.c:746: Test failed: 4: count 6 clipboard.c:749: Test failed: 4: gle 1418 clipboard.c:757: Test failed: 4: count 6 instead of 2 clipboard.c:760: Test failed: 4: gle 5 clipboard.c:765: Test failed: 4.0: got 0000 instead of 0003 clipboard.c:805: Test failed: 4: gle 1418 clipboard.c:815: Test failed: 4: count 6 clipboard.c:818: Test failed: 4: gle 1418 clipboard.c:828: Test failed: 4: count 6 instead of 2 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 clipboard.c:717: Test failed: 5: gle 5 clipboard.c:719: Test failed: 5: gle 1418 clipboard.c:746: Test failed: 5: count 7 clipboard.c:749: Test failed: 5: gle 1418 clipboard.c:755: Test failed: 5: 0008 not available clipboard.c:755: Test failed: 5: 0011 not available clipboard.c:757: Test failed: 5: count 7 instead of 3 clipboard.c:760: Test failed: 5: gle 5 clipboard.c:765: Test failed: 5.0: got 0000 instead of 0002 clipboard.c:805: Test failed: 5: gle 1418 clipboard.c:815: Test failed: 5: count 7 clipboard.c:818: Test failed: 5: gle 1418 clipboard.c:826: Test failed: 5: 0008 not available clipboard.c:826: Test failed: 5: 0011 not available clipboard.c:828: Test failed: 5: count 7 instead of 3 clipboard.c:833: Test failed: 5: gle 5 clipboard.c:838: Test failed: 5.0: got 0000 instead of 0002 clipboard.c:868: Test failed: 5: gle 1418 clipboard.c:717: Test failed: 6: gle 5 clipboard.c:719: Test failed: 6: gle 1418 clipboard.c:746: Test failed: 6: count 8 clipboard.c:749: Test failed: 6: gle 1418 clipboard.c:755: Test failed: 6: 0011 not available clipboard.c:757: Test failed: 6: count 8 instead of 3 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 8 clipboard.c:818: Test failed: 6: gle 1418 clipboard.c:826: Test failed: 6: 0011 not available clipboard.c:828: Test failed: 6: count 8 instead of 3 clipboard.c:833: Test failed: 6: gle 5 clipboard.c:838: Test failed: 6.0: got 0000 instead of 0008 clipboard.c:868: Test failed: 6: gle 1418 clipboard.c:717: Test failed: 7: gle 5 clipboard.c:719: Test failed: 7: gle 1418 clipboard.c:746: Test failed: 7: count 9 clipboard.c:749: Test failed: 7: gle 1418 clipboard.c:757: Test failed: 7: count 9 instead of 3 clipboard.c:760: Test failed: 7: gle 5 clipboard.c:765: Test failed: 7.0: got 0000 instead of 0011 clipboard.c:805: Test failed: 7: gle 1418 clipboard.c:815: Test failed: 7: count 9 clipboard.c:818: Test failed: 7: gle 1418 clipboard.c:828: Test failed: 7: count 9 instead of 3 clipboard.c:833: Test failed: 7: gle 5 clipboard.c:838: Test failed: 7.0: got 0000 instead of 0011 clipboard.c:868: Test failed: 7: gle 1418 clipboard.c:874: Test failed: gle 5 clipboard.c:876: Test failed: gle 1418 clipboard.c:878: Test failed: gle 1418