diff options
| author | Simon Tatham <anakin@pobox.com> | 2017-02-27 19:26:06 +0000 |
|---|---|---|
| committer | Simon Tatham <anakin@pobox.com> | 2017-02-27 19:26:06 +0000 |
| commit | 1f613ba31f2599bf29c35d5a46cc81594f6844ea (patch) | |
| tree | ab8e5b4a685dc43ffdfe2fb833ae06d0bb2e3446 | |
| parent | f3ca0e5af8b0ccb7400accc946e0a32e290b0206 (diff) | |
| download | puzzles-1f613ba31f2599bf29c35d5a46cc81594f6844ea.zip puzzles-1f613ba31f2599bf29c35d5a46cc81594f6844ea.tar.gz puzzles-1f613ba31f2599bf29c35d5a46cc81594f6844ea.tar.bz2 puzzles-1f613ba31f2599bf29c35d5a46cc81594f6844ea.tar.xz | |
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.
| -rw-r--r-- | gtk.c | 31 |
1 files changed, 25 insertions, 6 deletions
@@ -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) |