Krolyxon
Commit 2886876

Branches

Refs →

nsxiv2886876

Use normal win colors in fullscreen mode

Fixes issues #361 and #367
Author
Bert Münnich
Date
2019-07-16 19:18 +0200
Parent
6511d68
Commit
28868767e6ea74f1e758686e6ae5d58918bd1627

+11 −31

4 files changed

  1. M image.c +1 −1
  2. M sxiv.h +0 −2
  3. M thumbs.c +3 −8
  4. M window.c +7 −20
M image.c View
@@ -497,7 +497,7 @@ void img_render(img_t *img)
497497 }
498498 imlib_image_put_back_data(data);
499499 } else {
500− c = win->fullscreen ? win->black.pixel : win->bg.pixel;
500+ c = win->bg.pixel;
501501 imlib_context_set_color(c >> 16 & 0xFF, c >> 8 & 0xFF, c & 0xFF, 0xFF);
502502 imlib_image_fill_rectangle(0, 0, dw, dh);
503503 }
M sxiv.h View
@@ -408,10 +408,8 @@ struct win {
408408 Window xwin;
409409 win_env_t env;
410410
411− bool light; /* bg is lighter than fg */
412411 XftColor bg;
413412 XftColor fg;
414− XftColor black;
415413
416414 int x;
417415 int y;
M thumbs.c View
@@ -469,14 +469,14 @@ void tns_mark(tns_t *tns, int n, bool mark)
469469 if (n >= 0 && n < *tns->cnt && tns->thumbs[n].im != NULL) {
470470 win_t *win = tns->win;
471471 thumb_t *t = &tns->thumbs[n];
472− unsigned long col = win->fullscreen ? win->black.pixel : win->bg.pixel;
472+ unsigned long col = win->bg.pixel;
473473 int x = t->x + t->w, y = t->y + t->h;
474474
475475 win_draw_rect(win, x - 1, y + 1, 1, tns->bw, true, 1, col);
476476 win_draw_rect(win, x + 1, y - 1, tns->bw, 1, true, 1, col);
477477
478478 if (mark)
479− col = win->fullscreen && win->light ? win->bg.pixel : win->fg.pixel;
479+ col = win->fg.pixel;
480480
481481 win_draw_rect(win, x, y, tns->bw + 2, tns->bw + 2, true, 1, col);
482482
@@ -490,14 +490,9 @@ void tns_highlight(tns_t *tns, int n, bool hl)
490490 if (n >= 0 && n < *tns->cnt && tns->thumbs[n].im != NULL) {
491491 win_t *win = tns->win;
492492 thumb_t *t = &tns->thumbs[n];
493− unsigned long col;
493+ unsigned long col = hl ? win->fg.pixel : win->bg.pixel;
494494 int oxy = (tns->bw + 1) / 2 + 1, owh = tns->bw + 2;
495495
496− if (hl)
497− col = win->fullscreen && win->light ? win->bg.pixel : win->fg.pixel;
498− else
499− col = win->fullscreen ? win->black.pixel : win->bg.pixel;
500−
501496 win_draw_rect(win, t->x - oxy, t->y - oxy, t->w + owh, t->h + owh,
502497 false, tns->bw, col);
503498
M window.c View
@@ -123,11 +123,6 @@ const char* win_res(Display *dpy, const char *name, const char *def)
123123 }
124124 }
125125
126−unsigned int win_luminance(const XftColor *col)
127−{
128− return (col->color.red + col->color.green + col->color.blue) / 3;
129−}
130−
131126 #define INIT_ATOM_(atom) \
132127 atoms[ATOM_##atom] = XInternAtom(e->dpy, #atom, False);
133128
@@ -159,8 +154,6 @@ void win_init(win_t *win)
159154 fg = win_res(e->dpy, RES_CLASS ".foreground", "black");
160155 win_alloc_color(e, bg, &win->bg);
161156 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);
164157
165158 win->bar.l.size = BAR_L_LEN;
166159 win->bar.r.size = BAR_R_LEN;
@@ -300,7 +293,7 @@ void win_open(win_t *win)
300293 win->buf.h = e->scrh;
301294 win->buf.pm = XCreatePixmap(e->dpy, win->xwin,
302295 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);
304297 XFillRectangle(e->dpy, win->buf.pm, gc, 0, 0, win->buf.w, win->buf.h);
305298 XSetWindowBackgroundPixmap(e->dpy, win->xwin, win->buf.pm);
306299
@@ -392,7 +385,7 @@ void win_clear(win_t *win)
392385 win->buf.pm = XCreatePixmap(e->dpy, win->xwin,
393386 win->buf.w, win->buf.h, e->depth);
394387 }
395− XSetForeground(e->dpy, gc, win->fullscreen ? win->black.pixel : win->bg.pixel);
388+ XSetForeground(e->dpy, gc, win->bg.pixel);
396389 XFillRectangle(e->dpy, win->buf.pm, gc, 0, 0, win->buf.w, win->buf.h);
397390 }
398391
@@ -439,7 +432,6 @@ void win_draw_bar(win_t *win)
439432 win_env_t *e;
440433 win_bar_t *l, *r;
441434 XftDraw *d;
442− const XftColor *bg, *fg;
443435
444436 if ((l = &win->bar.l)->buf == NULL || (r = &win->bar.r)->buf == NULL)
445437 return;
@@ -450,28 +442,23 @@ void win_draw_bar(win_t *win)
450442 d = XftDrawCreate(e->dpy, win->buf.pm, DefaultVisual(e->dpy, e->scr),
451443 DefaultColormap(e->dpy, e->scr));
452444
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);
459446 XFillRectangle(e->dpy, win->buf.pm, gc, 0, win->h, win->w, win->bar.h);
460447
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);
463450
464451 if ((len = strlen(r->buf)) > 0) {
465452 if ((tw = TEXTWIDTH(win, r->buf, len)) > w)
466453 return;
467454 x = win->w - tw - H_TEXT_PAD;
468455 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);
470457 }
471458 if ((len = strlen(l->buf)) > 0) {
472459 x = H_TEXT_PAD;
473460 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);
475462 }
476463 XftDrawDestroy(d);
477464 }