[gtk+/multitouch: 116/121] scrolledwindow: Use the child widget's window bg color for the overshoot area



commit 22a45c9283443159c797713388b869dae6713237
Author: Carlos Garnacho <carlosg gnome org>
Date:   Thu Jan 12 02:53:47 2012 +0100

    scrolledwindow: Use the child widget's window bg color for the overshoot area
    
    This makes the overshoot area seamless, if the child plays along.

 gtk/gtkscrolledwindow.c |   24 +++++++++++++++++++++---
 1 files changed, 21 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c
index 2e02c8e..91a51c7 100644
--- a/gtk/gtkscrolledwindow.c
+++ b/gtk/gtkscrolledwindow.c
@@ -1399,14 +1399,32 @@ gtk_scrolled_window_draw (GtkWidget *widget,
   GtkScrolledWindow *scrolled_window = GTK_SCROLLED_WINDOW (widget);
   GtkScrolledWindowPrivate *priv = scrolled_window->priv;
   GtkAllocation relative_allocation;
+  cairo_pattern_t *pattern = NULL;
   GtkStyleContext *context;
+  GtkWidget *child;
 
   context = gtk_widget_get_style_context (widget);
   gtk_scrolled_window_relative_allocation (widget, &relative_allocation);
 
-  gtk_render_background (context, cr,
-                         relative_allocation.x, relative_allocation.y,
-                         relative_allocation.width, relative_allocation.height);
+  /* Use child's background if possible */
+  child = gtk_bin_get_child (GTK_BIN (widget));
+
+  if (child && gtk_widget_get_has_window (child))
+    pattern = gdk_window_get_background_pattern (gtk_widget_get_window (child));
+
+  if (pattern &&
+      cairo_pattern_get_type (pattern) == CAIRO_PATTERN_TYPE_SOLID)
+    {
+      cairo_set_source (cr, pattern);
+
+      cairo_rectangle (cr, relative_allocation.x, relative_allocation.y,
+                       relative_allocation.width, relative_allocation.height);
+      cairo_fill (cr);
+    }
+  else
+    gtk_render_background (context, cr,
+                           relative_allocation.x, relative_allocation.y,
+                           relative_allocation.width, relative_allocation.height);
 
   if (priv->shadow_type != GTK_SHADOW_NONE)
     {



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