aboutsummaryrefslogtreecommitdiffstats
path: root/xutil.c
diff options
context:
space:
mode:
Diffstat (limited to 'xutil.c')
-rw-r--r--xutil.c22
1 files changed, 21 insertions, 1 deletions
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);
+}