diff options
-rw-r--r-- | gtk/gtkdrawingarea.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/gtk/gtkdrawingarea.c b/gtk/gtkdrawingarea.c index a9b659ee1c..94034059e1 100644 --- a/gtk/gtkdrawingarea.c +++ b/gtk/gtkdrawingarea.c @@ -25,9 +25,9 @@ #include "config.h" #include "gtkdrawingarea.h" #include "gtkintl.h" +#include "gtkrender.h" #include "gtkstylecontext.h" - /** * SECTION:gtkdrawingarea * @Short_description: A widget for custom user interface elements @@ -112,6 +112,8 @@ * gtk_render_focus() for one way to draw focus. */ +static gboolean gtk_drawing_area_draw (GtkWidget *widget, + cairo_t *cr); static void gtk_drawing_area_realize (GtkWidget *widget); static void gtk_drawing_area_size_allocate (GtkWidget *widget, GtkAllocation *allocation); @@ -126,6 +128,7 @@ gtk_drawing_area_class_init (GtkDrawingAreaClass *class) widget_class->realize = gtk_drawing_area_realize; widget_class->size_allocate = gtk_drawing_area_size_allocate; + widget_class->draw = gtk_drawing_area_draw; gtk_widget_class_set_accessible_role (widget_class, ATK_ROLE_DRAWING_AREA); } @@ -181,9 +184,6 @@ gtk_drawing_area_realize (GtkWidget *widget) &attributes, attributes_mask); gtk_widget_register_window (widget, window); gtk_widget_set_window (widget, window); - - gtk_style_context_set_background (gtk_widget_get_style_context (widget), - window); } gtk_drawing_area_send_configure (GTK_DRAWING_AREA (widget)); @@ -209,6 +209,19 @@ gtk_drawing_area_size_allocate (GtkWidget *widget, } } +static gboolean +gtk_drawing_area_draw (GtkWidget *widget, + cairo_t *cr) +{ + if (gtk_widget_get_has_window (widget)) + gtk_render_background (gtk_widget_get_style_context (widget), cr, + 0, 0, + gtk_widget_get_allocated_width (widget), + gtk_widget_get_allocated_height (widget)); + + return GTK_WIDGET_CLASS (gtk_drawing_area_parent_class)->draw (widget, cr); +} + static void gtk_drawing_area_send_configure (GtkDrawingArea *darea) { |