]>
Dogcows Code - chaz/openbox/blob - render/color.c
5 #include "../kernel/openbox.h"
6 void color_allocate_gc(color_rgb
*in
)
10 gcv
.foreground
= in
->pixel
;
11 gcv
.cap_style
= CapProjecting
;
12 in
->gc
= XCreateGC(ob_display
, ob_root
, GCForeground
| GCCapStyle
, &gcv
);
15 color_rgb
*color_parse(char *colorname
)
19 g_assert(colorname
!= NULL
);
20 // get rgb values from colorname
26 if (!XParseColor(ob_display
, render_colormap
, colorname
, &xcol
)) {
27 g_warning("unable to parse color '%s'", colorname
);
30 return color_new(xcol
.red
>> 8, xcol
.green
>> 8, xcol
.blue
>> 8);
33 color_rgb
*color_new(int r
, int g
, int b
)
35 /* this should be replaced with something far cooler */
38 xcol
.red
= (r
<< 8) | r
;
39 xcol
.green
= (g
<< 8) | g
;
40 xcol
.blue
= (b
<< 8) | b
;
41 if (XAllocColor(ob_display
, render_colormap
, &xcol
)) {
42 out
= g_new(color_rgb
, 1);
43 out
->r
= xcol
.red
>> 8;
44 out
->g
= xcol
.green
>> 8;
45 out
->b
= xcol
.blue
>> 8;
47 out
->pixel
= xcol
.pixel
;
53 //XXX same color could be pointed to twice, this might have to be a refcount
55 void color_free(color_rgb
*c
)
58 XFreeGC(ob_display
, c
->gc
);
This page took 0.034845 seconds and 4 git commands to generate.