diff --git a/window.c b/window.c index 387d789..3c8b3f0 100644 --- a/window.c +++ b/window.c @@ -470,17 +470,15 @@ static void win_draw_bar(win_t *win) XSetBackground(e->dpy, gc, win->bar_bg.pixel); if ((len = strlen(r->buf)) > 0) { - if ((tw = TEXTWIDTH(win, r->buf, len)) > w) { - XftDrawDestroy(d); - return; + if ((tw = TEXTWIDTH(win, r->buf, len)) <= w) { + x = win->w - tw - H_TEXT_PAD; + win_draw_text(win, d, &win->bar_fg, x, y, r->buf, len, tw); } - x = win->w - tw - H_TEXT_PAD; - w -= tw; - win_draw_text(win, d, &win->bar_fg, x, y, r->buf, len, tw); + /* remaining width, also keeping gap between left and right parts */ + w -= tw + (2 * H_TEXT_PAD); } - if ((len = strlen(l->buf)) > 0) { + if ((len = strlen(l->buf)) > 0 && w > 0) { x = H_TEXT_PAD; - w -= 2 * H_TEXT_PAD; /* gap between left and right parts */ win_draw_text(win, d, &win->bar_fg, x, y, l->buf, len, w); } XftDrawDestroy(d);