summary refs log tree commit diff
diff options
context:
space:
mode:
authorokan <okan>2011-09-08 12:35:33 +0000
committerokan <okan>2011-09-08 12:35:33 +0000
commit82d31aec1d380bc53a1ccfdabe81e37d9b7213c2 (patch)
treefc9397efe088ac08537cd645464ce6e94c74c4c4
parenta262f8e80cb02238e7b01fde8faf4085115acd1c (diff)
downloadcwm-82d31aec1d380bc53a1ccfdabe81e37d9b7213c2.tar.gz
cwm-82d31aec1d380bc53a1ccfdabe81e37d9b7213c2.tar.xz
cwm-82d31aec1d380bc53a1ccfdabe81e37d9b7213c2.zip
allow configurable menu font color; from Alexander Polakov with a tweak
from me.

ok oga@
-rw-r--r--calmwm.c1
-rw-r--r--calmwm.h3
-rw-r--r--conf.c2
-rw-r--r--cwmrc.55
-rw-r--r--font.c9
-rw-r--r--parse.y7
6 files changed, 21 insertions, 6 deletions
diff --git a/calmwm.c b/calmwm.c
index 8bfdff3..611ae37 100644
--- a/calmwm.c
+++ b/calmwm.c
@@ -169,7 +169,6 @@ x_setupscreen(struct screen_ctx *sc, u_int which)
 	conf_color(&Conf, sc);
 
 	group_init(sc);
-	font_init(sc);
 	conf_font(&Conf, sc);
 
 	TAILQ_INIT(&sc->mruq);
diff --git a/calmwm.h b/calmwm.h
index 0d035d9..2f1c6c2 100644
--- a/calmwm.h
+++ b/calmwm.h
@@ -86,6 +86,7 @@ enum cwmcolor {
 	CWM_COLOR_BORDER_UNGROUP,
 	CWM_COLOR_FG_MENU,
 	CWM_COLOR_BG_MENU,
+	CWM_COLOR_FONT,
 	CWM_COLOR_MAX
 };
 
@@ -435,7 +436,7 @@ int			 font_descent(struct screen_ctx *);
 void			 font_draw(struct screen_ctx *, const char *, int,
 			     Drawable, int, int);
 u_int			 font_height(struct screen_ctx *);
-void			 font_init(struct screen_ctx *);
+void			 font_init(struct screen_ctx *, const char *);
 int			 font_width(struct screen_ctx *, const char *, int);
 XftFont			*font_make(struct screen_ctx *, const char *);
 
diff --git a/conf.c b/conf.c
index e2263b0..e8cd157 100644
--- a/conf.c
+++ b/conf.c
@@ -62,6 +62,7 @@ conf_gap(struct conf *c, struct screen_ctx *sc)
 void
 conf_font(struct conf *c, struct screen_ctx *sc)
 {
+	font_init(sc, c->color[CWM_COLOR_FONT].name);
 	sc->font = font_make(sc, c->font);
 }
 
@@ -72,6 +73,7 @@ static struct color color_binds[] = {
 	{ "red",	0 }, /* CWM_COLOR_BORDOR_UNGROUP */
 	{ "black",	0 }, /* CWM_COLOR_FG_MENU */
 	{ "white",	0 }, /* CWM_COLOR_BG_MENU */
+	{ "black",	0 }, /* CWM_COLOR_FONT */
 };
 
 void
diff --git a/cwmrc.5 b/cwmrc.5
index 3f9a09c..ebae713 100644
--- a/cwmrc.5
+++ b/cwmrc.5
@@ -14,7 +14,7 @@
 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 .\"
-.Dd $Mdocdate: September 3 2011 $
+.Dd $Mdocdate: September 8 2011 $
 .Dt CWMRC 5
 .Os
 .Sh NAME
@@ -99,6 +99,9 @@ Set the window border width to
 .It Ic color activeborder Ar color
 Set the color of the active border.
 .Pp
+.It Ic color font Ar color
+Set menu font color.
+.Pp
 .It Ic color groupborder Ar color
 Set the color of the border while grouping a window.
 .Pp
diff --git a/font.c b/font.c
index cc24eaf..54c878e 100644
--- a/font.c
+++ b/font.c
@@ -49,15 +49,20 @@ font_height(struct screen_ctx *sc)
 }
 
 void
-font_init(struct screen_ctx *sc)
+font_init(struct screen_ctx *sc, const char *color)
 {
+	if (sc->xftdraw)
+		XftDrawDestroy(sc->xftdraw);
 	sc->xftdraw = XftDrawCreate(X_Dpy, sc->rootwin,
 	    DefaultVisual(X_Dpy, sc->which), DefaultColormap(X_Dpy, sc->which));
 	if (sc->xftdraw == NULL)
 		errx(1, "XftDrawCreate");
 
+	if (sc->xftcolor.pixel)
+		XftColorFree(X_Dpy, DefaultVisual(X_Dpy, sc->which),
+		    DefaultColormap(X_Dpy, sc->which), &sc->xftcolor);
 	if (!XftColorAllocName(X_Dpy, DefaultVisual(X_Dpy, sc->which),
-	    DefaultColormap(X_Dpy, sc->which), "black", &sc->xftcolor))
+	    DefaultColormap(X_Dpy, sc->which), color, &sc->xftcolor))
 		errx(1, "XftColorAllocName");
 }
 
diff --git a/parse.y b/parse.y
index 43c687e..1b1a249 100644
--- a/parse.y
+++ b/parse.y
@@ -73,7 +73,7 @@ typedef struct {
 %token	COLOR SNAPDIST
 %token	ACTIVEBORDER INACTIVEBORDER
 %token	GROUPBORDER UNGROUPBORDER
-%token	MENUBG MENUFG
+%token	MENUBG MENUFG FONTCOLOR
 %token	ERROR
 %token	<v.string>		STRING
 %token	<v.number>		NUMBER
@@ -193,6 +193,10 @@ colors		: ACTIVEBORDER STRING {
 			free(conf->color[CWM_COLOR_FG_MENU].name);
 			conf->color[CWM_COLOR_FG_MENU].name = $2;
 		}
+		| FONTCOLOR STRING {
+			free(conf->color[CWM_COLOR_FONT].name);
+			conf->color[CWM_COLOR_FONT].name = $2;
+		}
 		;
 %%
 
@@ -232,6 +236,7 @@ lookup(char *s)
 		{ "borderwidth",	BORDERWIDTH},
 		{ "color",		COLOR},
 		{ "command",		COMMAND},
+		{ "font",		FONTCOLOR},
 		{ "fontname",		FONTNAME},
 		{ "gap",		GAP},
 		{ "groupborder",	GROUPBORDER},