talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit 7626388b45d8bd87b2f78cd89f76b52e9116bf7c
parent b7e8f5299b20bba15aca74d4d6702aef4ad6d94f
Author: Jonathan Boeing <jonathan.n.boeing@gmail.com>
Date:   Sun, 28 Feb 2021 18:56:08 -0700

Double-buffer row drawing in gtkcmctree

This patch fixes the slowness seen when redrawing the folder tree with
cairo > 1.10 on Windows.  It also improves the occasionally visible
flickering in the folder tree on Linux and Windows with older versions
of cairo.

Diffstat:
Mconfigure.ac | 2+-
Msrc/gtk/gtkcmctree.c | 21++++++++++++++++++++-
2 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/configure.ac b/configure.ac @@ -1234,7 +1234,7 @@ AC_SUBST(GDATA_CFLAGS) AC_SUBST(GDATA_LIBS) dnl cairo ********************************************************************** -PKG_CHECK_MODULES(CAIRO, cairo, HAVE_CAIRO=yes, HAVE_CAIRO=no) +PKG_CHECK_MODULES(CAIRO, cairo >= 1.12.0, HAVE_CAIRO=yes, HAVE_CAIRO=no) AC_SUBST(CAIRO_CFLAGS) AC_SUBST(CAIRO_LIBS) diff --git a/src/gtk/gtkcmctree.c b/src/gtk/gtkcmctree.c @@ -599,6 +599,8 @@ draw_row (GtkCMCList *clist, static GdkColor greybg={0, 0, 0, 0}; static gboolean color_change = TRUE; cairo_t *cr; + cairo_t *cr_hw; + cairo_surface_t *image_surface; GdkColor *fgcolor, *bgcolor; cm_return_if_fail (clist != NULL); @@ -667,7 +669,12 @@ draw_row (GtkCMCList *clist, } state = clist_row->state; - cr = gdk_cairo_create(clist->clist_window); + cr_hw = gdk_cairo_create(clist->clist_window); + image_surface = cairo_surface_create_similar_image(cairo_get_target(cr_hw), + CAIRO_FORMAT_RGB24, + gdk_window_get_width(clist->clist_window), + gdk_window_get_height(clist->clist_window)); + cr = cairo_create(image_surface); if (clist_row->fg_set && state != GTK_STATE_SELECTED) fgcolor = &clist_row->foreground; @@ -937,7 +944,19 @@ draw_row (GtkCMCList *clist, cairo_stroke(cr); } } + + cairo_set_operator(cr_hw, CAIRO_OPERATOR_SOURCE); + cairo_set_source_surface(cr_hw, image_surface, 0, 0); + cairo_rectangle(cr_hw, + row_rectangle.x, + row_rectangle.y - CELL_SPACING, + row_rectangle.width, + row_rectangle.height + CELL_SPACING * 2); + cairo_fill(cr_hw); + cairo_destroy(cr); + cairo_surface_destroy(image_surface); + cairo_destroy(cr_hw); } static void