X-Git-Url: https://jasonwoof.com/gitweb/?a=blobdiff_plain;f=draw.c;h=fe5b7cb9699cb333594b7eb44888bb6e8a85137b;hb=4b0328f2097dedd70bbb36ea2b5159ac55b7cbcb;hp=506a86290f2798ef8d5f38a0a61149d1a48f45a6;hpb=8cc7f3bace087dfb024a23115c211d82b35614ae;p=dwm.git diff --git a/draw.c b/draw.c index 506a862..fe5b7cb 100644 --- a/draw.c +++ b/draw.c @@ -9,26 +9,6 @@ /* static */ -static void -drawborder(void) -{ - XPoint points[5]; - - XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter); - XSetForeground(dpy, dc.gc, dc.border); - points[0].x = dc.x; - points[0].y = dc.y; - points[1].x = dc.w - 1; - points[1].y = 0; - points[2].x = 0; - points[2].y = dc.h - 1; - points[3].x = -(dc.w - 1); - points[3].y = 0; - points[4].x = 0; - points[4].y = -(dc.h - 1); - XDrawLines(dpy, dc.drawable, dc.gc, points, 5, CoordModePrevious); -} - static unsigned int textnw(const char *text, unsigned int len) { @@ -42,24 +22,21 @@ textnw(const char *text, unsigned int len) } static void -drawtext(const char *text, Bool invert, Bool border) +drawtext(const char *text, Bool invert) { int x, y, w, h; static char buf[256]; unsigned int len; XGCValues gcv; + XPoint points[5]; XRectangle r = { dc.x, dc.y, dc.w, dc.h }; XSetForeground(dpy, dc.gc, invert ? dc.fg : dc.bg); XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1); - - w = 0; - if(border) - drawborder(); - if(!text) return; + w = 0; len = strlen(text); if(len >= sizeof(buf)) len = sizeof(buf) - 1; @@ -89,6 +66,19 @@ drawtext(const char *text, Bool invert, Bool border) XChangeGC(dpy, dc.gc, GCForeground | GCBackground | GCFont, &gcv); XDrawImageString(dpy, dc.drawable, dc.gc, x, y, buf, len); } + + XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter); + points[0].x = dc.x; + points[0].y = dc.y; + points[1].x = dc.w - 1; + points[1].y = 0; + points[2].x = 0; + points[2].y = dc.h - 1; + points[3].x = -(dc.w - 1); + points[3].y = 0; + points[4].x = 0; + points[4].y = -(dc.h - 1); + XDrawLines(dpy, dc.drawable, dc.gc, points, 5, CoordModePrevious); } /* extern */ @@ -111,24 +101,24 @@ drawstatus() dc.x = dc.y = 0; dc.w = bw; - drawtext(NULL, !istile, False); + drawtext(NULL, !istile); dc.w = 0; - for(i = 0; i < TLast; i++) { + for(i = 0; i < ntags; i++) { dc.x += dc.w; dc.w = textw(tags[i]); if(istile) - drawtext(tags[i], (i == tsel), True); + drawtext(tags[i], (i == tsel)); else - drawtext(tags[i], (i != tsel), True); + drawtext(tags[i], (i != tsel)); } x = dc.x + dc.w; dc.w = textw(stext); dc.x = bx + bw - dc.w; - drawtext(stext, !istile, False); + drawtext(stext, !istile); if(sel && ((dc.w = dc.x - x) >= bh)) { dc.x = x; - drawtext(sel->name, istile, True); + drawtext(sel->name, istile); } XCopyArea(dpy, dc.drawable, barwin, dc.gc, 0, 0, bw, bh, 0, 0); XSync(dpy, False); @@ -153,16 +143,16 @@ drawtitle(Client *c) dc.x = dc.y = 0; dc.w = 0; - for(i = 0; i < TLast; i++) { + for(i = 0; i < ntags; i++) { if(c->tags[i]) { dc.x += dc.w; dc.w = textw(tags[i]); - drawtext(tags[i], !istile, True); + drawtext(tags[i], !istile); } } dc.x += dc.w; dc.w = textw(c->name); - drawtext(c->name, !istile, True); + drawtext(c->name, !istile); XCopyArea(dpy, dc.drawable, c->title, dc.gc, 0, 0, c->tw, c->th, 0, 0); XSync(dpy, False); }