[hackers] [st] [PATCH] Replace four XftDrawRect calls with one XDrawRectangle

From: noname <noname_AT_inventati.org>
Date: Sun, 6 Dec 2015 19:10:24 +0000

This part looks especially ugly, effectively uses XftDrawRect to draw
lines, so I suggest to rewrite it this way.

---
 st.c | 21 +++++----------------
 1 file changed, 5 insertions(+), 16 deletions(-)
diff --git a/st.c b/st.c
index c5d62c1..32e4c55 100644
--- a/st.c
+++ b/st.c
_AT_@ -3908,22 +3908,11 @@ xdrawcursor(void)
 			break;
 		}
 	} else {
-		XftDrawRect(xw.draw, &drawcol,
-				borderpx + curx * xw.cw,
-				borderpx + term.c.y * xw.ch,
-				xw.cw - 1, 1);
-		XftDrawRect(xw.draw, &drawcol,
-				borderpx + curx * xw.cw,
-				borderpx + term.c.y * xw.ch,
-				1, xw.ch - 1);
-		XftDrawRect(xw.draw, &drawcol,
-				borderpx + (curx + 1) * xw.cw - 1,
-				borderpx + term.c.y * xw.ch,
-				1, xw.ch - 1);
-		XftDrawRect(xw.draw, &drawcol,
-				borderpx + curx * xw.cw,
-				borderpx + (term.c.y + 1) * xw.ch - 1,
-				xw.cw, 1);
+		XSetForeground(xw.dpy, dc.gc, drawcol.pixel);
+		XDrawRectangle(xw.dpy, xw.buf, dc.gc,
+		               borderpx + curx * xw.cw,
+			       borderpx + term.c.y * xw.ch,
+			       xw.cw - 1, xw.ch - 1);
 	}
 	oldx = curx, oldy = term.c.y;
 }
-- 
2.4.10
Received on Sun Dec 06 2015 - 20:10:24 CET

This archive was generated by hypermail 2.3.0 : Sun Dec 06 2015 - 20:12:12 CET