From 49daf22cf1ff94bec4a4c299caf1037240946794 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Thu, 12 Jan 2012 02:53:47 +0100 Subject: [PATCH] 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 file changed, 21 insertions(+), 3 deletions(-) diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c index d0bde13086..af5923cf5f 100644 --- a/gtk/gtkscrolledwindow.c +++ b/gtk/gtkscrolledwindow.c @@ -1406,14 +1406,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) {