GTK API deprecation: in GTK 3.22, stop using gdk_cairo_create.

This is another annoyingly removed function, replaced by a tower of
about four assorted objects you have to create in succession.
This commit is contained in:
Simon Tatham
2017-02-27 19:26:06 +00:00
parent f3ca0e5af8
commit 1f613ba31f

31
gtk.c
View File

@ -462,11 +462,13 @@ static void clear_backing_store(frontend *fe)
fe->image = NULL;
}
static void wipe_and_destroy_cairo(frontend *fe, cairo_t *cr)
static void wipe_and_maybe_destroy_cairo(frontend *fe, cairo_t *cr,
int destroy)
{
cairo_set_source_rgb(cr, fe->colours[0], fe->colours[1], fe->colours[2]);
cairo_paint(cr);
cairo_destroy(cr);
if (destroy)
cairo_destroy(cr);
}
static void setup_backing_store(frontend *fe)
@ -478,12 +480,29 @@ static void setup_backing_store(frontend *fe)
fe->image = cairo_image_surface_create(CAIRO_FORMAT_RGB24,
fe->pw, fe->ph);
wipe_and_destroy_cairo(fe, cairo_create(fe->image));
wipe_and_maybe_destroy_cairo(fe, cairo_create(fe->image), TRUE);
#ifndef USE_CAIRO_WITHOUT_PIXMAP
wipe_and_destroy_cairo(fe, gdk_cairo_create(fe->pixmap));
wipe_and_maybe_destroy_cairo(fe, gdk_cairo_create(fe->pixmap), TRUE);
#endif
#if GTK_CHECK_VERSION(3,22,0)
{
GdkWindow *gdkwin;
cairo_region_t *region;
GdkDrawingContext *drawctx;
cairo_t *cr;
gdkwin = gtk_widget_get_window(fe->area);
region = gdk_window_get_clip_region(gdkwin);
drawctx = gdk_window_begin_draw_frame(gdkwin, region);
cr = gdk_drawing_context_get_cairo_context(drawctx);
wipe_and_maybe_destroy_cairo(fe, cr, FALSE);
gdk_window_end_draw_frame(gdkwin, drawctx);
cairo_region_destroy(region);
}
#else
wipe_and_maybe_destroy_cairo(
fe, gdk_cairo_create(gtk_widget_get_window(fe->area)), TRUE);
#endif
wipe_and_destroy_cairo(fe, gdk_cairo_create
(gtk_widget_get_window(fe->area)));
}
static int backing_store_ok(frontend *fe)