Include mod_xrandr instead of using submodules
[notion/jeffpc.git] / de / colour.c
blob5bd2d609308be8a5d88a608632882b863c4dba5c
1 /*
2 * ion/de/colour.h
4 * Copyright (c) Tuomo Valkonen 1999-2009.
6 * See the included file LICENSE for details.
7 */
9 #include <ioncore/common.h>
10 #include "colour.h"
13 bool de_alloc_colour(WRootWin *rootwin, DEColour *ret, const char *name)
15 XColor c;
16 bool ok=FALSE;
18 if(name==NULL)
19 return FALSE;
21 if(XParseColor(ioncore_g.dpy, rootwin->default_cmap, name, &c)){
22 ok=XAllocColor(ioncore_g.dpy, rootwin->default_cmap, &c);
23 if(ok)
24 *ret=c.pixel;
27 return ok;
31 bool de_duplicate_colour(WRootWin *rootwin, DEColour in, DEColour *out)
33 XColor c;
34 c.pixel=in;
35 XQueryColor(ioncore_g.dpy, rootwin->default_cmap, &c);
36 if(XAllocColor(ioncore_g.dpy, rootwin->default_cmap, &c)){
37 *out=c.pixel;
38 return TRUE;
40 return FALSE;
44 void de_free_colour_group(WRootWin *rootwin, DEColourGroup *cg)
46 DEColour pixels[5];
48 pixels[0]=cg->bg;
49 pixels[1]=cg->fg;
50 pixels[2]=cg->hl;
51 pixels[3]=cg->sh;
52 pixels[4]=cg->pad;
54 XFreeColors(ioncore_g.dpy, rootwin->default_cmap, pixels, 5, 0);
56 gr_stylespec_unalloc(&cg->spec);
60 void de_free_colour(WRootWin *rootwin, DEColour col)
62 DEColour pixels[1];
64 pixels[0]=col;
66 XFreeColors(ioncore_g.dpy, rootwin->default_cmap, pixels, 1, 0);