mirror of git://git.suckless.org/dwm
cleaner drawing
This commit is contained in:
parent
04797343db
commit
2255bf46a0
22
dwm.c
22
dwm.c
|
@ -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);
|
||||||
|
|
Loading…
Reference in New Issue