From 30c0639b5a2623072e0b93932d196f37976951b8 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Mon, 12 May 2008 12:29:56 +0200 Subject: [PATCH] server: Crop the invalidate region against the rectangles of all parents. --- dlls/user32/tests/msg.c | 6 ++++++ server/window.c | 30 +++++++++++++++++------------- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c index da353f99fc6..fe4264e379f 100644 --- a/dlls/user32/tests/msg.c +++ b/dlls/user32/tests/msg.c @@ -5824,6 +5824,12 @@ static void test_paint_messages(void) SetRectRgn( hrgn, 30, 30, 40, 40 ); check_update_rgn( hchild, hrgn ); + /* invalidated region is cropped by the parent rects */ + SetRect( &rect, 0, 0, 50, 50 ); + RedrawWindow( hchild, &rect, 0, RDW_INVALIDATE | RDW_ERASE ); + SetRectRgn( hrgn, 30, 30, 50, 50 ); + check_update_rgn( hchild, hrgn ); + DestroyWindow( hparent ); ok(!IsWindow(hchild), "child must be destroyed with its parent\n"); flush_sequence(); diff --git a/server/window.c b/server/window.c index 3a67b8d742d..9530c6102a5 100644 --- a/server/window.c +++ b/server/window.c @@ -1036,23 +1036,27 @@ static int get_window_visible_rect( struct window *win, rectangle_t *rect, int f /* and converted from client to window coordinates. Helper for (in)validate_window. */ static struct region *crop_region_to_win_rect( struct window *win, struct region *region, int frame ) { - struct region *tmp = create_empty_region(); + rectangle_t rect; + struct region *tmp; - if (!tmp) return NULL; + if (!get_window_visible_rect( win, &rect, frame )) return NULL; + if (!(tmp = create_empty_region())) return NULL; + set_region_rect( tmp, &rect ); - /* get bounding rect in client coords */ - if (frame) set_region_rect( tmp, &win->window_rect ); - else set_region_client_rect( tmp, win ); - if (!is_desktop_window(win)) - offset_region( tmp, -win->client_rect.left, -win->client_rect.top ); + if (region) + { + /* map it to client coords */ + offset_region( tmp, win->window_rect.left - win->client_rect.left, + win->window_rect.top - win->client_rect.top ); - /* intersect specified region with bounding rect */ - if (region && !intersect_region( tmp, region, tmp )) goto done; - if (is_region_empty( tmp )) goto done; + /* intersect specified region with bounding rect */ + if (!intersect_region( tmp, region, tmp )) goto done; + if (is_region_empty( tmp )) goto done; - /* map it to window coords */ - offset_region( tmp, win->client_rect.left - win->window_rect.left, - win->client_rect.top - win->window_rect.top ); + /* map it back to window coords */ + offset_region( tmp, win->client_rect.left - win->window_rect.left, + win->client_rect.top - win->window_rect.top ); + } return tmp; done: