ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtcolor.C
(Generate patch)

Comparing rxvt-unicode/src/rxvtcolor.C (file contents):
Revision 1.1 by pcg, Mon Nov 24 17:28:08 2003 UTC vs.
Revision 1.3 by pcg, Sat Jan 31 00:20:21 2004 UTC

2#include <rxvt.h> 2#include <rxvt.h>
3 3
4// TODO: free colors again 4// TODO: free colors again
5 5
6bool 6bool
7rxvt_color::set (pR_ Pixel p) 7rxvt_color::set (rxvt_term *t, Pixel p)
8{ 8{
9#if XFT 9#if XFT
10 XColor xc; 10 XColor xc;
11 11
12 xc.pixel = p; 12 xc.pixel = p;
13 if (!XQueryColor (R->Xdisplay, XCMAP, &xc)) 13 if (!XQueryColor (t->Xdisplay, t->Xcmap, &xc))
14 return false; 14 return false;
15 15
16 XRenderColor d; 16 XRenderColor d;
17 17
18 d.red = xc.red; 18 d.red = xc.red;
19 d.green = xc.green; 19 d.green = xc.green;
20 d.blue = xc.blue; 20 d.blue = xc.blue;
21 d.alpha = 0xffff; 21 d.alpha = 0xffff;
22 22
23 return 23 return
24 XftColorAllocValue (R->Xdisplay, 24 XftColorAllocValue (t->Xdisplay,
25 XVISUAL, 25 t->Xvisual,
26 XCMAP, 26 t->Xcmap,
27 &d, 27 &d,
28 &c); 28 &c);
29#else 29#else
30 this->p = p; 30 this->p = p;
31#endif 31#endif
32 32
33 return true; 33 return true;
34} 34}
35 35
36bool 36bool
37rxvt_color::set (pR_ const char *name) 37rxvt_color::set (rxvt_term *t, const char *name)
38{ 38{
39 XColor xc; 39 XColor xc;
40 40
41 if (XParseColor (R->Xdisplay, XCMAP, name, &xc)) 41 if (XParseColor (t->Xdisplay, t->Xcmap, name, &xc))
42 return set (aR_ xc.red, xc.green, xc.blue); 42 return set (t, xc.red, xc.green, xc.blue);
43 43
44 return false; 44 return false;
45} 45}
46 46
47bool 47bool
48rxvt_color::set (pR_ unsigned short cr, unsigned short cg, unsigned short cb) 48rxvt_color::set (rxvt_term *t, unsigned short cr, unsigned short cg, unsigned short cb)
49{ 49{
50 XColor xc; 50 XColor xc;
51 51
52 xc.red = cr; 52 xc.red = cr;
53 xc.green = cg; 53 xc.green = cg;
54 xc.blue = cb; 54 xc.blue = cb;
55 xc.flags = DoRed | DoGreen | DoBlue; 55 xc.flags = DoRed | DoGreen | DoBlue;
56 56
57 if (XAllocColor (R->Xdisplay, XCMAP, &xc)) 57 if (XAllocColor (t->Xdisplay, t->Xcmap, &xc))
58 return set (aR_ xc.pixel); 58 return set (t, xc.pixel);
59 59
60 return false; 60 return false;
61} 61}
62 62
63void 63void
64rxvt_color::get (pR_ unsigned short &cr, unsigned short &cg, unsigned short &cb) 64rxvt_color::get (rxvt_term *t, unsigned short &cr, unsigned short &cg, unsigned short &cb)
65{ 65{
66#if XFT 66#if XFT
67 cr = c.color.red; 67 cr = c.color.red;
68 cg = c.color.green; 68 cg = c.color.green;
69 cb = c.color.blue; 69 cb = c.color.blue;
70#else 70#else
71 XColor c; 71 XColor c;
72 72
73 c.pixel = p; 73 c.pixel = p;
74 XQueryColor (R->Xdisplay, XCMAP, &c); 74 XQueryColor (t->Xdisplay, t->Xcmap, &c);
75 75
76 cr = c.red; 76 cr = c.red;
77 cg = c.green; 77 cg = c.green;
78 cb = c.blue; 78 cb = c.blue;
79#endif 79#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines