win_draw_bar: simplify logic a bit
This commit is contained in:
parent
b6d9e7d24f
commit
1fbff6d539
14
window.c
14
window.c
|
@ -470,17 +470,15 @@ static void win_draw_bar(win_t *win)
|
||||||
XSetBackground(e->dpy, gc, win->bar_bg.pixel);
|
XSetBackground(e->dpy, gc, win->bar_bg.pixel);
|
||||||
|
|
||||||
if ((len = strlen(r->buf)) > 0) {
|
if ((len = strlen(r->buf)) > 0) {
|
||||||
if ((tw = TEXTWIDTH(win, r->buf, len)) > w) {
|
if ((tw = TEXTWIDTH(win, r->buf, len)) <= w) {
|
||||||
XftDrawDestroy(d);
|
x = win->w - tw - H_TEXT_PAD;
|
||||||
return;
|
win_draw_text(win, d, &win->bar_fg, x, y, r->buf, len, tw);
|
||||||
}
|
}
|
||||||
x = win->w - tw - H_TEXT_PAD;
|
/* remaining width, also keeping gap between left and right parts */
|
||||||
w -= tw;
|
w -= tw + (2 * H_TEXT_PAD);
|
||||||
win_draw_text(win, d, &win->bar_fg, x, y, r->buf, len, tw);
|
|
||||||
}
|
}
|
||||||
if ((len = strlen(l->buf)) > 0) {
|
if ((len = strlen(l->buf)) > 0 && w > 0) {
|
||||||
x = H_TEXT_PAD;
|
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);
|
win_draw_text(win, d, &win->bar_fg, x, y, l->buf, len, w);
|
||||||
}
|
}
|
||||||
XftDrawDestroy(d);
|
XftDrawDestroy(d);
|
||||||
|
|
Loading…
Reference in a new issue