From d8a83b500fca038d38bb6364c5d16d8b420f8afd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Fri, 5 Jun 2020 08:10:38 +0200 Subject: [PATCH] render: regression: don't let cell background overflow into the margins This used to work before because we had a "global" clip region on the text area, excluding the margins. When we introduced per-cell clipping, this global clip region was removed, and the background drawing code could now overflow into the margins. This fixes it by setting the cell clip region not just when rendering a glyph, but before we render the cell background. --- render.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/render.c b/render.c index 869c315a..136ca4f3 100644 --- a/render.c +++ b/render.c @@ -418,7 +418,14 @@ render_cell(struct terminal *term, pixman_image_t *pix, glyph = fcft_glyph_rasterize(font, base, term->font_subpixel); } - int cell_cols = glyph != NULL ? max(1, glyph->cols) : 1; + const int cols_left = term->cols - col; + int cell_cols = glyph != NULL ? max(1, min(glyph->cols, cols_left)) : 1; + + pixman_region32_t clip; + pixman_region32_init_rect( + &clip, x, y, + cell_cols * term->cell_width, term->cell_height); + pixman_image_set_clip_region32(pix, &clip); /* Background */ pixman_image_fill_rectangles( @@ -438,11 +445,6 @@ render_cell(struct terminal *term, pixman_image_t *pix, if (glyph != NULL) { /* Clip to cell */ - pixman_region32_t clip; - pixman_region32_init_rect( - &clip, x, y, glyph->cols * term->cell_width, term->cell_height); - pixman_image_set_clip_region32(pix, &clip); - if (unlikely(pixman_image_get_format(glyph->pix) == PIXMAN_a8r8g8b8)) { /* Glyph surface is a pre-rendered image (typically a color emoji...) */ if (!(cell->attrs.blink && term->blink.state == BLINK_OFF)) {