]> Pileus Git - ~andy/gtk/commitdiff
container: Implement gtk_container_propagate_draw() without fallbacks
authorBenjamin Otte <otte@redhat.com>
Fri, 10 Sep 2010 19:03:58 +0000 (21:03 +0200)
committerBenjamin Otte <otte@redhat.com>
Sun, 26 Sep 2010 13:11:42 +0000 (15:11 +0200)
No more fallbacks to gtk_container_propagate_expose().

gtk/gtkcontainer.c

index 8800ecb1a3873c4bdb94bf0823f9a2d8e881a819..2a6855e2e9c661543408fe593148fcbcf8278727 100644 (file)
@@ -2831,6 +2831,9 @@ gtk_container_propagate_draw (GtkContainer   *container,
                               cairo_t        *cr)
 {
   GdkEventExpose *event;
                               cairo_t        *cr)
 {
   GdkEventExpose *event;
+  GtkAllocation allocation;
+  GdkWindow *window, *w;
+  int x, y;
 
   g_return_if_fail (GTK_IS_CONTAINER (container));
   g_return_if_fail (GTK_IS_WIDGET (child));
 
   g_return_if_fail (GTK_IS_CONTAINER (container));
   g_return_if_fail (GTK_IS_WIDGET (child));
@@ -2841,15 +2844,54 @@ gtk_container_propagate_draw (GtkContainer   *container,
   event = _gtk_cairo_get_event (cr);
   if (event)
     {
   event = _gtk_cairo_get_event (cr);
   if (event)
     {
-      gtk_container_propagate_expose (container, child, event);
+      if (gtk_widget_get_has_window (child) ||
+          gtk_widget_get_window (child) != event->window)
+        return;
+    }
+
+  cairo_save (cr);
+
+  /* translate coordinates. Ugly business, that. */
+  if (!gtk_widget_get_has_window (GTK_WIDGET (container)))
+    {
+      gtk_widget_get_allocation (GTK_WIDGET (container), &allocation);
+      x = -allocation.x;
+      y = -allocation.y;
     }
   else
     {
     }
   else
     {
-      /* XXX: Needs gtk_widget_draw(), but can only happen once
-       * that function exists */
-      g_assert_not_reached ();
+      x = 0;
+      y = 0;
+    }
+
+  window = gtk_widget_get_window (GTK_WIDGET (container));
+  
+  for (w = gtk_widget_get_window (child); w && w != window; w = gdk_window_get_parent (w))
+    {
+      int wx, wy;
+      gdk_window_get_position (w, &wx, &wy);
+      x += wx;
+      y += wy;
     }
 
     }
 
+  if (w == NULL)
+    {
+      x = 0;
+      y = 0;
+    }
+
+  if (!gtk_widget_get_has_window (child))
+    {
+      gtk_widget_get_allocation (child, &allocation);
+      x += allocation.x;
+      y += allocation.y;
+    }
+
+  cairo_translate (cr, x, y);
+
+  _gtk_widget_draw_internal (child, cr, TRUE);
+
+  cairo_restore (cr);
 }
 
 /**
 }
 
 /**