X-Git-Url: https://jasonwoof.com/gitweb/?p=dwm.git;a=blobdiff_plain;f=dwm.c;h=ada272c6caf5d11223c8872002b462ae2ef5ead1;hp=3b6efaaa4f80121ea19800923ebdef07b911c410;hb=08bcf721b436018306bdbb9fbaca87f941ee6441;hpb=c26e22cceeee5fdd40e6bd6e019729ed316e2e01 diff --git a/dwm.c b/dwm.c index 3b6efaa..ada272c 100644 --- a/dwm.c +++ b/dwm.c @@ -551,7 +551,7 @@ drawsquare(Bool filled, Bool empty, Bool invert, ulong col[ColLast]) { void drawtext(const char *text, ulong col[ColLast], Bool invert) { - int x, y, w, h; + int i, x, y, h; uint len, olen; XRectangle r = { dc.x, dc.y, dc.w, dc.h }; char buf[256]; @@ -563,16 +563,15 @@ drawtext(const char *text, ulong col[ColLast], Bool invert) { olen = strlen(text); len = MIN(olen, sizeof buf); memcpy(buf, text, len); - w = 0; h = dc.font.ascent + dc.font.descent; y = dc.y + (dc.h / 2) - (h / 2) + dc.font.ascent; x = dc.x + (h / 2); /* shorten text if necessary */ - for(; len && (w = textnw(buf, len)) > dc.w - h; len--); + for(; len && (i = textnw(buf, len)) > dc.w - h; len--); if(!len) return; if(len < olen) - strncpy(&buf[MAX(0, len - 3)], "...", len); + for(i = len; i >= MAX(0, len - 3); buf[i--] = '.'); XSetForeground(dpy, dc.gc, col[invert ? ColBG : ColFG]); if(dc.font.set) XmbDrawString(dpy, dc.drawable, dc.font.set, dc.gc, x, y, buf, len); @@ -1442,13 +1441,13 @@ tile(void) { /* master */ c = nexttiled(clients); mw = mfact * ww; - resize(c, wx, wy, ((n == 1) ? ww : mw) - 2 * c->bw, wh - 2 * c->bw, resizehints); + resize(c, wx, wy, (n == 1 ? ww : mw) - 2 * c->bw, wh - 2 * c->bw, resizehints); if(--n == 0) return; /* tile stack */ - x = (wx + mw > c->x + c->w) ? c->x + c->w + 2 * c->bw : ww - mw; + x = (wx + mw > c->x + c->w) ? c->x + c->w + 2 * c->bw : wx + mw; y = wy; w = (wx + mw > c->x + c->w) ? wx + ww - x : ww - mw; h = wh / n;