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);
|
||||
|
||||
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);
|
||||
|
|
Loading…
Reference in a new issue