From a83ec02263f57eac22f091d37c7e678aed7b8d38 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 | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'xutil.c') diff --git a/xutil.c b/xutil.c index db9fe8c..4b03595 100644 --- a/xutil.c +++ b/xutil.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. * - * $Id: xutil.c,v 1.14 2009/01/27 00:42:53 oga Exp $ + * $Id: xutil.c,v 1.15 2009/05/17 23:40:57 okan Exp $ */ #include "headers.h" @@ -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 v1.2.3-2-gb3c3