From 802d9fa48749bbe0b43d3315943c728712f4de1f Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 18 Mar 2024 10:47:31 -0600 Subject: [PATCH] correctly implement canvas expose redraw for both single- and multi-expose contexts --- libs/canvas/canvas.cc | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/libs/canvas/canvas.cc b/libs/canvas/canvas.cc index 1ace28f8c0..2721c6c96b 100644 --- a/libs/canvas/canvas.cc +++ b/libs/canvas/canvas.cc @@ -1027,14 +1027,14 @@ GtkCanvas::on_expose_event (GdkEventExpose* ev) draw_context->push_group (); } - /* draw background color */ - draw_context->rectangle (ev->area.x, ev->area.y, ev->area.width, ev->area.height); - Gtkmm2ext::set_source_rgba (draw_context, _bg_color); - draw_context->fill (); - /* render canvas */ if (_single_exposure) { + /* draw background color */ + draw_context->rectangle (ev->area.x, ev->area.y, ev->area.width, ev->area.height); + Gtkmm2ext::set_source_rgba (draw_context, _bg_color); + draw_context->fill (); + Canvas::render (Rect (ev->area.x, ev->area.y, ev->area.x + ev->area.width, ev->area.y + ev->area.height), draw_context); } else { @@ -1042,10 +1042,18 @@ GtkCanvas::on_expose_event (GdkEventExpose* ev) gint nrects; gdk_region_get_rectangles (ev->region, &rects, &nrects); + for (gint n = 0; n < nrects; ++n) { draw_context->set_identity_matrix(); //reset the cairo matrix, just in case someone left it transformed after drawing ( cough ) + + /* draw background color */ + draw_context->rectangle (rects[n].x, rects[n].y, rects[n].x + rects[n].width, rects[n].y + rects[n].height); + Gtkmm2ext::set_source_rgba (draw_context, _bg_color); + draw_context->fill (); + Canvas::render (Rect (rects[n].x, rects[n].y, rects[n].x + rects[n].width, rects[n].y + rects[n].height), draw_context); } + g_free (rects); }