From a12b73a36fc19941938adafdec1cd1c9f861f3b5 Mon Sep 17 00:00:00 2001 From: Bakkeby Date: Tue, 6 May 2025 14:41:20 +0200 Subject: [PATCH] Refactoring Xft clipping ref. #175 --- x.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/x.c b/x.c index 249e056..e540322 100644 --- a/x.c +++ b/x.c @@ -2281,20 +2281,9 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i else #endif // BACKGROUND_IMAGE_PATCH - #if !WIDE_GLYPHS_PATCH - XftDrawRect(xw.draw, bg, winx, winy, width, win.ch); - #endif // WIDE_GLYPHS_PATCH - - /* Set the clip region because Xft is sometimes dirty. */ - r.x = 0; - r.y = 0; - r.height = win.ch; - r.width = width; - XftDrawSetClipRectangles(xw.draw, winx, winy, &r, 1); - - #if WIDE_GLYPHS_PATCH /* Fill the background */ XftDrawRect(xw.draw, bg, winx, winy, width, win.ch); + #if WIDE_GLYPHS_PATCH } #endif // WIDE_GLYPHS_PATCH @@ -2305,13 +2294,27 @@ xdrawglyphfontspecs(const XftGlyphFontSpec *specs, Glyph base, int len, int x, i if (base.mode & ATTR_BOXDRAW) { drawboxes(winx, winy, width / len, win.ch, fg, bg, specs, len); } else { - /* Render the glyphs. */ - XftDrawGlyphFontSpec(xw.draw, fg, specs, len); - } + #endif // BOXDRAW_PATCH + /* Set the clip region because Xft is sometimes dirty. */ + #if WIDE_GLYPHS_PATCH + r.x = 0; + r.y = 0; + r.height = win.ch; + r.width = win.w; + XftDrawSetClipRectangles(xw.draw, 0, winy, &r, 1); #else + r.x = 0; + r.y = 0; + r.height = win.ch; + r.width = width; + XftDrawSetClipRectangles(xw.draw, winx, winy, &r, 1); + #endif // WIDE_GLYPHS_PATCH + #if BOXDRAW_PATCH + } + #endif // BOXDRAW_PATCH + /* Render the glyphs. */ XftDrawGlyphFontSpec(xw.draw, fg, specs, len); - #endif // BOXDRAW_PATCH /* Render underline and strikethrough. */ if (base.mode & ATTR_UNDERLINE) {