diff options
Diffstat (limited to '')
-rw-r--r-- | calmwm.h | 31 | ||||
-rw-r--r-- | client.c | 10 | ||||
-rw-r--r-- | conf.c | 49 | ||||
-rw-r--r-- | font.c | 24 | ||||
-rw-r--r-- | parse.y | 23 | ||||
-rw-r--r-- | xutil.c | 26 |
6 files changed, 67 insertions, 96 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: calmwm.h,v 1.202 2013/05/19 17:05:52 okan Exp $ + * $OpenBSD: calmwm.h,v 1.203 2013/05/19 23:09:59 okan Exp $ */ #ifndef _CALMWM_H_ @@ -85,20 +85,16 @@ union arg { int i; }; -enum menucolor { - CWM_COLOR_MENU_FG, - CWM_COLOR_MENU_BG, - CWM_COLOR_MENU_FONT, - CWM_COLOR_MENU_FONT_SEL, - CWM_COLOR_MENU_MAX -}; - -enum bordercolor { +enum color { CWM_COLOR_BORDER_ACTIVE, CWM_COLOR_BORDER_INACTIVE, CWM_COLOR_BORDER_GROUP, CWM_COLOR_BORDER_UNGROUP, - CWM_COLOR_BORDER_MAX + CWM_COLOR_MENU_FG, + CWM_COLOR_MENU_BG, + CWM_COLOR_MENU_FONT, + CWM_COLOR_MENU_FONT_SEL, + CWM_COLOR_MAX }; struct geom { @@ -213,13 +209,12 @@ struct screen_ctx { Colormap colormap; Window rootwin; Window menuwin; - unsigned long color[CWM_COLOR_BORDER_MAX]; int cycling; struct geom view; /* viewable area */ struct geom work; /* workable area, gap-applied */ struct gap gap; struct cycle_entry_q mruq; - XftColor xftcolor[CWM_COLOR_MENU_MAX]; + XftColor xftcolor[CWM_COLOR_MAX]; XftDraw *xftdraw; XftFont *xftfont; int xinerama_no; @@ -293,8 +288,7 @@ struct conf { #define CONF_SNAPDIST 0 int snapdist; struct gap gap; - char *color[CWM_COLOR_BORDER_MAX]; - char *menucolor[CWM_COLOR_MENU_MAX]; + char *color[CWM_COLOR_MAX]; char termpath[MAXPATHLEN]; char lockpath[MAXPATHLEN]; char known_hosts[MAXPATHLEN]; @@ -452,8 +446,7 @@ void conf_ungrab(struct conf *, struct keybinding *); void font_draw(struct screen_ctx *, const char *, Drawable, int, int, int); -void font_init(struct screen_ctx *, const char *, - const char **); +void font_init(struct screen_ctx *, const char *); int font_width(XftFont *, const char *, int); void xev_loop(void); @@ -462,7 +455,6 @@ void xu_btn_grab(Window, int, u_int); void xu_btn_ungrab(Window, int, u_int); void xu_configure(struct client_ctx *); void xu_getatoms(void); -unsigned long xu_getcolor(struct screen_ctx *, char *); int xu_getprop(Window, Atom, Atom, long, u_char **); int xu_get_wm_state(Window, int *); int xu_getstrprop(Window, Atom, char **); @@ -475,8 +467,7 @@ void xu_ptr_setpos(Window, int, int); void xu_ptr_ungrab(void); void xu_sendmsg(Window, Atom, long); void xu_set_wm_state(Window win, int); -void xu_xorcolor(XRenderColor, XRenderColor, - XRenderColor *); +void xu_xorcolor(XftColor, XftColor, XftColor *); void xu_ewmh_net_supported(struct screen_ctx *); void xu_ewmh_net_supported_wm_check(struct screen_ctx *); @@ -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.130 2013/05/19 17:02:04 okan Exp $ + * $OpenBSD: client.c,v 1.131 2013/05/19 23:09:59 okan Exp $ */ #include <sys/param.h> @@ -480,17 +480,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 = sc->xftcolor[CWM_COLOR_BORDER_GROUP].pixel; break; case CLIENT_UNGROUP: - pixel = sc->color[CWM_COLOR_BORDER_UNGROUP]; + pixel = sc->xftcolor[CWM_COLOR_BORDER_UNGROUP].pixel; break; default: - pixel = sc->color[CWM_COLOR_BORDER_ACTIVE]; + pixel = sc->xftcolor[CWM_COLOR_BORDER_ACTIVE].pixel; break; } else - pixel = sc->color[CWM_COLOR_BORDER_INACTIVE]; + pixel = sc->xftcolor[CWM_COLOR_BORDER_INACTIVE].pixel; XSetWindowBorderWidth(X_Dpy, cc->win, cc->bwidth); XSetWindowBorder(X_Dpy, cc->win, pixel); @@ -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); @@ -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: font.c,v 1.26 2013/05/14 12:35:56 okan Exp $ + * $OpenBSD: font.c,v 1.27 2013/05/19 23:09:59 okan Exp $ */ #include <sys/param.h> @@ -31,11 +31,8 @@ #include "calmwm.h" void -font_init(struct screen_ctx *sc, const char *name, const char **color) +font_init(struct screen_ctx *sc, const char *name) { - int i; - XRenderColor c; - sc->xftdraw = XftDrawCreate(X_Dpy, sc->rootwin, sc->visual, sc->colormap); if (sc->xftdraw == NULL) @@ -44,23 +41,6 @@ font_init(struct screen_ctx *sc, const char *name, const char **color) sc->xftfont = XftFontOpenName(X_Dpy, sc->which, name); if (sc->xftfont == NULL) errx(1, "XftFontOpenName"); - - for (i = 0; i < CWM_COLOR_MENU_MAX; i++) { - if (*color[i] == '\0') - break; - if (!XftColorAllocName(X_Dpy, sc->visual, sc->colormap, - color[i], &sc->xftcolor[i])) - errx(1, "XftColorAllocName"); - } - if (i == CWM_COLOR_MENU_MAX) - return; - - xu_xorcolor(sc->xftcolor[CWM_COLOR_MENU_BG].color, - sc->xftcolor[CWM_COLOR_MENU_FG].color, &c); - xu_xorcolor(sc->xftcolor[CWM_COLOR_MENU_FONT].color, c, &c); - if (!XftColorAllocValue(X_Dpy, sc->visual, sc->colormap, - &c, &sc->xftcolor[CWM_COLOR_MENU_FONT_SEL])) - errx(1, "XftColorAllocValue"); } int @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.41 2013/05/06 19:09:19 okan Exp $ */ +/* $OpenBSD: parse.y,v 1.42 2013/05/19 23:09:59 okan Exp $ */ /* * Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -198,20 +198,20 @@ colors : ACTIVEBORDER STRING { conf->color[CWM_COLOR_BORDER_UNGROUP] = $2; } | MENUBG STRING { - free(conf->menucolor[CWM_COLOR_MENU_BG]); - conf->menucolor[CWM_COLOR_MENU_BG] = $2; + free(conf->color[CWM_COLOR_MENU_BG]); + conf->color[CWM_COLOR_MENU_BG] = $2; } | MENUFG STRING { - free(conf->menucolor[CWM_COLOR_MENU_FG]); - conf->menucolor[CWM_COLOR_MENU_FG] = $2; + free(conf->color[CWM_COLOR_MENU_FG]); + conf->color[CWM_COLOR_MENU_FG] = $2; } | FONTCOLOR STRING { - free(conf->menucolor[CWM_COLOR_MENU_FONT]); - conf->menucolor[CWM_COLOR_MENU_FONT] = $2; + free(conf->color[CWM_COLOR_MENU_FONT]); + conf->color[CWM_COLOR_MENU_FONT] = $2; } | FONTSELCOLOR STRING { - free(conf->menucolor[CWM_COLOR_MENU_FONT_SEL]); - conf->menucolor[CWM_COLOR_MENU_FONT_SEL] = $2; + free(conf->color[CWM_COLOR_MENU_FONT_SEL]); + conf->color[CWM_COLOR_MENU_FONT_SEL] = $2; } ; %% @@ -589,12 +589,9 @@ parse_config(const char *filename, struct conf *xconf) (void)strlcpy(xconf->lockpath, conf->lockpath, sizeof(xconf->lockpath)); - for (i = 0; i < CWM_COLOR_BORDER_MAX; i++) + for (i = 0; i < CWM_COLOR_MAX; i++) xconf->color[i] = conf->color[i]; - for (i = 0; i < CWM_COLOR_MENU_MAX; i++) - xconf->menucolor[i] = conf->menucolor[i]; - xconf->font = conf->font; } @@ -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: xutil.c,v 1.61 2013/05/19 17:05:52 okan Exp $ + * $OpenBSD: xutil.c,v 1.62 2013/05/19 23:09:59 okan Exp $ */ #include <sys/param.h> @@ -420,24 +420,12 @@ xu_ewmh_net_wm_desktop(struct client_ctx *cc) XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&no, 1); } -unsigned long -xu_getcolor(struct screen_ctx *sc, char *name) -{ - XColor color, tmp; - - if (!XAllocNamedColor(X_Dpy, sc->colormap, name, &color, &tmp)) { - warnx("XAllocNamedColor error: '%s'", name); - return (0); - } - - return (color.pixel); -} - void -xu_xorcolor(XRenderColor a, XRenderColor b, XRenderColor *r) +xu_xorcolor(XftColor a, XftColor b, XftColor *r) { - r->red = a.red ^ b.red; - r->green = a.green ^ b.green; - r->blue = a.blue ^ b.blue; - r->alpha = 0xffff; + r->pixel = a.pixel ^ b.pixel; + r->color.red = a.color.red ^ b.color.red; + r->color.green = a.color.green ^ b.color.green; + r->color.blue = a.color.blue ^ b.color.blue; + r->color.alpha = 0xffff; } |