From 4d5dc5d9ea24d1b856c8b8c13c36a16daa396a4d Mon Sep 17 00:00:00 2001 From: okan Date: Sun, 17 May 2009 23:40:57 +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@ --- xutil.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'xutil.c') diff --git a/xutil.c b/xutil.c index 7246531..e5129b6 100644 --- a/xutil.c +++ b/xutil.c @@ -184,3 +184,23 @@ xu_getatoms(void) { XInternAtoms(X_Dpy, atoms, CWM_NO_ATOMS, False, cwm_atoms); } + +unsigned long +xu_getcolor(struct screen_ctx *sc, char *name) +{ + XColor color, tmp; + + if (!XAllocNamedColor(X_Dpy, DefaultColormap(X_Dpy, sc->which), + name, &color, &tmp)) { + warnx("XAllocNamedColor error: '%s'", name); + return 0; + } + + return color.pixel; +} + +void +xu_freecolor(struct screen_ctx *sc, unsigned long pixel) +{ + XFreeColors(X_Dpy, DefaultColormap(X_Dpy, sc->which), &pixel, 1, 0L); +} -- cgit 1.4.1