# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1496445915 0 # Node ID fe04bcfd5b65bd5ef97bb597b38b6507ab55c8a6 # Parent 25da63f0eddc643f623269dc0f92405a552bb655 GTK3: Need to use cairo region in that new code or else drawing functions crash. diff -r 25da63f0eddc -r fe04bcfd5b65 gtk3/dw.c --- a/gtk3/dw.c Fri Jun 02 22:49:09 2017 +0000 +++ b/gtk3/dw.c Fri Jun 02 23:25:15 2017 +0000 @@ -7172,6 +7172,7 @@ cairo_t *cr = NULL; #if GTK_CHECK_VERSION(3,22,0) GdkDrawingContext *dc = NULL; + cairo_region_t *clip = NULL; #endif DW_MUTEX_LOCK; @@ -7185,7 +7186,8 @@ return; } #if GTK_CHECK_VERSION(3,22,0) - dc = gdk_window_begin_draw_frame(window, NULL); + clip = gdk_window_get_clip_region(window); + dc = gdk_window_begin_draw_frame(window, clip); cr = gdk_drawing_context_get_cairo_context(dc); #else cr = gdk_cairo_create(window); @@ -7202,10 +7204,14 @@ cairo_move_to(cr, x, y); cairo_stroke(cr); #if GTK_CHECK_VERSION(3,22,0) + if(clip) + cairo_region_destroy(clip); /* If we are using a drawing context... * we don't own the cairo context so don't destroy it. */ - if(!dc) + if(dc) + gdk_window_end_draw_frame(gtk_widget_get_window(handle), dc); + else #endif cairo_destroy(cr); } @@ -7227,6 +7233,7 @@ cairo_t *cr = NULL; #if GTK_CHECK_VERSION(3,22,0) GdkDrawingContext *dc = NULL; + cairo_region_t *clip = NULL; #endif DW_MUTEX_LOCK; @@ -7240,7 +7247,8 @@ return; } #if GTK_CHECK_VERSION(3,22,0) - dc = gdk_window_begin_draw_frame(window, NULL); + clip = gdk_window_get_clip_region(window); + dc = gdk_window_begin_draw_frame(window, clip); cr = gdk_drawing_context_get_cairo_context(dc); #else cr = gdk_cairo_create(window); @@ -7258,10 +7266,14 @@ cairo_line_to(cr, x2, y2); cairo_stroke(cr); #if GTK_CHECK_VERSION(3,22,0) + if(clip) + cairo_region_destroy(clip); /* If we are using a drawing context... * we don't own the cairo context so don't destroy it. */ - if(!dc) + if(dc) + gdk_window_end_draw_frame(gtk_widget_get_window(handle), dc); + else #endif cairo_destroy(cr); } @@ -7284,6 +7296,7 @@ int z; #if GTK_CHECK_VERSION(3,22,0) GdkDrawingContext *dc = NULL; + cairo_region_t *clip = NULL; #endif DW_MUTEX_LOCK; @@ -7297,7 +7310,8 @@ return; } #if GTK_CHECK_VERSION(3,22,0) - dc = gdk_window_begin_draw_frame(window, NULL); + clip = gdk_window_get_clip_region(window); + dc = gdk_window_begin_draw_frame(window, clip); cr = gdk_drawing_context_get_cairo_context(dc); #else cr = gdk_cairo_create(window); @@ -7323,10 +7337,14 @@ cairo_fill(cr); cairo_stroke(cr); #if GTK_CHECK_VERSION(3,22,0) + if(clip) + cairo_region_destroy(clip); /* If we are using a drawing context... * we don't own the cairo context so don't destroy it. */ - if(!dc) + if(dc) + gdk_window_end_draw_frame(gtk_widget_get_window(handle), dc); + else #endif cairo_destroy(cr); } @@ -7349,6 +7367,7 @@ cairo_t *cr = NULL; #if GTK_CHECK_VERSION(3,22,0) GdkDrawingContext *dc = NULL; + cairo_region_t *clip = NULL; #endif DW_MUTEX_LOCK; @@ -7362,7 +7381,8 @@ return; } #if GTK_CHECK_VERSION(3,22,0) - dc = gdk_window_begin_draw_frame(window, NULL); + clip = gdk_window_get_clip_region(window); + dc = gdk_window_begin_draw_frame(window, clip); cr = gdk_drawing_context_get_cairo_context(dc); #else cr = gdk_cairo_create(window); @@ -7387,10 +7407,14 @@ cairo_fill(cr); cairo_stroke(cr); #if GTK_CHECK_VERSION(3,22,0) + if(clip) + cairo_region_destroy(clip); /* If we are using a drawing context... * we don't own the cairo context so don't destroy it. */ - if(!dc) + if(dc) + gdk_window_end_draw_frame(gtk_widget_get_window(handle), dc); + else #endif cairo_destroy(cr); } @@ -7416,6 +7440,7 @@ cairo_t *cr = NULL; #if GTK_CHECK_VERSION(3,22,0) GdkDrawingContext *dc = NULL; + cairo_region_t *clip = NULL; #endif DW_MUTEX_LOCK; @@ -7429,7 +7454,8 @@ return; } #if GTK_CHECK_VERSION(3,22,0) - dc = gdk_window_begin_draw_frame(window, NULL); + clip = gdk_window_get_clip_region(window); + dc = gdk_window_begin_draw_frame(window, clip); cr = gdk_drawing_context_get_cairo_context(dc); #else cr = gdk_cairo_create(window); @@ -7466,10 +7492,14 @@ cairo_fill(cr); cairo_stroke(cr); #if GTK_CHECK_VERSION(3,22,0) + if(clip) + cairo_region_destroy(clip); /* If we are using a drawing context... * we don't own the cairo context so don't destroy it. */ - if(!dc) + if(dc) + gdk_window_end_draw_frame(gtk_widget_get_window(handle), dc); + else #endif cairo_destroy(cr); } @@ -7492,6 +7522,7 @@ char *tmpname, *fontname = "monospace 10"; #if GTK_CHECK_VERSION(3,22,0) GdkDrawingContext *dc = NULL; + cairo_region_t *clip = NULL; #endif if(!text) @@ -7508,7 +7539,8 @@ return; } #if GTK_CHECK_VERSION(3,22,0) - dc = gdk_window_begin_draw_frame(window, NULL); + clip = gdk_window_get_clip_region(window); + dc = gdk_window_begin_draw_frame(window, clip); cr = gdk_drawing_context_get_cairo_context(dc); #else cr = gdk_cairo_create(window); @@ -7569,10 +7601,14 @@ pango_font_description_free(font); } #if GTK_CHECK_VERSION(3,22,0) + if(clip) + cairo_region_destroy(clip); /* If we are using a drawing context... * we don't own the cairo context so don't destroy it. */ - if(!dc) + if(dc) + gdk_window_end_draw_frame(gtk_widget_get_window(handle), dc); + else #endif cairo_destroy(cr); } @@ -7918,6 +7954,7 @@ int retval = DW_ERROR_GENERAL; #if GTK_CHECK_VERSION(3,22,0) GdkDrawingContext *dc = NULL; + cairo_region_t *clip = NULL; #endif if((!dest && (!destp || !destp->image)) || (!src && (!srcp || !srcp->image))) @@ -7934,7 +7971,8 @@ return retval; } #if GTK_CHECK_VERSION(3,22,0) - dc = gdk_window_begin_draw_frame(window, NULL); + clip = gdk_window_get_clip_region(window); + dc = gdk_window_begin_draw_frame(window, clip); cr = gdk_drawing_context_get_cairo_context(dc); #else cr = gdk_cairo_create(window); @@ -7962,10 +8000,14 @@ cairo_rectangle(cr, xdest / xscale, ydest / yscale, width, height); cairo_fill(cr); #if GTK_CHECK_VERSION(3,22,0) + if(clip) + cairo_region_destroy(clip); /* If we are using a drawing context... * we don't own the cairo context so don't destroy it. */ - if(!dc) + if(dc) + gdk_window_end_draw_frame(gtk_widget_get_window(dest), dc); + else #endif cairo_destroy(cr); retval = DW_ERROR_NONE;