From c93a225b979e67bc04a9443104ab5505e9299d2e Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Thu, 10 Apr 2025 10:09:07 +0100 Subject: [PATCH] GTK: use cairo_paint() to copy from backing store to screen I just found cairo_paint() while wandering the Cairo documentation. It just fills the entire clip region with data from the current source, which is precisely what draw_area() wants to do. This is simpler for us than requesting the bounding rectangle of the clipping region and then filling it, and as far as I can tell the clipping rectangle generally covers the whole window anyway. --- unix/window.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/unix/window.c b/unix/window.c index 66da32fa..1379b6ef 100644 --- a/unix/window.c +++ b/unix/window.c @@ -953,7 +953,6 @@ static gint draw_area(GtkWidget *widget, cairo_t *cr, gpointer data) * inst->surface to the window. */ if (inst->surface) { - GdkRectangle dirtyrect; cairo_surface_t *target_surface; double orig_sx, orig_sy; cairo_matrix_t m; @@ -982,12 +981,8 @@ static gint draw_area(GtkWidget *widget, cairo_t *cr, gpointer data) cairo_surface_set_device_scale(target_surface, 1.0, 1.0); cairo_translate(cr, m.x0 * (orig_sx - 1.0), m.y0 * (orig_sy - 1.0)); - gdk_cairo_get_clip_rectangle(cr, &dirtyrect); - cairo_set_source_surface(cr, inst->surface, 0, 0); - cairo_rectangle(cr, dirtyrect.x, dirtyrect.y, - dirtyrect.width, dirtyrect.height); - cairo_fill(cr); + cairo_paint(cr); cairo_surface_set_device_scale(target_surface, orig_sx, orig_sy); }