From edc90a9f9cb69646e936cad4527007242771c682 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 1 Sep 2004 22:49:14 +0000 Subject: [PATCH] Added rect_in_region function. --- server/region.c | 17 +++++++++++++++++ server/user.h | 1 + 2 files changed, 18 insertions(+) diff --git a/server/region.c b/server/region.c index e0035e96521..15dc3b8ab88 100644 --- a/server/region.c +++ b/server/region.c @@ -775,3 +775,20 @@ int point_in_region( struct region *region, int x, int y ) } return 0; } + +/* check if the given rectangle is (at least partially) inside the region */ +int rect_in_region( struct region *region, const rectangle_t *rect ) +{ + const rectangle_t *ptr, *end; + + for (ptr = region->rects, end = region->rects + region->num_rects; ptr < end; ptr++) + { + if (ptr->top > rect->bottom) return 0; + if (ptr->bottom <= rect->top) continue; + /* now we are in the correct band */ + if (ptr->left > rect->right) return 0; + if (ptr->right <= rect->left) continue; + return 1; + } + return 0; +} diff --git a/server/user.h b/server/user.h index 638ffc68f8b..7f510ee1172 100644 --- a/server/user.h +++ b/server/user.h @@ -84,6 +84,7 @@ extern struct region *subtract_region( struct region *dst, const struct region * extern struct region *union_region( struct region *dst, const struct region *src1, const struct region *src2 ); extern int point_in_region( struct region *region, int x, int y ); +extern int rect_in_region( struct region *region, const rectangle_t *rect ); static inline struct region *create_empty_region(void) { return create_region( NULL, 0 ); } /* window functions */ -- 2.11.4.GIT