diff options
Diffstat (limited to 'conf.c')
-rw-r--r-- | conf.c | 49 |
1 files changed, 32 insertions, 17 deletions
@@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: conf.c,v 1.126 2013/05/11 21:46:27 okan Exp $ + * $OpenBSD: conf.c,v 1.127 2013/05/19 23:09:59 okan Exp $ */ #include <sys/param.h> @@ -84,31 +84,49 @@ conf_ignore(struct conf *c, char *val) TAILQ_INSERT_TAIL(&c->ignoreq, wm, entry); } -static char *menu_color_binds[CWM_COLOR_MENU_MAX] = { - "black", /* CWM_COLOR_MENU_FG */ - "white", /* CWM_COLOR_MENU_BG */ - "black", /* CWM_COLOR_MENU_FONT */ - "", /* CWM_COLOR_MENU_FONT_SEL */ -}; - -static char *color_binds[CWM_COLOR_BORDER_MAX] = { +static char *color_binds[CWM_COLOR_MAX] = { "#CCCCCC", /* CWM_COLOR_BORDER_ACTIVE */ "#666666", /* CWM_COLOR_BORDER_INACTIVE */ "blue", /* CWM_COLOR_BORDER_GROUP */ "red", /* CWM_COLOR_BORDER_UNGROUP */ + "black", /* CWM_COLOR_MENU_FG */ + "white", /* CWM_COLOR_MENU_BG */ + "black", /* CWM_COLOR_MENU_FONT */ + "", /* CWM_COLOR_MENU_FONT_SEL */ }; void conf_screen(struct screen_ctx *sc) { - int i; + int i; + XftColor xc; sc->gap = Conf.gap; - font_init(sc, Conf.font, (const char **)Conf.menucolor); + font_init(sc, Conf.font); + + for (i = 0; i < CWM_COLOR_MAX; i++) { + if (*Conf.color[i] == '\0') + break; + if (XftColorAllocName(X_Dpy, sc->visual, sc->colormap, + Conf.color[i], &xc)) { + sc->xftcolor[i] = xc; + XftColorFree(X_Dpy, sc->visual, sc->colormap, &xc); + } else { + warnx("XftColorAllocName: '%s'", Conf.color[i]); + XftColorAllocName(X_Dpy, sc->visual, sc->colormap, + color_binds[i], &sc->xftcolor[i]); + } + } + if (i == CWM_COLOR_MAX) + return; - for (i = 0; i < CWM_COLOR_BORDER_MAX; i++) - sc->color[i] = xu_getcolor(sc, Conf.color[i]); + xu_xorcolor(sc->xftcolor[CWM_COLOR_MENU_BG], + sc->xftcolor[CWM_COLOR_MENU_FG], &xc); + xu_xorcolor(sc->xftcolor[CWM_COLOR_MENU_FONT], xc, &xc); + if (!XftColorAllocValue(X_Dpy, sc->visual, sc->colormap, + &xc.color, &sc->xftcolor[CWM_COLOR_MENU_FONT_SEL])) + warnx("XftColorAllocValue: '%s'", Conf.color[i]); } static struct { @@ -210,9 +228,6 @@ conf_init(struct conf *c) for (i = 0; i < nitems(color_binds); i++) c->color[i] = xstrdup(color_binds[i]); - for (i = 0; i < nitems(menu_color_binds); i++) - c->menucolor[i] = xstrdup(menu_color_binds[i]); - /* Default term/lock */ (void)strlcpy(c->termpath, "xterm", sizeof(c->termpath)); (void)strlcpy(c->lockpath, "xlock", sizeof(c->lockpath)); @@ -260,7 +275,7 @@ conf_clear(struct conf *c) free(mb); } - for (i = 0; i < CWM_COLOR_BORDER_MAX; i++) + for (i = 0; i < CWM_COLOR_MAX; i++) free(c->color[i]); free(c->font); |