Skip to content
This repository has been archived by the owner on Jan 16, 2023. It is now read-only.

Separated bar background into it's own Xresource. #386

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion sxiv.1
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,10 @@ The following X resources are supported:
Color of the window background and bar foreground
.TP
.B foreground
Color of the window foreground and bar background
Color of the window foreground
.TP
.B barBackground
Color of the bar background
.TP
.B font
Name of Xft bar font
Expand Down
1 change: 1 addition & 0 deletions sxiv.h
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ struct win {

XftColor bg;
XftColor fg;
XftColor bbg;

int x;
int y;
Expand Down
10 changes: 6 additions & 4 deletions window.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,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 *bg, *fg, *bbg, *f;
char *res_man;
XrmDatabase db;

Expand Down Expand Up @@ -121,8 +121,10 @@ void win_init(win_t *win)

bg = win_res(db, RES_CLASS ".background", "white");
fg = win_res(db, RES_CLASS ".foreground", "black");
bbg = win_res(db, RES_CLASS ".barBackground", "white");
win_alloc_color(e, bg, &win->bg);
win_alloc_color(e, fg, &win->fg);
win_alloc_color(e, bbg, &win->bbg);

win->bar.l.size = BAR_L_LEN;
win->bar.r.size = BAR_R_LEN;
Expand Down Expand Up @@ -397,7 +399,7 @@ void win_draw_bar(win_t *win)
d = XftDrawCreate(e->dpy, win->buf.pm, DefaultVisual(e->dpy, e->scr),
DefaultColormap(e->dpy, e->scr));

XSetForeground(e->dpy, gc, win->fg.pixel);
XSetForeground(e->dpy, gc, win->bbg.pixel);
XFillRectangle(e->dpy, win->buf.pm, gc, 0, win->h, win->w, win->bar.h);

XSetForeground(e->dpy, gc, win->bg.pixel);
Expand All @@ -408,12 +410,12 @@ void win_draw_bar(win_t *win)
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->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->fg, x, y, l->buf, len, w);
}
XftDrawDestroy(d);
}
Expand Down