comctl32/pager: Prevent excessive PGN_CALCSIZE notifications during PGM_SETCHILD.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Nikolay Sivov 2017-04-21 13:16:02 +03:00 committed by Alexandre Julliard
parent 299ded6091
commit 48c4edd9ba
2 changed files with 14 additions and 13 deletions

View File

@ -271,7 +271,7 @@ PAGER_PositionChildWnd(PAGER_INFO* infoPtr)
} }
static INT static INT
PAGER_GetScrollRange(PAGER_INFO* infoPtr) PAGER_GetScrollRange(PAGER_INFO* infoPtr, BOOL calc_size)
{ {
INT scrollRange = 0; INT scrollRange = 0;
@ -281,6 +281,7 @@ PAGER_GetScrollRange(PAGER_INFO* infoPtr)
RECT wndRect; RECT wndRect;
GetWindowRect(infoPtr->hwndSelf, &wndRect); GetWindowRect(infoPtr->hwndSelf, &wndRect);
if (calc_size)
PAGER_CalcSize(infoPtr); PAGER_CalcSize(infoPtr);
if (infoPtr->dwStyle & PGS_HORZ) if (infoPtr->dwStyle & PGS_HORZ)
{ {
@ -362,9 +363,9 @@ PAGER_UpdateBtns(PAGER_INFO *infoPtr, INT scrollRange, BOOL hideGrayBtns)
} }
static LRESULT static LRESULT
PAGER_SetPos(PAGER_INFO* infoPtr, INT newPos, BOOL fromBtnPress) PAGER_SetPos(PAGER_INFO* infoPtr, INT newPos, BOOL fromBtnPress, BOOL calc_size)
{ {
INT scrollRange = PAGER_GetScrollRange(infoPtr); INT scrollRange = PAGER_GetScrollRange(infoPtr, calc_size);
INT oldPos = infoPtr->nPos; INT oldPos = infoPtr->nPos;
if ((scrollRange <= 0) || (newPos < 0)) if ((scrollRange <= 0) || (newPos < 0))
@ -405,12 +406,12 @@ PAGER_RecalcSize(PAGER_INFO *infoPtr)
if (infoPtr->hwndChild) if (infoPtr->hwndChild)
{ {
INT scrollRange = PAGER_GetScrollRange(infoPtr); INT scrollRange = PAGER_GetScrollRange(infoPtr, TRUE);
if (scrollRange <= 0) if (scrollRange <= 0)
{ {
infoPtr->nPos = -1; infoPtr->nPos = -1;
PAGER_SetPos(infoPtr, 0, FALSE); PAGER_SetPos(infoPtr, 0, FALSE, TRUE);
} }
else else
PAGER_PositionChildWnd(infoPtr); PAGER_PositionChildWnd(infoPtr);
@ -480,7 +481,7 @@ PAGER_SetChild (PAGER_INFO* infoPtr, HWND hwndChild)
SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE); SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE);
infoPtr->nPos = -1; infoPtr->nPos = -1;
PAGER_SetPos(infoPtr, 0, FALSE); PAGER_SetPos(infoPtr, 0, FALSE, FALSE);
} }
return 0; return 0;
@ -525,9 +526,9 @@ PAGER_Scroll(PAGER_INFO* infoPtr, INT dir)
infoPtr->direction = dir; infoPtr->direction = dir;
if (dir == PGF_SCROLLLEFT || dir == PGF_SCROLLUP) if (dir == PGF_SCROLLLEFT || dir == PGF_SCROLLUP)
PAGER_SetPos(infoPtr, infoPtr->nPos - nmpgScroll.iScroll, TRUE); PAGER_SetPos(infoPtr, infoPtr->nPos - nmpgScroll.iScroll, TRUE, TRUE);
else else
PAGER_SetPos(infoPtr, infoPtr->nPos + nmpgScroll.iScroll, TRUE); PAGER_SetPos(infoPtr, infoPtr->nPos + nmpgScroll.iScroll, TRUE, TRUE);
} }
else else
infoPtr->direction = -1; infoPtr->direction = -1;
@ -1047,7 +1048,7 @@ PAGER_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
return PAGER_SetChild (infoPtr, (HWND)lParam); return PAGER_SetChild (infoPtr, (HWND)lParam);
case PGM_SETPOS: case PGM_SETPOS:
return PAGER_SetPos(infoPtr, (INT)lParam, FALSE); return PAGER_SetPos(infoPtr, (INT)lParam, FALSE, TRUE);
case WM_CREATE: case WM_CREATE:
return PAGER_Create (hwnd, (LPCREATESTRUCTW)lParam); return PAGER_Create (hwnd, (LPCREATESTRUCTW)lParam);

