ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvtcolor.h
Revision: 1.9
Committed: Wed Feb 25 15:06:05 2004 UTC (20 years, 3 months ago) by pcg
Content type: text/plain
Branch: MAIN
CVS Tags: rel-2_1_0, rxvt-2-0, rel-2_4, rel-2_5, rel-2_2, rel-2_3, rel-2_0, rel-1-9, rel-1_9
Changes since 1.8: +1 -2 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 pcg 1.1 #ifndef RXVT_COLOR_H
2     #define RXVT_COLOR_H
3    
4     #include <X11/Xlib.h>
5    
6     #if XFT
7     # include <X11/Xft/Xft.h>
8     #endif
9    
10 pcg 1.3 #include "iom.h"
11    
12 pcg 1.1 #include "rxvtlib.h"
13 pcg 1.3 #include "rxvtstl.h"
14    
15     #include "callback.h"
16 pcg 1.1
17 pcg 1.4 struct rxvt_term;
18 pcg 1.1
19 pcg 1.5 struct im_watcher;
20 pcg 1.3 struct xevent_watcher;
21    
22 pcg 1.5 struct refcounted {
23 pcg 1.3 int referenced;
24 pcg 1.5 char *id;
25    
26     refcounted (const char *id);
27 pcg 1.8 bool init () { return false; }
28 pcg 1.5 ~refcounted ();
29     };
30    
31     template<class T>
32     struct refcache : vector<T *> {
33     T *get (const char *id);
34     void put (T *obj);
35     ~refcache ();
36     };
37    
38     /////////////////////////////////////////////////////////////////////////////
39    
40     struct rxvt_xim : refcounted {
41     void destroy ();
42     rxvt_display *display;
43    
44     //public
45     XIM xim;
46    
47     rxvt_xim (const char *id) : refcounted (id) { }
48     bool init ();
49     ~rxvt_xim ();
50     };
51    
52     struct rxvt_display : refcounted {
53     Atom xa_xim_servers;
54 pcg 1.4
55 pcg 1.3 io_manager_vec<xevent_watcher> xw;
56 pcg 1.5
57 pcg 1.6 io_watcher x_ev; void x_cb (io_watcher &w, short revents);
58 pcg 1.3
59 pcg 1.5 refcache<rxvt_xim> xims;
60     vector<im_watcher *> imw;
61    
62     void im_change_cb ();
63    
64 pcg 1.3 //public
65     Display *display;
66     int depth;
67     int screen;
68     Visual *visual;
69     Colormap cmap;
70     Window root;
71 pcg 1.9 rxvt_term *selection_owner;
72 pcg 1.3
73 pcg 1.5 rxvt_display (const char *id);
74     bool init ();
75     ~rxvt_display ();
76 pcg 1.3
77 pcg 1.6 void flush ();
78    
79 pcg 1.3 void reg (xevent_watcher *w);
80     void unreg (xevent_watcher *w);
81 pcg 1.5 void reg (im_watcher *w);
82     void unreg (im_watcher *w);
83    
84     void set_selection_owner (rxvt_term *owner);
85    
86     rxvt_xim *get_xim (const char *locale, const char *modifiers);
87     void put_xim (rxvt_xim *xim);
88     };
89 pcg 1.3
90 pcg 1.5 struct im_watcher : watcher, callback0<void> {
91     template<class O1, class O2>
92 pcg 1.7 im_watcher (O1 *object, void (O2::*method) ())
93     : callback0<void> (object,method)
94 pcg 1.5 { }
95 pcg 1.4
96 pcg 1.5 void start (rxvt_display *display)
97     {
98     display->reg (this);
99     }
100     void stop (rxvt_display *display)
101     {
102     display->unreg (this);
103     }
104 pcg 1.3 };
105    
106     struct xevent_watcher : watcher, callback1<void, XEvent &> {
107     Window window;
108    
109     template<class O1, class O2>
110 pcg 1.7 xevent_watcher (O1 *object, void (O2::*method) (XEvent &))
111     : callback1<void, XEvent &> (object,method)
112 pcg 1.3 { }
113    
114     void start (rxvt_display *display, Window window)
115     {
116     this->window = window;
117     display->reg (this);
118     }
119     void stop (rxvt_display *display)
120     {
121     display->unreg (this);
122     }
123     };
124    
125 pcg 1.5 extern refcache<rxvt_display> displays;
126 pcg 1.3
127 pcg 1.5 /////////////////////////////////////////////////////////////////////////////
128 pcg 1.3
129 pcg 1.1 typedef unsigned long Pixel;
130    
131     struct rxvt_color {
132     #if XFT
133 pcg 1.3 XftColor c;
134 pcg 1.7 operator Pixel () const { return c.pixel; }
135 pcg 1.1 #else
136 pcg 1.3 Pixel p;
137 pcg 1.7 operator Pixel () const { return p; }
138 pcg 1.1 #endif
139    
140 pcg 1.7 bool operator == (const rxvt_color &b) const { return Pixel (*this) == Pixel (b); }
141     bool operator != (const rxvt_color &b) const { return Pixel (*this) != Pixel (b); }
142 pcg 1.1
143 pcg 1.3 void get (rxvt_display *display, unsigned short &cr, unsigned short &cg, unsigned short &cb);
144    
145     bool set (rxvt_display *display, Pixel p);
146     bool set (rxvt_display *display, const char *name);
147     bool set (rxvt_display *display, unsigned short cr, unsigned short cg, unsigned short cb);
148    
149     void free (rxvt_display *display);
150 pcg 1.1 };
151    
152     #endif
153