[v6 5/6] user32: Send WM_NCPAINT and WM_ERASEBKGND when window is shown and add tests

Fabian Maurer dark.shadow4 at web.de
Thu Feb 9 16:50:30 CST 2017


Fixes Bug 2624 and 6682 and a few others

v2: Make patch independent from the WM_NCPAINT issue
v3: Add more tests and split patch up
v5: Mark tests as todo as long as they don't pass

Signed-off-by: Fabian Maurer <dark.shadow4 at web.de>
---
 dlls/user32/tests/msg.c | 24 ++++++++++++------------
 dlls/user32/winpos.c    | 33 +++++++++++++++++++++++----------
 2 files changed, 35 insertions(+), 22 deletions(-)

diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c
index 019ea6b5a1..8dcb06ea10 100644
--- a/dlls/user32/tests/msg.c
+++ b/dlls/user32/tests/msg.c
@@ -5135,7 +5135,7 @@ static void test_messages(void)
                              10, 10, 100, 100, NULL, 0, 0, NULL );
     ok (hwnd != 0, "Failed to create popup window\n");
     RedrawWindow(hwnd, NULL, NULL, RDW_UPDATENOW);
-    ok_sequence(WmShowPopupFirstDrawSeq_1, "RedrawWindow:show_popup_first_draw_visible", TRUE);
+    ok_sequence(WmShowPopupFirstDrawSeq_1, "RedrawWindow:show_popup_first_draw_visible", FALSE);
     DestroyWindow(hwnd);
 
     /* Invisible, show, message */
@@ -5146,7 +5146,7 @@ static void test_messages(void)
     ok (hwnd != 0, "Failed to create popup window\n");
     ShowWindow(hwnd, SW_SHOW);
     SendMessageW(hwnd, WM_PAINT, 0, 0);
-    ok_sequence(WmShowPopupFirstDrawSeq_1, "RedrawWindow:show_popup_first_draw_show", TRUE);
+    ok_sequence(WmShowPopupFirstDrawSeq_1, "RedrawWindow:show_popup_first_draw_show", FALSE);
     DestroyWindow(hwnd);
 
     /* Invisible, show maximized, redraw */
@@ -5157,20 +5157,20 @@ static void test_messages(void)
     ok (hwnd != 0, "Failed to create popup window\n");
     ShowWindow(hwnd, SW_SHOWMAXIMIZED);
     RedrawWindow(hwnd, NULL, NULL, RDW_UPDATENOW);
-    ok_sequence(WmShowPopupFirstDrawSeq_2, "RedrawWindow:show_popup_first_draw_show_maximized", TRUE);
+    ok_sequence(WmShowPopupFirstDrawSeq_2, "RedrawWindow:show_popup_first_draw_show_maximized", FALSE);
     DestroyWindow(hwnd);
 
     /* Test SetWindowPos */
-    test_msg_setpos(WmFirstDrawSetWindowPosSeq1, SWP_SHOWWINDOW, TRUE);
+    test_msg_setpos(WmFirstDrawSetWindowPosSeq1, SWP_SHOWWINDOW, FALSE);
     test_msg_setpos(WmFirstDrawSetWindowPosSeq2, 0, FALSE);
     test_msg_setpos(WmFirstDrawSetWindowPosSeq3,
             SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE | SWP_NOCLIENTSIZE | SWP_NOCLIENTMOVE | SWP_NOZORDER, TRUE);
 
-    test_msg_setpos(WmFirstDrawSetWindowPosSeq1, SWP_SHOWWINDOW | SWP_NOSIZE, TRUE);
-    test_msg_setpos(WmFirstDrawSetWindowPosSeq4, SWP_SHOWWINDOW | SWP_NOMOVE, TRUE);
+    test_msg_setpos(WmFirstDrawSetWindowPosSeq1, SWP_SHOWWINDOW | SWP_NOSIZE, FALSE);
+    test_msg_setpos(WmFirstDrawSetWindowPosSeq4, SWP_SHOWWINDOW | SWP_NOMOVE, FALSE);
     test_msg_setpos(WmFirstDrawSetWindowPosSeq3, SWP_SHOWWINDOW | SWP_NOCLIENTSIZE, TRUE);
     test_msg_setpos(WmFirstDrawSetWindowPosSeq3, SWP_SHOWWINDOW | SWP_NOCLIENTMOVE, TRUE);
-    test_msg_setpos(WmFirstDrawSetWindowPosSeq1, SWP_SHOWWINDOW | SWP_NOZORDER, TRUE);
+    test_msg_setpos(WmFirstDrawSetWindowPosSeq1, SWP_SHOWWINDOW | SWP_NOZORDER, FALSE);
 
     test_msg_setpos(WmFirstDrawSetWindowPosSeq2, SWP_SHOWWINDOW | SWP_DEFERERASE, FALSE);
     test_msg_setpos(WmFirstDrawSetWindowPosSeq3, SWP_SHOWWINDOW | SWP_DEFERERASE | SWP_NOCLIENTMOVE, TRUE);
@@ -5179,12 +5179,12 @@ static void test_messages(void)
     test_msg_setpos(WmFirstDrawSetWindowPosSeq2, SWP_SHOWWINDOW | SWP_DEFERERASE | SWP_NOSIZE, FALSE);
     test_msg_setpos(WmFirstDrawSetWindowPosSeq2, SWP_SHOWWINDOW | SWP_DEFERERASE | SWP_NOZORDER, FALSE);
 
