- GtkViewport *viewport = GTK_VIEWPORT (widget);
- GtkViewportPrivate *priv = viewport->priv;
- int x, y, w, h;
-
- if (gtk_cairo_should_draw_window (cr, gtk_widget_get_window (widget)))
- {
- gdk_drawable_get_size (gtk_widget_get_window (widget),
- &w, &h);
- gtk_cairo_paint_shadow (gtk_widget_get_style (widget),
- cr,
- GTK_STATE_NORMAL, priv->shadow_type,
- widget, "viewport",
- 0, 0, w, h);
- }
-
- if (gtk_cairo_should_draw_window (cr, priv->bin_window))
- {
- gdk_window_get_position (priv->bin_window, &x, &y);
- gdk_drawable_get_size (priv->bin_window, &w, &h);
- gtk_cairo_paint_flat_box (gtk_widget_get_style (widget), cr,
- GTK_STATE_NORMAL, GTK_SHADOW_NONE,
- widget, "viewportbin",
- x, y, w, h);
-
- GTK_WIDGET_CLASS (gtk_viewport_parent_class)->draw (widget, cr);
- }
+ gtk_style_context_save (context);
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_FRAME);
+
+ gtk_render_frame (context, cr, 0, 0,
+ gdk_window_get_width (gtk_widget_get_window (widget)),
+ gdk_window_get_height (gtk_widget_get_window (widget)));
+
+ gtk_style_context_restore (context);
+ }
+
+ if (gtk_cairo_should_draw_window (cr, priv->view_window))
+ {
+ /* This is a cute hack to ensure the contents of bin_window are
+ * restricted to where they are visible. We only need to do this
+ * clipping when called via gtk_widget_draw() and not in expose
+ * events. And when that happens every window (including this one)
+ * should be drawn.
+ */
+ gdk_window_get_position (priv->view_window, &x, &y);
+ cairo_rectangle (cr, x, y,
+ gdk_window_get_width (priv->view_window),
+ gdk_window_get_height (priv->view_window));
+ cairo_clip (cr);
+ }
+
+ if (gtk_cairo_should_draw_window (cr, priv->bin_window))
+ {
+ gdk_window_get_position (priv->bin_window, &x, &y);
+ gtk_render_background (context, cr, x, y,
+ gdk_window_get_width (priv->bin_window),
+ gdk_window_get_height (priv->bin_window));
+
+ GTK_WIDGET_CLASS (gtk_viewport_parent_class)->draw (widget, cr);