cleaner drawing

This commit is contained in:
Connor Lane Smith 2011-06-04 10:17:25 +01:00
parent 04797343db
commit 2255bf46a0
1 changed files with 6 additions and 16 deletions

22
dwm.c
View File

@ -780,32 +780,22 @@ drawbars(void) {
void void
drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]) { drawsquare(Bool filled, Bool empty, Bool invert, unsigned long col[ColLast]) {
int x; int x;
XGCValues gcv;
XRectangle r = { dc.x, dc.y, dc.w, dc.h };
gcv.foreground = col[invert ? ColBG : ColFG]; XSetForeground(dpy, dc.gc, col[invert ? ColFG : ColBG]);
XChangeGC(dpy, dc.gc, GCForeground, &gcv);
x = (dc.font.ascent + dc.font.descent + 2) / 4; x = (dc.font.ascent + dc.font.descent + 2) / 4;
r.x = dc.x + 1; if(filled)
r.y = dc.y + 1; XFillRectangle(dpy, dc.drawable, dc.gc, dc.x+1, dc.y+1, x+1, x+1);
if(filled) { else if(empty)
r.width = r.height = x + 1; XDrawRectangle(dpy, dc.drawable, dc.gc, dc.x+1, dc.y+1, x, x);
XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
}
else if(empty) {
r.width = r.height = x;
XDrawRectangles(dpy, dc.drawable, dc.gc, &r, 1);
}
} }
void void
drawtext(const char *text, unsigned long col[ColLast], Bool invert) { drawtext(const char *text, unsigned long col[ColLast], Bool invert) {
char buf[256]; char buf[256];
int i, x, y, h, len, olen; int i, x, y, h, len, olen;
XRectangle r = { dc.x, dc.y, dc.w, dc.h };
XSetForeground(dpy, dc.gc, col[invert ? ColFG : ColBG]); XSetForeground(dpy, dc.gc, col[invert ? ColFG : ColBG]);
XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1); XFillRectangle(dpy, dc.drawable, dc.gc, dc.x, dc.y, dc.w, dc.h);
if(!text) if(!text)
return; return;
olen = strlen(text); olen = strlen(text);