[gtk+/client-side-windows] Add gdk_region_rect_equal to compare a region with a rect



commit 6c76f8f6cef2c026985995a5e7444b3a8a5840bb
Author: Alexander Larsson <alexl redhat com>
Date:   Tue May 26 20:48:10 2009 +0200

    Add gdk_region_rect_equal to compare a region with a rect
---
 gdk/gdkregion-generic.c |   26 ++++++++++++++++++++++++++
 gdk/gdkregion.h         |    2 ++
 2 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/gdk/gdkregion-generic.c b/gdk/gdkregion-generic.c
index 19e03e4..d98dc88 100644
--- a/gdk/gdkregion-generic.c
+++ b/gdk/gdkregion-generic.c
@@ -1582,6 +1582,32 @@ gdk_region_equal (const GdkRegion *region1,
 }
 
 /**
+ * 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
  * @x: the x coordinate of a point
diff --git a/gdk/gdkregion.h b/gdk/gdkregion.h
index b7381ea..415cd24 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);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]