summaryrefslogtreecommitdiffstats
path: root/window.c
diff options
context:
space:
mode:
authorGuilherme Freire <41879254+GRFreire@users.noreply.github.com>2021-09-11 16:38:22 +0200
committerBerke Kocaoğlu <berke.kocaoglu@metu.edu.tr>2021-09-16 21:55:31 +0200
commitf7557c55b5a87a51daba825ed3f6155eed179221 (patch)
treeeaedd0717e558730b62015740a088ae2ce3e6706 /window.c
parentd8ec6f91a9857fb651f39de7929f17543d1c996c (diff)
downloadnsxiv-f7557c55b5a87a51daba825ed3f6155eed179221.tar.zst
Custom bar colors (#10)
* set bar and text colors independently * change xresources to Program.class.resource * rename color variables to win/bar_bg/fg * change default bar colors to match window colors
Diffstat (limited to 'window.c')
-rw-r--r--window.c28
1 files changed, 16 insertions, 12 deletions
diff --git a/window.c b/window.c
index ded20c8..bd9b0c3 100644
--- a/window.c
+++ b/window.c
@@ -93,7 +93,7 @@ const char* win_res(XrmDatabase db, const char *name, const char *def)
void win_init(win_t *win)
{
win_env_t *e;
- const char *bg, *fg, *f;
+ const char *win_bg, *win_fg, *bar_bg, *bar_fg, *f;
char *res_man;
XrmDatabase db;
XVisualInfo vis;
@@ -133,10 +133,14 @@ void win_init(win_t *win)
f = win_res(db, RES_CLASS ".font", "monospace-8");
win_init_font(e, f);
- bg = win_res(db, RES_CLASS ".background", "white");
- fg = win_res(db, RES_CLASS ".foreground", "black");
- win_alloc_color(e, bg, &win->bg);
- win_alloc_color(e, fg, &win->fg);
+ win_bg = win_res(db, RES_CLASS ".window.background", "white");
+ win_fg = win_res(db, RES_CLASS ".window.foreground", "black");
+ bar_bg = win_res(db, RES_CLASS ".bar.background", win_bg);
+ bar_fg = win_res(db, RES_CLASS ".bar.foreground", win_fg);
+ win_alloc_color(e, win_bg, &win->win_bg);
+ win_alloc_color(e, win_fg, &win->win_fg);
+ win_alloc_color(e, bar_bg, &win->bar_bg);
+ win_alloc_color(e, bar_fg, &win->bar_fg);
win->bar.l.size = BAR_L_LEN;
win->bar.r.size = BAR_R_LEN;
@@ -297,7 +301,7 @@ void win_open(win_t *win)
win->buf.h = e->scrh;
win->buf.pm = XCreatePixmap(e->dpy, win->xwin,
win->buf.w, win->buf.h, e->depth);
- XSetForeground(e->dpy, gc, win->bg.pixel);
+ XSetForeground(e->dpy, gc, win->win_bg.pixel);
XFillRectangle(e->dpy, win->buf.pm, gc, 0, 0, win->buf.w, win->buf.h);
XSetWindowBackgroundPixmap(e->dpy, win->xwin, win->buf.pm);
@@ -379,7 +383,7 @@ void win_clear(win_t *win)
win->buf.pm = XCreatePixmap(e->dpy, win->xwin,
win->buf.w, win->buf.h, e->depth);
}
- XSetForeground(e->dpy, gc, win->bg.pixel);
+ XSetForeground(e->dpy, gc, win->win_bg.pixel);
XFillRectangle(e->dpy, win->buf.pm, gc, 0, 0, win->buf.w, win->buf.h);
}
@@ -436,23 +440,23 @@ void win_draw_bar(win_t *win)
d = XftDrawCreate(e->dpy, win->buf.pm, e->vis,
e->cmap);
- XSetForeground(e->dpy, gc, win->fg.pixel);
+ XSetForeground(e->dpy, gc, win->bar_bg.pixel);
XFillRectangle(e->dpy, win->buf.pm, gc, 0, win->h, win->w, win->bar.h);
- XSetForeground(e->dpy, gc, win->bg.pixel);
- XSetBackground(e->dpy, gc, win->fg.pixel);
+ XSetForeground(e->dpy, gc, win->win_bg.pixel);
+ XSetBackground(e->dpy, gc, win->bar_bg.pixel);
if ((len = strlen(r->buf)) > 0) {
if ((tw = TEXTWIDTH(win, r->buf, len)) > w)
return;
x = win->w - tw - H_TEXT_PAD;
w -= tw;
- win_draw_text(win, d, &win->bg, x, y, r->buf, len, tw);
+ win_draw_text(win, d, &win->bar_fg, x, y, r->buf, len, tw);
}
if ((len = strlen(l->buf)) > 0) {
x = H_TEXT_PAD;
w -= 2 * H_TEXT_PAD; /* gap between left and right parts */
- win_draw_text(win, d, &win->bg, x, y, l->buf, len, w);
+ win_draw_text(win, d, &win->bar_fg, x, y, l->buf, len, w);
}
XftDrawDestroy(d);
}