when the scroll bars and the edit widget share the same X window. */
GdkWindow *window = gtk_widget_get_window (FRAME_GTK_WIDGET (f));
#ifdef HAVE_GTK3
+#if GTK_CHECK_VERSION (3, 22, 0)
+ cairo_region_t *region = gdk_window_get_visible_region (window);
+ GdkDrawingContext *context = gdk_window_begin_draw_frame (window, region);
+ cairo_t *cr = gdk_drawing_context_get_cairo_context (context);
+#else
cairo_t *cr = gdk_cairo_create (window);
+#endif
cairo_set_source_rgb (cr, 1, 1, 1);
cairo_set_operator (cr, CAIRO_OPERATOR_DIFFERENCE);
#define XFillRectangle(d, win, gc, x, y, w, h) \
#ifdef USE_GTK
#ifdef HAVE_GTK3
+#if GTK_CHECK_VERSION (3, 22, 0)
+ gdk_window_end_draw_frame (window, context);
+ cairo_region_destroy (region);
+#else
cairo_destroy (cr);
+#endif
#else
g_object_unref (G_OBJECT (gc));
#endif