#include <cairo/cairo-xcb.h>
+/* We need to flush cairo surfaces twice to avoid an assertion bug. See #1989
+ * and https://bugs.freedesktop.org/show_bug.cgi?id=92455. */
+#define CAIRO_SURFACE_FLUSH(surface) \
+ do { \
+ cairo_surface_flush(surface); \
+ cairo_surface_flush(surface); \
+ } while (0)
+
/* Represents a color split by color channel. */
typedef struct color_t {
double red;
*/
void cairo_draw_text(i3String *text, surface_t *surface, color_t fg_color, color_t bg_color, int x, int y, int max_width) {
/* Flush any changes before we draw the text as this might use XCB directly. */
- cairo_surface_flush(surface->surface);
+ CAIRO_SURFACE_FLUSH(surface->surface);
set_font_colors(surface->gc, fg_color.colorpixel, bg_color.colorpixel);
draw_text(text, surface->id, surface->gc, visual_type, x, y, max_width);
/* Make sure we flush the surface for any text drawing operations that could follow.
* Since we support drawing text via XCB, we need this. */
- cairo_surface_flush(surface->surface);
+ CAIRO_SURFACE_FLUSH(surface->surface);
cairo_restore(surface->cr);
}
/* Make sure we flush the surface for any text drawing operations that could follow.
* Since we support drawing text via XCB, we need this. */
- cairo_surface_flush(src->surface);
- cairo_surface_flush(dest->surface);
+ CAIRO_SURFACE_FLUSH(src->surface);
+ CAIRO_SURFACE_FLUSH(dest->surface);
cairo_restore(dest->cr);
}
cairo_set_source_color(&statusline_surface, colors.bar_bg);
cairo_set_operator(statusline_surface.cr, CAIRO_OPERATOR_SOURCE);
cairo_paint(statusline_surface.cr);
- cairo_surface_flush(statusline_surface.surface);
+ CAIRO_SURFACE_FLUSH(statusline_surface.surface);
cairo_restore(statusline_surface.cr);
/* Draw the text of each block. */
cairo_set_source_color(&(outputs_walk->buffer), colors.bar_bg);
cairo_set_operator(outputs_walk->buffer.cr, CAIRO_OPERATOR_SOURCE);
cairo_paint(outputs_walk->buffer.cr);
- cairo_surface_flush(outputs_walk->buffer.surface);
+ CAIRO_SURFACE_FLUSH(outputs_walk->buffer.surface);
cairo_restore(outputs_walk->buffer.cr);
if (!config.disable_ws) {
cairo_move_to(cr, x, y - yoffset);
pango_cairo_show_layout(cr, layout);
+ /* We need to flush cairo surfaces twice to avoid an assertion bug. See #1989
+ * and https://bugs.freedesktop.org/show_bug.cgi?id=92455. */
+ cairo_surface_flush(surface);
cairo_surface_flush(surface);
/* Free resources */