trunk: changeset 1972
[notion/jeffpc.git] / de / colour.c
blobb31d48d830a55230b4951f8ef46f4714659dbe3a
1 /*
2 * ion/de/colour.h
4 * Copyright (c) Tuomo Valkonen 1999-2005.
6 * Ion is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
12 #include <ioncore/common.h>
13 #include "colour.h"
16 bool de_alloc_colour(WRootWin *rootwin, DEColour *ret, const char *name)
18 XColor c;
19 bool ok=FALSE;
21 if(name==NULL)
22 return FALSE;
24 if(XParseColor(ioncore_g.dpy, rootwin->default_cmap, name, &c)){
25 ok=XAllocColor(ioncore_g.dpy, rootwin->default_cmap, &c);
26 if(ok)
27 *ret=c.pixel;
30 return ok;
34 bool de_duplicate_colour(WRootWin *rootwin, DEColour in, DEColour *out)
36 XColor c;
37 c.pixel=in;
38 XQueryColor(ioncore_g.dpy, rootwin->default_cmap, &c);
39 if(XAllocColor(ioncore_g.dpy, rootwin->default_cmap, &c)){
40 *out=c.pixel;
41 return TRUE;
43 return FALSE;
47 void de_free_colour_group(WRootWin *rootwin, DEColourGroup *cg)
49 DEColour pixels[5];
51 pixels[0]=cg->bg;
52 pixels[1]=cg->fg;
53 pixels[2]=cg->hl;
54 pixels[3]=cg->sh;
55 pixels[4]=cg->pad;
57 XFreeColors(ioncore_g.dpy, rootwin->default_cmap, pixels, 5, 0);
59 if(cg->spec!=NULL){
60 free(cg->spec);
61 cg->spec=NULL;
66 void de_free_colour(WRootWin *rootwin, DEColour col)
68 DEColour pixels[1];
70 pixels[0]=col;
72 XFreeColors(ioncore_g.dpy, rootwin->default_cmap, pixels, 1, 0);