From 9e11fcccad90ece0d7eeb330660aecf2986e975a Mon Sep 17 00:00:00 2001 From: okan Date: Fri, 4 Jan 2013 16:23:04 +0000 Subject: [PATCH] get rid of struct color --- app/cwm/calmwm.h | 11 +++-------- app/cwm/client.c | 10 +++++----- app/cwm/conf.c | 18 +++++++++--------- app/cwm/parse.y | 20 ++++++++++---------- 4 files changed, 27 insertions(+), 32 deletions(-) diff --git a/app/cwm/calmwm.h b/app/cwm/calmwm.h index 68fd1ef6b..3ea61698a 100644 --- a/app/cwm/calmwm.h +++ b/app/cwm/calmwm.h @@ -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: calmwm.h,v 1.182 2013/01/02 16:26:34 okan Exp $ + * $OpenBSD: calmwm.h,v 1.183 2013/01/04 16:23:04 okan Exp $ */ #ifndef _CALMWM_H_ @@ -97,11 +97,6 @@ enum cwmcolor { CWM_COLOR_MAX }; -struct color { - char *name; - unsigned long pixel; -}; - struct geom { int x; int y; @@ -211,7 +206,7 @@ struct screen_ctx { Colormap colormap; Window rootwin; Window menuwin; - struct color color[CWM_COLOR_MAX]; + unsigned long color[CWM_COLOR_MAX]; int cycling; struct geom view; /* viewable area */ struct geom work; /* workable area, gap-applied */ @@ -291,7 +286,7 @@ struct conf { #define CONF_SNAPDIST 0 int snapdist; struct gap gap; - struct color color[CWM_COLOR_MAX]; + char *color[CWM_COLOR_MAX]; char *menucolor[CWM_COLOR_MENU_MAX]; char termpath[MAXPATHLEN]; char lockpath[MAXPATHLEN]; diff --git a/app/cwm/client.c b/app/cwm/client.c index 44f9a8452..d1718053c 100644 --- a/app/cwm/client.c +++ b/app/cwm/client.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. * - * $OpenBSD: client.c,v 1.113 2013/01/02 21:37:21 okan Exp $ + * $OpenBSD: client.c,v 1.114 2013/01/04 16:23:04 okan Exp $ */ #include @@ -475,17 +475,17 @@ client_draw_border(struct client_ctx *cc) if (cc->active) switch (cc->flags & CLIENT_HIGHLIGHT) { case CLIENT_GROUP: - pixel = sc->color[CWM_COLOR_BORDER_GROUP].pixel; + pixel = sc->color[CWM_COLOR_BORDER_GROUP]; break; case CLIENT_UNGROUP: - pixel = sc->color[CWM_COLOR_BORDER_UNGROUP].pixel; + pixel = sc->color[CWM_COLOR_BORDER_UNGROUP]; break; default: - pixel = sc->color[CWM_COLOR_BORDER_ACTIVE].pixel; + pixel = sc->color[CWM_COLOR_BORDER_ACTIVE]; break; } else - pixel = sc->color[CWM_COLOR_BORDER_INACTIVE].pixel; + pixel = sc->color[CWM_COLOR_BORDER_INACTIVE]; XSetWindowBorderWidth(X_Dpy, cc->win, cc->bwidth); XSetWindowBorder(X_Dpy, cc->win, pixel); diff --git a/app/cwm/conf.c b/app/cwm/conf.c index 2f9a05768..c28c26669 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. * - * $OpenBSD: conf.c,v 1.117 2013/01/01 14:33:52 okan Exp $ + * $OpenBSD: conf.c,v 1.118 2013/01/04 16:23:04 okan Exp $ */ #include @@ -71,11 +71,11 @@ static char *menu_color_binds[CWM_COLOR_MENU_MAX] = { "", /* CWM_COLOR_MENU_FONT_SEL */ }; -static struct color color_binds[CWM_COLOR_MAX] = { - { "#CCCCCC", 0 }, /* CWM_COLOR_BORDER_ACTIVE */ - { "#666666", 0 }, /* CWM_COLOR_BORDER_INACTIVE */ - { "blue", 0 }, /* CWM_COLOR_BORDER_GROUP */ - { "red", 0 }, /* CWM_COLOR_BORDER_UNGROUP */ +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 */ }; void @@ -84,7 +84,7 @@ conf_color(struct conf *c, struct screen_ctx *sc) int i; for (i = 0; i < CWM_COLOR_MAX; i++) - sc->color[i].pixel = xu_getcolor(sc, c->color[i].name); + sc->color[i] = xu_getcolor(sc, c->color[i]); } static struct { @@ -184,7 +184,7 @@ conf_init(struct conf *c) conf_mousebind(c, m_binds[i].key, m_binds[i].func); for (i = 0; i < nitems(color_binds); i++) - c->color[i].name = xstrdup(color_binds[i].name); + c->color[i] = xstrdup(color_binds[i]); for (i = 0; i < nitems(menu_color_binds); i++) c->menucolor[i] = xstrdup(menu_color_binds[i]); @@ -237,7 +237,7 @@ conf_clear(struct conf *c) } for (i = 0; i < CWM_COLOR_MAX; i++) - free(c->color[i].name); + free(c->color[i]); free(c->font); } diff --git a/app/cwm/parse.y b/app/cwm/parse.y index 5fc01464d..4c094b1cb 100644 --- a/app/cwm/parse.y +++ b/app/cwm/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.37 2012/12/19 15:21:34 okan Exp $ */ +/* $OpenBSD: parse.y,v 1.38 2013/01/04 16:23:04 okan Exp $ */ /* * Copyright (c) 2002, 2003, 2004 Henning Brauer @@ -171,20 +171,20 @@ color : COLOR colors ; colors : ACTIVEBORDER STRING { - free(conf->color[CWM_COLOR_BORDER_ACTIVE].name); - conf->color[CWM_COLOR_BORDER_ACTIVE].name = $2; + free(conf->color[CWM_COLOR_BORDER_ACTIVE]); + conf->color[CWM_COLOR_BORDER_ACTIVE] = $2; } | INACTIVEBORDER STRING { - free(conf->color[CWM_COLOR_BORDER_INACTIVE].name); - conf->color[CWM_COLOR_BORDER_INACTIVE].name = $2; + free(conf->color[CWM_COLOR_BORDER_INACTIVE]); + conf->color[CWM_COLOR_BORDER_INACTIVE] = $2; } | GROUPBORDER STRING { - free(conf->color[CWM_COLOR_BORDER_GROUP].name); - conf->color[CWM_COLOR_BORDER_GROUP].name = $2; + free(conf->color[CWM_COLOR_BORDER_GROUP]); + conf->color[CWM_COLOR_BORDER_GROUP] = $2; } | UNGROUPBORDER STRING { - free(conf->color[CWM_COLOR_BORDER_UNGROUP].name); - conf->color[CWM_COLOR_BORDER_UNGROUP].name = $2; + free(conf->color[CWM_COLOR_BORDER_UNGROUP]); + conf->color[CWM_COLOR_BORDER_UNGROUP] = $2; } | MENUBG STRING { free(conf->menucolor[CWM_COLOR_MENU_BG]); @@ -579,7 +579,7 @@ parse_config(const char *filename, struct conf *xconf) sizeof(xconf->lockpath)); for (i = 0; i < CWM_COLOR_MAX; i++) - xconf->color[i].name = conf->color[i].name; + xconf->color[i] = conf->color[i]; for (i = 0; i < CWM_COLOR_MENU_MAX; i++) xconf->menucolor[i] = conf->menucolor[i];