-    test_msg_setpos(WmFirstDrawSetWindowPosSeq1, SWP_SHOWWINDOW | SWP_NOCOPYBITS, TRUE);
+    test_msg_setpos(WmFirstDrawSetWindowPosSeq1, SWP_SHOWWINDOW | SWP_NOCOPYBITS, FALSE);
     test_msg_setpos(WmFirstDrawSetWindowPosSeq3, SWP_SHOWWINDOW | SWP_NOCOPYBITS | SWP_NOCLIENTMOVE, TRUE);
     test_msg_setpos(WmFirstDrawSetWindowPosSeq3, SWP_SHOWWINDOW | SWP_NOCOPYBITS | SWP_NOCLIENTSIZE, TRUE);
-    test_msg_setpos(WmFirstDrawSetWindowPosSeq4, SWP_SHOWWINDOW | SWP_NOCOPYBITS | SWP_NOMOVE, TRUE);
-    test_msg_setpos(WmFirstDrawSetWindowPosSeq1, SWP_SHOWWINDOW | SWP_NOCOPYBITS | SWP_NOSIZE, TRUE);
-    test_msg_setpos(WmFirstDrawSetWindowPosSeq1, SWP_SHOWWINDOW | SWP_NOCOPYBITS | SWP_NOZORDER, TRUE);
+    test_msg_setpos(WmFirstDrawSetWindowPosSeq4, SWP_SHOWWINDOW | SWP_NOCOPYBITS | SWP_NOMOVE, FALSE);
+    test_msg_setpos(WmFirstDrawSetWindowPosSeq1, SWP_SHOWWINDOW | SWP_NOCOPYBITS | SWP_NOSIZE, FALSE);
+    test_msg_setpos(WmFirstDrawSetWindowPosSeq1, SWP_SHOWWINDOW | SWP_NOCOPYBITS | SWP_NOZORDER, FALSE);
 
     test_msg_setpos(WmFirstDrawSetWindowPosSeq2, SWP_SHOWWINDOW | SWP_NOREDRAW, FALSE);
     test_msg_setpos(WmFirstDrawSetWindowPosSeq3, SWP_SHOWWINDOW | SWP_NOREDRAW | SWP_NOCLIENTMOVE, TRUE);
@@ -5220,7 +5220,7 @@ static void test_messages(void)
     flush_sequence();
     SetWindowPos(hparent, NULL, 0, 0, 100, 100, SWP_SHOWWINDOW);
     ok_sequence(WmFirstDrawChildSeq2, /* Expect child to be redrawn */
-                "SetWindowPos:show_popup_first_show_window_child2", TRUE);
+                "SetWindowPos:show_popup_first_show_window_child2", FALSE);
     DestroyWindow(hchild);
     DestroyWindow(hparent);
 
diff --git a/dlls/user32/winpos.c b/dlls/user32/winpos.c
index 2fa194fa1c..a6c2ce101c 100644
--- a/dlls/user32/winpos.c
+++ b/dlls/user32/winpos.c
@@ -45,6 +45,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(win);
     (SWP_NOSIZE | SWP_NOMOVE | SWP_NOCLIENTSIZE | SWP_NOCLIENTMOVE | SWP_NOZORDER)
 #define SWP_AGG_STATUSFLAGS \
     (SWP_AGG_NOPOSCHANGE | SWP_FRAMECHANGED | SWP_HIDEWINDOW | SWP_SHOWWINDOW)
+#define SWP_AGG_NOCLIENTCHANGE \
+        (SWP_NOCLIENTSIZE | SWP_NOCLIENTMOVE)
 
 #define HAS_DLGFRAME(style,exStyle) \
     (((exStyle) & WS_EX_DLGMODALFRAME) || \
@@ -2229,16 +2231,7 @@ BOOL USER_SetWindowPos( WINDOWPOS * winpos )
                          &newWindowRect, &newClientRect, valid_rects ))
         return FALSE;
 
-    /* erase parent when hiding or resizing child */
-    if (!(orig_flags & SWP_DEFERERASE) &&
-        ((orig_flags & SWP_HIDEWINDOW) ||
-         (!(orig_flags & SWP_SHOWWINDOW) &&
-          (winpos->flags & SWP_AGG_STATUSFLAGS) != SWP_AGG_NOGEOMETRYCHANGE)))
-    {
-        HWND parent = GetAncestor( winpos->hwnd, GA_PARENT );
-        if (!parent || parent == GetDesktopWindow()) parent = winpos->hwnd;
-        erase_now( parent, 0 );
-    }
+
 
     if( winpos->flags & SWP_HIDEWINDOW )
         HideCaret(winpos->hwnd);
@@ -2254,6 +2247,26 @@ BOOL USER_SetWindowPos( WINDOWPOS * winpos )
             SetForegroundWindow( winpos->hwnd );
     }
 
+    if(!(orig_flags & SWP_DEFERERASE))
+    {
+        /* erase parent when hiding or resizing child */
+        if ((orig_flags & SWP_HIDEWINDOW) ||
+         (!(orig_flags & SWP_SHOWWINDOW) &&
+          (winpos->flags & SWP_AGG_STATUSFLAGS) != SWP_AGG_NOGEOMETRYCHANGE))
+        {
+            HWND parent = GetAncestor( winpos->hwnd, GA_PARENT );
+            if (!parent || parent == GetDesktopWindow()) parent = winpos->hwnd;
+            erase_now( parent, 0 );
+        }
+
+        /* Give newly shown windows a chance to redraw */
+        if(((winpos->flags & SWP_AGG_STATUSFLAGS) != SWP_AGG_NOPOSCHANGE)
+                && !(orig_flags & SWP_AGG_NOCLIENTCHANGE) && (orig_flags & SWP_SHOWWINDOW))
+        {
+            erase_now(winpos->hwnd, 0);
+        }
+    }
+
       /* And last, send the WM_WINDOWPOSCHANGED message */
 
     TRACE("\tstatus flags = %04x\n", winpos->flags & SWP_AGG_STATUSFLAGS);
-- 
2.11.1




More information about the wine-patches mailing list