From 49c64852885aadb1bd54f8e5d2a1961363db7461 Mon Sep 17 00:00:00 2001 From: Okan Demirmen Date: Sun, 17 May 2009 23:40:58 +0000 Subject: a long time coming - re-work the way we deal with colors: since we're using Xft(3), use it to select the font color as well instead of trying to build one; properly allocate and free colors at-will, e.g. we now have configurable colors. feedback and ok's todd@ and oga@ --- app/cwm/conf.c | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'app/cwm/conf.c') diff --git a/app/cwm/conf.c b/app/cwm/conf.c index 6898515f5..4c17b0668 100644 --- a/app/cwm/conf.c +++ b/app/cwm/conf.c @@ -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. * - * $Id: conf.c,v 1.60 2009/05/17 17:04:59 sthen Exp $ + * $Id: conf.c,v 1.61 2009/05/17 23:40:57 okan Exp $ */ #include "headers.h" @@ -61,6 +61,21 @@ conf_font(struct conf *c) c->FontHeight = font_ascent() + font_descent() + 1; } +void +conf_color(struct conf *c) +{ + struct screen_ctx *sc; + int i; + + sc = screen_current(); + + + for (i = 0; i < CWM_COLOR_MAX; i++) { + xu_freecolor(sc, sc->color[i].pixel); + sc->color[i].pixel = xu_getcolor(sc, c->color[i].name); + } +} + void conf_reload(struct conf *c) { @@ -69,6 +84,7 @@ conf_reload(struct conf *c) return; } + conf_color(c); conf_font(c); } @@ -157,6 +173,19 @@ conf_init(struct conf *c) strlcpy(c->termpath, "xterm", sizeof(c->termpath)); strlcpy(c->lockpath, "xlock", sizeof(c->lockpath)); + c->color[CWM_COLOR_BORDOR_ACTIVE].name = + xstrdup(CONF_COLOR_ACTIVEBORDER); + c->color[CWM_COLOR_BORDER_INACTIVE].name = + xstrdup(CONF_COLOR_INACTIVEBORDER); + c->color[CWM_COLOR_BORDER_GROUP].name = + xstrdup(CONF_COLOR_GROUPBORDER); + c->color[CWM_COLOR_BORDER_UNGROUP].name = + xstrdup(CONF_COLOR_UNGROUPBORDER); + c->color[CWM_COLOR_FG_MENU].name = + xstrdup(CONF_COLOR_MENUFG); + c->color[CWM_COLOR_BG_MENU].name = + xstrdup(CONF_COLOR_MENUBG); + c->DefaultFontName = xstrdup(DEFAULTFONTNAME); } @@ -168,6 +197,7 @@ conf_clear(struct conf *c) struct winmatch *wm; struct cmd *cmd; struct mousebinding *mb; + int i; while ((cmd = TAILQ_FIRST(&c->cmdq)) != NULL) { TAILQ_REMOVE(&c->cmdq, cmd, entry); @@ -198,6 +228,9 @@ conf_clear(struct conf *c) xfree(mb); } + for (i = 0; i < CWM_COLOR_MAX; i++) + xfree(c->color[i].name); + xfree(c->DefaultFontName); } -- cgit v1.2.3