#include "config.h" #include #include #include #include #include #include "colors.h" /* arch-tag: bbb50f3b-a3d2-44e7-9d21-54333bb80d30 */ static struct color *colors = NULL; static void do_alloc(Display *disp, Colormap cmap, struct color *c) { XColor c1, c2; XAllocNamedColor(disp, cmap, c->name, &c1, &c2); XRenderParseColor(disp, (char *)c->name, &c->rc.color); c->pixel = c1.pixel; c->red = c2.red; c->green = c2.green; c->blue = c2.blue; c->rc.pixel = c->pixel; } struct color * get_color(const char *name) { assert(name); struct color *c = colors; for(;c; c = c->next) if(!strcmp(name,c->name)) return c; c = g_slice_new(struct color); c->name = name; c->next = colors; colors = c; return c; } struct color * get_alloc_color(Display *disp, Colormap cmap, const char *name) { struct color *c = get_color(name); do_alloc(disp,cmap, c); return c; } void realloc_colors(Display *disp, Colormap cmap) { struct color *c = colors; for(;c; c = c->next) do_alloc(disp,cmap, c); }