diff --git a/gdk/gdkregion-generic.c b/gdk/gdkregion-generic.c index 19e03e45c4..d98dc8822d 100644 --- a/gdk/gdkregion-generic.c +++ b/gdk/gdkregion-generic.c @@ -1581,6 +1581,32 @@ gdk_region_equal (const GdkRegion *region1, return TRUE; } +/** + * gdk_region_rect_equal: + * @region: a #GdkRegion + * @rectangle: a #GdkRectangle + * + * Finds out if a regions is the same as a rectangle. + * + * Returns: %TRUE if @region and @rectangle are equal. + * + * Since: 2.18 + */ +gboolean +gdk_region_rect_equal (const GdkRegion *region, + const GdkRectangle *rectangle) +{ + g_return_val_if_fail (region != NULL, FALSE); + g_return_val_if_fail (rectangle != NULL, FALSE); + + if (region->numRects != 1) return FALSE; + else if (region->extents.x1 != rectangle->x) return FALSE; + else if (region->extents.y1 != rectangle->y) return FALSE; + else if (region->extents.x2 != rectangle->x + rectangle->width) return FALSE; + else if (region->extents.y2 != rectangle->y + rectangle->height) return FALSE; + return TRUE; +} + /** * gdk_region_point_in: * @region: a #GdkRegion diff --git a/gdk/gdkregion.h b/gdk/gdkregion.h index b7381eaf4d..415cd24b77 100644 --- a/gdk/gdkregion.h +++ b/gdk/gdkregion.h @@ -77,6 +77,8 @@ void gdk_region_get_rectangles (const GdkRegion *region, gboolean gdk_region_empty (const GdkRegion *region); gboolean gdk_region_equal (const GdkRegion *region1, const GdkRegion *region2); +gboolean gdk_region_rect_equal (const GdkRegion *region1, + const GdkRectangle *rectangle); gboolean gdk_region_point_in (const GdkRegion *region, int x, int y);