View File

@ -272,14 +272,14 @@ static void test_pager(void)
flush_sequences( sequences, NUM_MSG_SEQUENCES ); flush_sequences( sequences, NUM_MSG_SEQUENCES );
SendMessageA( pager, PGM_SETCHILD, 0, (LPARAM)child1_wnd ); SendMessageA( pager, PGM_SETCHILD, 0, (LPARAM)child1_wnd );
ok_sequence(sequences, PAGER_SEQ_INDEX, set_child_seq, "set child", TRUE); ok_sequence(sequences, PAGER_SEQ_INDEX, set_child_seq, "set child", FALSE);
GetWindowRect( pager, &rect ); GetWindowRect( pager, &rect );
ok( rect.right - rect.left == 100 && rect.bottom - rect.top == 100, ok( rect.right - rect.left == 100 && rect.bottom - rect.top == 100,
"pager resized %dx%d\n", rect.right - rect.left, rect.bottom - rect.top ); "pager resized %dx%d\n", rect.right - rect.left, rect.bottom - rect.top );
flush_sequences(sequences, NUM_MSG_SEQUENCES); flush_sequences(sequences, NUM_MSG_SEQUENCES);
SendMessageA(pager, PGM_SETCHILD, 0, (LPARAM)child2_wnd); SendMessageA(pager, PGM_SETCHILD, 0, (LPARAM)child2_wnd);
ok_sequence(sequences, PAGER_SEQ_INDEX, switch_child_seq, "switch to invisible child", TRUE); ok_sequence(sequences, PAGER_SEQ_INDEX, switch_child_seq, "switch to invisible child", FALSE);
GetWindowRect(pager, &rect); GetWindowRect(pager, &rect);
ok(rect.right - rect.left == 100 && rect.bottom - rect.top == 100, ok(rect.right - rect.left == 100 && rect.bottom - rect.top == 100,
"pager resized %dx%d\n", rect.right - rect.left, rect.bottom - rect.top); "pager resized %dx%d\n", rect.right - rect.left, rect.bottom - rect.top);
@ -287,7 +287,7 @@ static void test_pager(void)
flush_sequences(sequences, NUM_MSG_SEQUENCES); flush_sequences(sequences, NUM_MSG_SEQUENCES);
SendMessageA(pager, PGM_SETCHILD, 0, (LPARAM)child1_wnd); SendMessageA(pager, PGM_SETCHILD, 0, (LPARAM)child1_wnd);
ok_sequence(sequences, PAGER_SEQ_INDEX, set_child_seq, "switch to visible child", TRUE); ok_sequence(sequences, PAGER_SEQ_INDEX, set_child_seq, "switch to visible child", FALSE);
GetWindowRect(pager, &rect); GetWindowRect(pager, &rect);
ok(rect.right - rect.left == 100 && rect.bottom - rect.top == 100, ok(rect.right - rect.left == 100 && rect.bottom - rect.top == 100,
"pager resized %dx%d\n", rect.right - rect.left, rect.bottom - rect.top); "pager resized %dx%d\n", rect.right - rect.left, rect.bottom - rect.top);