[gtk+/wip/otte/queue-resize: 7/31] gdk: Add gdk_rectangle_equal()



commit 00e4659eeae6b3e4b8c902609b1d76fe45d89cb2
Author: Benjamin Otte <otte redhat com>
Date:   Sun Sep 13 16:00:22 2015 +0200

    gdk: Add gdk_rectangle_equal()
    
    There's enough users inside GTK to warrant this convenience function.

 docs/reference/gdk/gdk3-sections.txt |    1 +
 gdk/gdkrectangle.c                   |   21 +++++++++++++++++++++
 gdk/gdkrectangle.h                   |    4 ++++
 gtk/gtkframe.c                       |   12 +-----------
 gtk/gtkrange.c                       |   12 +-----------
 5 files changed, 28 insertions(+), 22 deletions(-)
---
diff --git a/docs/reference/gdk/gdk3-sections.txt b/docs/reference/gdk/gdk3-sections.txt
index 1aaefb5..8309d1d 100644
--- a/docs/reference/gdk/gdk3-sections.txt
+++ b/docs/reference/gdk/gdk3-sections.txt
@@ -631,6 +631,7 @@ GdkPoint
 GdkRectangle
 gdk_rectangle_intersect
 gdk_rectangle_union
+gdk_rectangle_equal
 
 <SUBSECTION Private>
 gdk_rectangle_get_type
diff --git a/gdk/gdkrectangle.c b/gdk/gdkrectangle.c
index 404ffca..84abd2f 100644
--- a/gdk/gdkrectangle.c
+++ b/gdk/gdkrectangle.c
@@ -133,6 +133,27 @@ gdk_rectangle_intersect (const GdkRectangle *src1,
   return return_val;
 }
 
+/**
+ * gdk_rectangle_equal:
+ * @rect1: a #GdkRectangle
+ * @rect2: a #GdkRectangle
+ *
+ * Checks if the two given rectangles are equal.
+ *
+ * Returns: %TRUE if the rectangles are equal.
+ *
+ * Since: 3.20
+ */
+gboolean
+gdk_rectangle_equal (const GdkRectangle *rect1,
+                     const GdkRectangle *rect2)
+{
+  return rect1->x == rect2->x
+      && rect1->y == rect2->y
+      && rect1->width == rect2->width
+      && rect1->height == rect2->height;
+}
+
 static GdkRectangle *
 gdk_rectangle_copy (const GdkRectangle *rectangle)
 {
diff --git a/gdk/gdkrectangle.h b/gdk/gdkrectangle.h
index e098ea9..7c0252f 100644
--- a/gdk/gdkrectangle.h
+++ b/gdk/gdkrectangle.h
@@ -45,6 +45,10 @@ void     gdk_rectangle_union     (const GdkRectangle *src1,
                                   const GdkRectangle *src2,
                                   GdkRectangle       *dest);
 
+GDK_AVAILABLE_IN_3_20
+gboolean gdk_rectangle_equal     (const GdkRectangle *rect1,
+                                  const GdkRectangle *rect2);
+
 GDK_AVAILABLE_IN_ALL
 GType gdk_rectangle_get_type (void) G_GNUC_CONST;
 
diff --git a/gtk/gtkframe.c b/gtk/gtkframe.c
index 8a0e3e2..b5fe4e5 100644
--- a/gtk/gtkframe.c
+++ b/gtk/gtkframe.c
@@ -707,16 +707,6 @@ gtk_frame_draw (GtkWidget *widget,
   return FALSE;
 }
 
-static gboolean
-rectangle_equal (const GdkRectangle *a,
-                 const GdkRectangle *b)
-{
-  return a->x == b->x
-      && a->y == b->y
-      && a->width == b->width
-      && a->height == b->height;
-}
-
 static void
 gtk_frame_size_allocate (GtkWidget     *widget,
                         GtkAllocation *allocation)
@@ -734,7 +724,7 @@ gtk_frame_size_allocate (GtkWidget     *widget,
   /* If the child allocation changed, that means that the frame is drawn
    * in a new place, so we must redraw the entire widget.
    */
-  if (gtk_widget_get_mapped (widget) && !rectangle_equal (&priv->child_allocation, &new_allocation))
+  if (gtk_widget_get_mapped (widget) && !gdk_rectangle_equal (&priv->child_allocation, &new_allocation))
     {
       gdk_window_invalidate_rect (gtk_widget_get_window (widget), allocation, FALSE);
     }
diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c
index 6217ae0..f790017 100644
--- a/gtk/gtkrange.c
+++ b/gtk/gtkrange.c
@@ -3655,16 +3655,6 @@ gtk_range_compute_slider_position (GtkRange     *range,
     }
 }
 
-static gboolean
-rectangle_equal (const GdkRectangle *a,
-                 const GdkRectangle *b)
-{
-  return a->x == b->x
-      && a->y == b->y
-      && a->width == b->width
-      && a->height == b->height;
-}
-
 static void
 gtk_range_calc_slider (GtkRange *range)
 {
@@ -3675,7 +3665,7 @@ gtk_range_calc_slider (GtkRange *range)
                                      gtk_adjustment_get_value (priv->adjustment),
                                      &new_slider);
 
-  if (rectangle_equal (&priv->slider, &new_slider))
+  if (gdk_rectangle_equal (&priv->slider, &new_slider))
     return;
 
   gtk_range_queue_draw_location (range, MOUSE_SLIDER);


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