user32: SetWindowPos should limit update region to nearest clipping parent

Dmitry Timoshkov dmitry at codeweavers.com
Mon Mar 19 05:42:58 CDT 2007


Hello,

this patch makes GetUpdateRect test pass under Wine and fixes the bug 7360.
It doesn't cause test failures, but if there are any concerns please let me
know.

Changelog:
    user32: SetWindowPos should limit update region to nearest clipping parent.

---
 dlls/user32/tests/win.c |   34 ++++++++++++++++++----------------
 server/window.c         |   10 +++++++++-
 2 files changed, 27 insertions(+), 17 deletions(-)

diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c
index 5502bf9..2d7bbd2 100644
--- a/dlls/user32/tests/win.c
+++ b/dlls/user32/tests/win.c
@@ -4175,6 +4175,7 @@ static void test_gettext(void)
 
 static void test_GetUpdateRect(void)
 {
+    BOOL ret;
     RECT rc1, rc2;
     HWND hgrandparent, hparent, hchild;
     WNDCLASSA cls;
@@ -4194,16 +4195,15 @@ static void test_GetUpdateRect(void)
 
     ShowWindow(hchild, SW_HIDE);
     SetRect(&rc2, 0, 0, 0, 0);
-    GetUpdateRect(hgrandparent, &rc1, FALSE);
-    todo_wine
-    {
-        ok(EqualRect(&rc1, &rc2), "rects do not match (%d,%d,%d,%d) / (%d,%d,%d,%d)\n",
-                rc1.left, rc1.top, rc1.right, rc1.bottom,
-                rc2.left, rc2.top, rc2.right, rc2.bottom);
-    }
+    ret = GetUpdateRect(hgrandparent, &rc1, FALSE);
+    ok(!ret, "GetUpdateRect returned not empty region\n");
+    ok(EqualRect(&rc1, &rc2), "rects do not match (%d,%d,%d,%d) / (%d,%d,%d,%d)\n",
+            rc1.left, rc1.top, rc1.right, rc1.bottom,
+            rc2.left, rc2.top, rc2.right, rc2.bottom);
 
     SetRect(&rc2, 10, 10, 40, 40);
-    GetUpdateRect(hparent, &rc1, FALSE);
+    ret = GetUpdateRect(hparent, &rc1, FALSE);
+    ok(ret, "GetUpdateRect returned empty region\n");
     ok(EqualRect(&rc1, &rc2), "rects do not match (%d,%d,%d,%d) / (%d,%d,%d,%d)\n",
             rc1.left, rc1.top, rc1.right, rc1.bottom,
             rc2.left, rc2.top, rc2.right, rc2.bottom);
@@ -4238,18 +4238,20 @@ static void test_GetUpdateRect(void)
     ShowWindow(hgrandparent, SW_SHOW);
     UpdateWindow(hgrandparent);
 
+    ret = GetUpdateRect(hgrandparent, &rc1, FALSE);
+    ok(!ret, "GetUpdateRect returned not empty region\n");
+
     ShowWindow(hchild, SW_HIDE);
     SetRect(&rc2, 0, 0, 0, 0);
-    GetUpdateRect(hgrandparent, &rc1, FALSE);
-    todo_wine
-    {
-        ok(EqualRect(&rc1, &rc2), "rects do not match (%d,%d,%d,%d) / (%d,%d,%d,%d)\n",
-                rc1.left, rc1.top, rc1.right, rc1.bottom,
-                rc2.left, rc2.top, rc2.right, rc2.bottom);
-    }
+    ret = GetUpdateRect(hgrandparent, &rc1, FALSE);
+    ok(!ret, "GetUpdateRect returned not empty region\n");
+    ok(EqualRect(&rc1, &rc2), "rects do not match (%d,%d,%d,%d) / (%d,%d,%d,%d)\n",
+            rc1.left, rc1.top, rc1.right, rc1.bottom,
+            rc2.left, rc2.top, rc2.right, rc2.bottom);
 
     SetRect(&rc2, 10, 10, 40, 40);
-    GetUpdateRect(hparent, &rc1, FALSE);
+    ret = GetUpdateRect(hparent, &rc1, FALSE);
+    ok(ret, "GetUpdateRect returned empty region\n");
     ok(EqualRect(&rc1, &rc2), "rects do not match (%d,%d,%d,%d) / (%d,%d,%d,%d)\n",
             rc1.left, rc1.top, rc1.right, rc1.bottom,
             rc2.left, rc2.top, rc2.right, rc2.bottom);
diff --git a/server/window.c b/server/window.c
index cbb4296..cb07a91 100644
--- a/server/window.c
+++ b/server/window.c
@@ -838,6 +838,14 @@ static inline struct window *get_top_clipping_window( struct window *win )
 }
 
 
+/* get the parent window to clip against for a given window */
+static inline struct window *get_clipping_window( struct window *win )
+{
+    if (win->parent && !is_desktop_window(win->parent)) win = win->parent;
+    return win;
+}
+
+
 /* compute the visible region of a window, in window coordinates */
 static struct region *get_visible_region( struct window *win, struct window *top, unsigned int flags )
 {
@@ -1338,7 +1346,7 @@ static void set_window_pos( struct window *win, struct window *previous,
     const rectangle_t old_window_rect = win->window_rect;
     const rectangle_t old_visible_rect = win->visible_rect;
     const rectangle_t old_client_rect = win->client_rect;
-    struct window *top = get_top_clipping_window( win );
+    struct window *top = get_clipping_window( win );
     int visible = (win->style & WS_VISIBLE) || (swp_flags & SWP_SHOWWINDOW);
 
     if (win->parent && !is_visible( win->parent )) visible = 0;
-- 
1.5.0.2






More information about the wine-patches mailing list