[PATCH 2/2] comctl32/pager: Prevent excessive PGN_CALCSIZE notifications during PGM_SETCHILD

Nikolay Sivov nsivov at codeweavers.com
Fri Apr 21 05:16:02 CDT 2017


Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
---
 dlls/comctl32/pager.c       | 21 +++++++++++----------
 dlls/comctl32/tests/pager.c |  6 +++---
 2 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/dlls/comctl32/pager.c b/dlls/comctl32/pager.c
index ae759fb68f..e9bcbe8c06 100644
--- a/dlls/comctl32/pager.c
+++ b/dlls/comctl32/pager.c
@@ -271,7 +271,7 @@ PAGER_PositionChildWnd(PAGER_INFO* infoPtr)
 }
 
 static INT
-PAGER_GetScrollRange(PAGER_INFO* infoPtr)
+PAGER_GetScrollRange(PAGER_INFO* infoPtr, BOOL calc_size)
 {
     INT scrollRange = 0;
 
@@ -281,7 +281,8 @@ PAGER_GetScrollRange(PAGER_INFO* infoPtr)
         RECT wndRect;
         GetWindowRect(infoPtr->hwndSelf, &wndRect);
 
-        PAGER_CalcSize(infoPtr);
+        if (calc_size)
+            PAGER_CalcSize(infoPtr);
         if (infoPtr->dwStyle & PGS_HORZ)
         {
             wndSize = wndRect.right - wndRect.left;
@@ -362,9 +363,9 @@ PAGER_UpdateBtns(PAGER_INFO *infoPtr, INT scrollRange, BOOL hideGrayBtns)
 }
 
 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;
 
     if ((scrollRange <= 0) || (newPos < 0))
@@ -405,12 +406,12 @@ PAGER_RecalcSize(PAGER_INFO *infoPtr)
 
     if (infoPtr->hwndChild)
     {
-        INT scrollRange = PAGER_GetScrollRange(infoPtr);
+        INT scrollRange = PAGER_GetScrollRange(infoPtr, TRUE);
 
         if (scrollRange <= 0)
         {
             infoPtr->nPos = -1;
-            PAGER_SetPos(infoPtr, 0, FALSE);
+            PAGER_SetPos(infoPtr, 0, FALSE, TRUE);
         }
         else
             PAGER_PositionChildWnd(infoPtr);
@@ -480,7 +481,7 @@ PAGER_SetChild (PAGER_INFO* infoPtr, HWND hwndChild)
                      SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE);
 
         infoPtr->nPos = -1;
-        PAGER_SetPos(infoPtr, 0, FALSE);
+        PAGER_SetPos(infoPtr, 0, FALSE, FALSE);
     }
 
     return 0;
@@ -525,9 +526,9 @@ PAGER_Scroll(PAGER_INFO* infoPtr, INT dir)
             infoPtr->direction = dir;
 
             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
-                PAGER_SetPos(infoPtr, infoPtr->nPos + nmpgScroll.iScroll, TRUE);
+                PAGER_SetPos(infoPtr, infoPtr->nPos + nmpgScroll.iScroll, TRUE, TRUE);
         }
         else
             infoPtr->direction = -1;
@@ -1047,7 +1048,7 @@ PAGER_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
             return PAGER_SetChild (infoPtr, (HWND)lParam);
 
         case PGM_SETPOS:
-            return PAGER_SetPos(infoPtr, (INT)lParam, FALSE);
+            return PAGER_SetPos(infoPtr, (INT)lParam, FALSE, TRUE);
 
         case WM_CREATE:
             return PAGER_Create (hwnd, (LPCREATESTRUCTW)lParam);
diff --git a/dlls/comctl32/tests/pager.c b/dlls/comctl32/tests/pager.c
index afe6fc6a7e..a9409eac08 100644
--- a/dlls/comctl32/tests/pager.c
+++ b/dlls/comctl32/tests/pager.c
@@ -272,14 +272,14 @@ static void test_pager(void)
 
     flush_sequences( sequences, NUM_MSG_SEQUENCES );
     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 );
     ok( rect.right - rect.left == 100 && rect.bottom - rect.top == 100,
         "pager resized %dx%d\n", rect.right - rect.left, rect.bottom - rect.top );
 
     flush_sequences(sequences, NUM_MSG_SEQUENCES);
     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);
     ok(rect.right - rect.left == 100 && rect.bottom - rect.top == 100,
         "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);
     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);
     ok(rect.right - rect.left == 100 && rect.bottom - rect.top == 100,
         "pager resized %dx%d\n", rect.right - rect.left, rect.bottom - rect.top);
-- 
2.11.0




More information about the wine-patches mailing list