From ec2b9a51651f29265cc2210313564ac3a0c9bb76 Mon Sep 17 00:00:00 2001 From: Brandon Wright Date: Thu, 7 Dec 2017 11:36:24 -0600 Subject: [PATCH] Fix warnings on GTK+ display driver with GTK+ 3. --- gtk/src/gtk_display_driver_gtk.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/gtk/src/gtk_display_driver_gtk.cpp b/gtk/src/gtk_display_driver_gtk.cpp index 5b3b069d..423b80ca 100644 --- a/gtk/src/gtk_display_driver_gtk.cpp +++ b/gtk/src/gtk_display_driver_gtk.cpp @@ -108,7 +108,15 @@ S9xGTKDisplayDriver::output (void *src, height, 24); +#ifndef USE_GTK3 cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (drawing_area)); +#else + cairo_rectangle_int_t rect = { x, y, dst_width, dst_height }; + cairo_region_t *region = cairo_region_create_rectangle (&rect); + GdkDrawingContext *context = gdk_window_begin_draw_frame (gtk_widget_get_window (drawing_area), + region); + cairo_t *cr = gdk_drawing_context_get_cairo_context (context); +#endif gdk_cairo_set_source_pixbuf (cr, pixbuf, x, y); @@ -132,7 +140,12 @@ S9xGTKDisplayDriver::output (void *src, cairo_rectangle (cr, x, y, dst_width, dst_height); cairo_fill (cr); +#ifndef USE_GTK3 cairo_destroy (cr); +#else + gdk_window_end_draw_frame (gtk_widget_get_window (drawing_area), context); + cairo_region_destroy (region); +#endif window->set_mouseable_area (x, y, width, height); @@ -206,7 +219,15 @@ S9xGTKDisplayDriver::clear (void) width = allocation.width; height = allocation.height; +#ifndef USE_GTK3 cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (drawing_area)); +#else + cairo_rectangle_int_t rect = { 0, 0, width, height }; + cairo_region_t *region = cairo_region_create_rectangle (&rect); + GdkDrawingContext *context = gdk_window_begin_draw_frame (gtk_widget_get_window (drawing_area), + region); + cairo_t *cr = gdk_drawing_context_get_cairo_context (context); +#endif cairo_set_source_rgb (cr, 0.0, 0.0, 0.0); @@ -243,7 +264,13 @@ S9xGTKDisplayDriver::clear (void) } cairo_fill (cr); + +#ifndef USE_GTK3 cairo_destroy (cr); +#else + gdk_window_end_draw_frame (gtk_widget_get_window (drawing_area), context); + cairo_region_destroy (region); +#endif return; }