Hello,

this patch adds the possibility to specify colors for the menu and
its font in the cwmrc(5). Thanks to Thomas Pfaff for brief testing
and further suggestions.

Tested it on amd64.

Index: calmwm.h
===================================================================
RCS file: /cvs/xenocara/app/cwm/calmwm.h,v
retrieving revision 1.94
diff -u calmwm.h
--- calmwm.h    26 Jun 2009 12:21:58 -0000      1.94
+++ calmwm.h    5 Aug 2009 00:25:48 -0000
@@ -47,6 +47,7 @@
        CWM_COLOR_BORDER_UNGROUP,
        CWM_COLOR_FG_MENU,
        CWM_COLOR_BG_MENU,
+       CWM_COLOR_FONT,
        CWM_COLOR_MAX
 };
 
@@ -272,6 +273,7 @@
 #define CONF_COLOR_UNGROUPBORDER       "red"
 #define CONF_COLOR_MENUFG              "black"
 #define CONF_COLOR_MENUBG              "white"
+#define CONF_COLOR_FONT                        "black"
        struct color             color[CWM_COLOR_MAX];
 
        char                     termpath[MAXPATHLEN];
Index: conf.c
===================================================================
RCS file: /cvs/xenocara/app/cwm/conf.c,v
retrieving revision 1.66
diff -u conf.c
--- conf.c      26 Jun 2009 12:21:58 -0000      1.66
+++ conf.c      5 Aug 2009 00:25:49 -0000
@@ -74,14 +74,20 @@
        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);
+
+               xfree(sc->color[i].name);
+               sc->color[i].name = xstrdup(c->color[i].name);
        }
 }
 
 void
 conf_reload(struct conf *c)
 {
+       struct screen_ctx       *sc;
        struct client_ctx       *cc;
 
+       sc = screen_current();
+
        if (parse_config(c->conf_path, c) == -1) {
                warnx("config file %s has errors, not reloading", c->conf_path);
                return;
@@ -91,6 +97,15 @@
        TAILQ_FOREACH(cc, &Clientq, entry)
                client_draw_border(cc);
        conf_font(c);
+
+       XDestroyWindow(X_Dpy, sc->menuwin);
+       XFreeGC(X_Dpy, sc->gc);
+       menu_init(sc);
+
+       XftDrawDestroy(sc->xftdraw);
+       XftColorFree(X_Dpy, DefaultVisual(X_Dpy, sc->which),
+           DefaultColormap(X_Dpy, sc->which), &sc->xftcolor);
+       font_init(sc);
 }
 
 void
@@ -190,6 +205,8 @@
            xstrdup(CONF_COLOR_MENUFG);
        c->color[CWM_COLOR_BG_MENU].name =
            xstrdup(CONF_COLOR_MENUBG);
+       c->color[CWM_COLOR_FONT].name =
+           xstrdup(CONF_COLOR_FONT);
 
        c->DefaultFontName = xstrdup(DEFAULTFONTNAME);
 }
Index: cwmrc.5
===================================================================
RCS file: /cvs/xenocara/app/cwm/cwmrc.5,v
retrieving revision 1.25
diff -u cwmrc.5
--- cwmrc.5     17 May 2009 23:40:57 -0000      1.25
+++ cwmrc.5     5 Aug 2009 00:25:49 -0000
@@ -96,6 +96,16 @@
 .It Ic color ungroupborder Ar color
 Set the color of the border while ungrouping a window.
 .Pp
+.It Ic color selectedentry Ar color
+Set the color of the selected entry in the menu.
+.Pp
+.It Ic color unselectedentry Ar color
+Set the color of the unselected entries in the menu.
+.Pp
+.It Ic color font Ar color
+Set the color of the font. Note that the color of the font used in the
+selected entry of the menu may differ.
+.Pp
 .It Ic command Ar name Ar path
 Every
 .Ar name
Index: font.c
===================================================================
RCS file: /cvs/xenocara/app/cwm/font.c,v
retrieving revision 1.9
diff -u font.c
--- font.c      17 May 2009 23:40:57 -0000      1.9
+++ font.c      5 Aug 2009 00:25:49 -0000
@@ -28,7 +28,8 @@
                errx(1, "XftDrawCreate");
 
        if (!XftColorAllocName(X_Dpy, DefaultVisual(X_Dpy, sc->which),
-           DefaultColormap(X_Dpy, sc->which), "black", &sc->xftcolor))
+           DefaultColormap(X_Dpy, sc->which), sc->color[CWM_COLOR_FONT].name,
+           &sc->xftcolor))
                errx(1, "XftColorAllocName");
 }
 
Index: parse.y
===================================================================
RCS file: /cvs/xenocara/app/cwm/parse.y,v
retrieving revision 1.21
diff -u parse.y
--- parse.y     20 Jun 2009 00:22:39 -0000      1.21
+++ parse.y     5 Aug 2009 00:25:49 -0000
@@ -70,6 +70,8 @@
 %token COLOR
 %token ACTIVEBORDER INACTIVEBORDER
 %token GROUPBORDER UNGROUPBORDER
+%token SELECTEDENTRY UNSELECTEDENTRY
+%token FONT
 %token ERROR
 %token <v.string>              STRING
 %token <v.number>              NUMBER
@@ -194,6 +196,18 @@
                        free(conf->color[CWM_COLOR_BORDER_UNGROUP].name);
                        conf->color[CWM_COLOR_BORDER_UNGROUP].name = $2;
                }
+               | SELECTEDENTRY STRING {
+                       free(conf->color[CWM_COLOR_FG_MENU].name);
+                       conf->color[CWM_COLOR_FG_MENU].name = $2;
+               }
+               | UNSELECTEDENTRY STRING {
+                       free(conf->color[CWM_COLOR_BG_MENU].name);
+                       conf->color[CWM_COLOR_BG_MENU].name = $2;
+               }
+               | FONT STRING {
+                       free(conf->color[CWM_COLOR_FONT].name);
+                       conf->color[CWM_COLOR_FONT].name = $2;
+               }
                ;
 %%
 
@@ -233,6 +247,7 @@
                { "borderwidth",        BORDERWIDTH},
                { "color",              COLOR},
                { "command",            COMMAND},
+               { "font",               FONT},
                { "fontname",           FONTNAME},
                { "gap",                GAP},
                { "groupborder",        GROUPBORDER},
@@ -241,8 +256,10 @@
                { "mousebind",          MOUSEBIND},
                { "moveamount",         MOVEAMOUNT},
                { "no",                 NO},
+               { "selectedentry",              SELECTEDENTRY},
                { "sticky",             STICKY},
                { "ungroupborder",      UNGROUPBORDER},
+               { "unselectedentry",            UNSELECTEDENTRY},
                { "yes",                YES}
        };
        const struct keywords   *p;

-- 
Simon Nicolussi, <simon.nicolu...@student.uibk.ac.at>
http://homepage.uibk.ac.at/~csag9583/

Reply via email to