[gtk+/wip/otte/gadget: 6/18] container: Split out a function



commit 175607f10944e3ee9c952abc8277c6abbed6b1e4
Author: Benjamin Otte <otte redhat com>
Date:   Wed Nov 18 01:47:16 2015 +0100

    container: Split out a function
    
    Computing the clip for all children is something I want to do in other
    places.

 gtk/gtkcontainer.c        |   24 ++++++++++++++++++++++++
 gtk/gtkcontainerprivate.h |    2 ++
 gtk/gtkwidget.c           |   29 ++++++-----------------------
 3 files changed, 32 insertions(+), 23 deletions(-)
---
diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c
index 3122bd6..cb98431 100644
--- a/gtk/gtkcontainer.c
+++ b/gtk/gtkcontainer.c
@@ -3751,6 +3751,30 @@ gtk_container_propagate_draw_internal (GtkContainer *container,
   cairo_restore (cr);
 }
 
+static void
+union_with_clip (GtkWidget *widget,
+                 gpointer   clip)
+{
+  GtkAllocation widget_clip;
+
+  if (!gtk_widget_is_visible (widget) ||
+      !_gtk_widget_get_child_visible (widget))
+    return;
+
+  gtk_widget_get_clip (widget, &widget_clip);
+
+  gdk_rectangle_union (&widget_clip, clip, clip);
+}
+
+void
+gtk_container_get_children_clip (GtkContainer  *container,
+                                 GtkAllocation *out_clip)
+{
+  memset (out_clip, 0, sizeof (GtkAllocation));
+
+  gtk_container_forall (container, union_with_clip, out_clip);
+}
+
 /**
  * gtk_container_propagate_draw:
  * @container: a #GtkContainer
diff --git a/gtk/gtkcontainerprivate.h b/gtk/gtkcontainerprivate.h
index 78ee99c..1961444 100644
--- a/gtk/gtkcontainerprivate.h
+++ b/gtk/gtkcontainerprivate.h
@@ -42,6 +42,8 @@ void      _gtk_container_maybe_start_idle_sizer (GtkContainer *container);
 gboolean  _gtk_container_get_border_width_set   (GtkContainer *container);
 void      _gtk_container_set_border_width_set   (GtkContainer *container,
                                                  gboolean      border_width_set);
+void      gtk_container_get_children_clip       (GtkContainer  *container,
+                                                 GtkAllocation *out_clip);
 
 G_END_DECLS
 
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index e8b30f0..0bf08a0 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -15629,21 +15629,6 @@ gtk_widget_set_clip (GtkWidget           *widget,
   priv->clip = *clip;
 }
 
-static void
-union_with_clip (GtkWidget *widget,
-                 gpointer   clip)
-{
-  GtkAllocation widget_clip;
-
-  if (!gtk_widget_is_visible (widget) ||
-      !_gtk_widget_get_child_visible (widget))
-    return;
-
-  gtk_widget_get_clip (widget, &widget_clip);
-
-  gdk_rectangle_union (&widget_clip, clip, clip);
-}
-
 /*
  * _gtk_widget_set_simple_clip:
  * @widget: a #GtkWidget
@@ -15690,19 +15675,17 @@ _gtk_widget_set_simple_clip (GtkWidget     *widget,
 
   if (GTK_IS_CONTAINER (widget))
     {
-      if (_gtk_widget_get_has_window (widget))
-        {
-          clip.x -= allocation.x;
-          clip.y -= allocation.y;
-        }
+      GdkRectangle children_clip;
 
-      gtk_container_forall (GTK_CONTAINER (widget), union_with_clip, &clip);
+      gtk_container_get_children_clip (GTK_CONTAINER (widget), &children_clip);
 
       if (_gtk_widget_get_has_window (widget))
         {
-          clip.x += allocation.x;
-          clip.y += allocation.y;
+          children_clip.x += allocation.x;
+          children_clip.y += allocation.y;
         }
+
+      gdk_rectangle_union (&children_clip, &clip, &clip);
     }
 
   gtk_widget_set_clip (widget, &clip);


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