- /* Create a new pixmap */
- GdkPixmap *newmap = gdk_pixmap_new(widget->window, allocation->width, allocation->height, -1);
- gdk_draw_rectangle( GDK_DRAWABLE(newmap), widget->style->white_gc, TRUE, 0, 0, allocation->width, allocation->height);
-
- /* Copy the contents of the old pixmap */
- if(oldmap != NULL)
- gdk_draw_drawable( GDK_DRAWABLE(newmap), widget->style->white_gc, GDK_DRAWABLE(oldmap), 0, 0, 0, 0, oldwidth, oldheight);
-
- /* Use the new pixmap */
- gtk_image_set_from_pixmap( GTK_IMAGE(widget), newmap, NULL );
- g_object_unref(newmap);
+ /* Create a new backing store */
+ cairo_surface_t *new_backing_store = gdk_window_create_similar_surface( gtk_widget_get_window(widget), CAIRO_CONTENT_COLOR, gtk_widget_get_allocated_width(widget), gtk_widget_get_allocated_height(widget) );
+ cairo_t *cr = cairo_create(new_backing_store);
+
+ /* Clear to background color */
+ glkcairo_set_source_glkcolor(cr, win->background_color);
+ cairo_paint(cr);
+
+ if(win->backing_store != NULL) {
+ /* Copy the contents of the old backing store */
+ cairo_set_source_surface(cr, win->backing_store, 0, 0);
+ cairo_paint(cr);
+ cairo_surface_destroy(win->backing_store);
+ }
+
+ cairo_destroy(cr);
+ /* Use the new backing store */
+ win->backing_store = new_backing_store;