summaryrefslogtreecommitdiff
path: root/app/cwm/xutil.c
diff options
context:
space:
mode:
authorOkan Demirmen <okan@cvs.openbsd.org>2009-05-17 23:40:58 +0000
committerOkan Demirmen <okan@cvs.openbsd.org>2009-05-17 23:40:58 +0000
commit49c64852885aadb1bd54f8e5d2a1961363db7461 (patch)
tree8c29c10285b08cdd10854a7a7c94ec5e359519f1 /app/cwm/xutil.c
parent643784d1e14fb8db12be54b8c9f89cc3bbc725f3 (diff)
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@
Diffstat (limited to 'app/cwm/xutil.c')
-rw-r--r--app/cwm/xutil.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/app/cwm/xutil.c b/app/cwm/xutil.c
index db9fe8cff..4b03595ff 100644
--- a/app/cwm/xutil.c
+++ b/app/cwm/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);
+}