| @@ -123,11 +123,6 @@ const char* win_res(Display *dpy, const char *name, const char *def) |
| 123 | 123 | | } |
| 124 | 124 | | } |
| 125 | 125 | | |
| 126 | | − | unsigned int win_luminance(const XftColor *col) |
| 127 | | − | { |
| 128 | | − | return (col->color.red + col->color.green + col->color.blue) / 3; |
| 129 | | − | } |
| 130 | | − | |
| 131 | 126 | | #define INIT_ATOM_(atom) \ |
| 132 | 127 | | atoms[ATOM_##atom] = XInternAtom(e->dpy, #atom, False); |
| 133 | 128 | | |
| @@ -159,8 +154,6 @@ void win_init(win_t *win) |
| 159 | 154 | | fg = win_res(e->dpy, RES_CLASS ".foreground", "black"); |
| 160 | 155 | | win_alloc_color(e, bg, &win->bg); |
| 161 | 156 | | win_alloc_color(e, fg, &win->fg); |
| 162 | | − | win_alloc_color(e, "black", &win->black); |
| 163 | | − | win->light = win_luminance(&win->bg) > win_luminance(&win->fg); |
| 164 | 157 | | |
| 165 | 158 | | win->bar.l.size = BAR_L_LEN; |
| 166 | 159 | | win->bar.r.size = BAR_R_LEN; |
| @@ -300,7 +293,7 @@ void win_open(win_t *win) |
| 300 | 293 | | win->buf.h = e->scrh; |
| 301 | 294 | | win->buf.pm = XCreatePixmap(e->dpy, win->xwin, |
| 302 | 295 | | win->buf.w, win->buf.h, e->depth); |
| 303 | | − | XSetForeground(e->dpy, gc, fullscreen ? win->black.pixel : win->bg.pixel); |
| 296 | + | XSetForeground(e->dpy, gc, win->bg.pixel); |
| 304 | 297 | | XFillRectangle(e->dpy, win->buf.pm, gc, 0, 0, win->buf.w, win->buf.h); |
| 305 | 298 | | XSetWindowBackgroundPixmap(e->dpy, win->xwin, win->buf.pm); |
| 306 | 299 | | |
| @@ -392,7 +385,7 @@ void win_clear(win_t *win) |
| 392 | 385 | | win->buf.pm = XCreatePixmap(e->dpy, win->xwin, |
| 393 | 386 | | win->buf.w, win->buf.h, e->depth); |
| 394 | 387 | | } |
| 395 | | − | XSetForeground(e->dpy, gc, win->fullscreen ? win->black.pixel : win->bg.pixel); |
| 388 | + | XSetForeground(e->dpy, gc, win->bg.pixel); |
| 396 | 389 | | XFillRectangle(e->dpy, win->buf.pm, gc, 0, 0, win->buf.w, win->buf.h); |
| 397 | 390 | | } |
| 398 | 391 | | |
| @@ -439,7 +432,6 @@ void win_draw_bar(win_t *win) |
| 439 | 432 | | win_env_t *e; |
| 440 | 433 | | win_bar_t *l, *r; |
| 441 | 434 | | XftDraw *d; |
| 442 | | − | const XftColor *bg, *fg; |
| 443 | 435 | | |
| 444 | 436 | | if ((l = &win->bar.l)->buf == NULL || (r = &win->bar.r)->buf == NULL) |
| 445 | 437 | | return; |
| @@ -450,28 +442,23 @@ void win_draw_bar(win_t *win) |
| 450 | 442 | | d = XftDrawCreate(e->dpy, win->buf.pm, DefaultVisual(e->dpy, e->scr), |
| 451 | 443 | | DefaultColormap(e->dpy, e->scr)); |
| 452 | 444 | | |
| 453 | | − | if (win->fullscreen && !win->light) |
| 454 | | − | bg = &win->bg, fg = &win->fg; |
| 455 | | − | else |
| 456 | | − | bg = &win->fg, fg = &win->bg; |
| 457 | | − | |
| 458 | | − | XSetForeground(e->dpy, gc, bg->pixel); |
| 445 | + | XSetForeground(e->dpy, gc, win->fg.pixel); |
| 459 | 446 | | XFillRectangle(e->dpy, win->buf.pm, gc, 0, win->h, win->w, win->bar.h); |
| 460 | 447 | | |
| 461 | | − | XSetForeground(e->dpy, gc, fg->pixel); |
| 462 | | − | XSetBackground(e->dpy, gc, bg->pixel); |
| 448 | + | XSetForeground(e->dpy, gc, win->bg.pixel); |
| 449 | + | XSetBackground(e->dpy, gc, win->fg.pixel); |
| 463 | 450 | | |
| 464 | 451 | | if ((len = strlen(r->buf)) > 0) { |
| 465 | 452 | | if ((tw = TEXTWIDTH(win, r->buf, len)) > w) |
| 466 | 453 | | return; |
| 467 | 454 | | x = win->w - tw - H_TEXT_PAD; |
| 468 | 455 | | w -= tw; |
| 469 | | − | win_draw_text(win, d, fg, x, y, r->buf, len, tw); |
| 456 | + | win_draw_text(win, d, &win->bg, x, y, r->buf, len, tw); |
| 470 | 457 | | } |
| 471 | 458 | | if ((len = strlen(l->buf)) > 0) { |
| 472 | 459 | | x = H_TEXT_PAD; |
| 473 | 460 | | w -= 2 * H_TEXT_PAD; /* gap between left and right parts */ |
| 474 | | − | win_draw_text(win, d, fg, x, y, l->buf, len, w); |
| 461 | + | win_draw_text(win, d, &win->bg, x, y, l->buf, len, w); |
| 475 | 462 | | } |
| 476 | 463 | | XftDrawDestroy(d); |
| 477 | 464 | | } |