aboutsummaryrefslogtreecommitdiffstats
path: root/xutil.c
diff options
context:
space:
mode:
authorokan2009-05-17 23:40:57 +0000
committerokan2009-05-17 23:40:57 +0000
commita83ec02263f57eac22f091d37c7e678aed7b8d38 (patch)
tree4b34676783c097eb00c55658b30e6c56c0fc8267 /xutil.c
parent915104a67e5e6fc2c55c6a44b9360c290ea2e61d (diff)
downloadcwm-a83ec02263f57eac22f091d37c7e678aed7b8d38.tar.gz
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 '')
-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);
+}