ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvttoolkit.h
Revision: 1.12
Committed: Wed Jan 25 21:03:04 2006 UTC (18 years, 4 months ago) by root
Content type: text/plain
Branch: MAIN
CVS Tags: rel-7_3, rel-7_4, rel-7_3a
Changes since 1.11: +19 -10 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 /*
2     * rxvttoolkit.h - provide toolkit-functionality for rxvt.
3     */
4     #ifndef RXVT_TOOLKIT_H
5     #define RXVT_TOOLKIT_H
6    
7     #include <X11/Xlib.h>
8    
9     #if XFT
10     # include <X11/Xft/Xft.h>
11     #endif
12    
13     #include "iom.h"
14    
15     #include "rxvtlib.h"
16     #include "rxvtutil.h"
17    
18     #include "callback.h"
19    
20 root 1.11 // see rxvttoolkit.C:xa_names, which must be kept in sync
21     enum {
22     XA_TEXT,
23     XA_COMPOUND_TEXT,
24     XA_UTF8_STRING,
25     XA_MULTIPLE,
26     XA_TARGETS,
27     XA_TIMESTAMP,
28     XA_VT_SELECTION,
29     XA_INCR,
30     XA_WM_PROTOCOLS,
31     XA_WM_DELETE_WINDOW,
32     XA_CLIPBOARD,
33     #if ENABLE_FRILLS
34     XA_MOTIF_WM_HINTS,
35     #endif
36     #if ENABLE_EWMH
37     XA_NET_WM_PID,
38     XA_NET_WM_NAME,
39     XA_NET_WM_ICON_NAME,
40     XA_NET_WM_PING,
41     #endif
42     #if USE_XIM
43     XA_WM_LOCALE_NAME,
44     XA_XIM_SERVERS,
45     #endif
46     #if TRANSPARENT
47     XA_XROOTPMAP_ID,
48     XA_ESETROOT_PMAP_ID,
49     #endif
50     #if ENABLE_XEMBED
51     XA_XEMBED,
52     XA_XEMBED_INFO,
53     #endif
54     NUM_XA
55     };
56    
57 root 1.1 struct rxvt_term;
58 root 1.2 struct rxvt_display;
59 root 1.1
60     struct im_watcher;
61     struct xevent_watcher;
62    
63     struct refcounted {
64     int referenced;
65     char *id;
66    
67     refcounted (const char *id);
68 root 1.9 bool ref_init () { return false; }
69     void ref_next () { }
70 root 1.1 ~refcounted ();
71     };
72    
73     template<class T>
74     struct refcache : vector<T *> {
75     T *get (const char *id);
76     void put (T *obj);
77 root 1.7 void clear ();
78    
79     ~refcache ()
80     {
81     clear ();
82     }
83 root 1.1 };
84    
85     /////////////////////////////////////////////////////////////////////////////
86    
87     #ifdef USE_XIM
88     struct rxvt_xim : refcounted {
89     void destroy ();
90     rxvt_display *display;
91    
92     //public
93     XIM xim;
94    
95     rxvt_xim (const char *id) : refcounted (id) { }
96 root 1.9 bool ref_init ();
97 root 1.1 ~rxvt_xim ();
98     };
99     #endif
100    
101 root 1.12 struct rxvt_screen {
102     rxvt_display *display;
103     Display *xdisp;
104     int depth;
105     Visual *visual;
106     Colormap cmap;
107    
108     void set (rxvt_display *disp);
109     void set (rxvt_display *disp, int depth);
110     void clear ();
111     };
112    
113 root 1.1 struct rxvt_display : refcounted {
114     io_manager_vec<xevent_watcher> xw;
115    
116     io_watcher x_ev; void x_cb (io_watcher &w, short revents);
117    
118     #ifdef USE_XIM
119     refcache<rxvt_xim> xims;
120     vector<im_watcher *> imw;
121    
122     void im_change_cb ();
123 root 1.3 void im_change_check ();
124 root 1.1 #endif
125    
126     //public
127 root 1.7 Display *display;
128     int screen;
129     Window root;
130 root 1.1 rxvt_term *selection_owner;
131 root 1.11 Atom xa[NUM_XA];
132 root 1.1 #ifndef NO_SLOW_LINK_SUPPORT
133 root 1.7 bool is_local;
134     #endif
135     #ifdef POINTER_BLANK
136     Cursor blank_cursor;
137 root 1.1 #endif
138    
139     rxvt_display (const char *id);
140 root 1.9 XrmDatabase get_resources ();
141     bool ref_init ();
142     void ref_next ();
143 root 1.1 ~rxvt_display ();
144    
145     void flush ();
146 root 1.5 Atom atom (const char *name);
147 root 1.1 void set_selection_owner (rxvt_term *owner);
148    
149     void reg (xevent_watcher *w);
150     void unreg (xevent_watcher *w);
151    
152     #ifdef USE_XIM
153     void reg (im_watcher *w);
154     void unreg (im_watcher *w);
155    
156     rxvt_xim *get_xim (const char *locale, const char *modifiers);
157     void put_xim (rxvt_xim *xim);
158     #endif
159     };
160    
161     #ifdef USE_XIM
162     struct im_watcher : watcher, callback0<void> {
163     template<class O1, class O2>
164     im_watcher (O1 *object, void (O2::*method) ())
165     : callback0<void> (object,method)
166     { }
167    
168     void start (rxvt_display *display)
169     {
170     display->reg (this);
171     }
172     void stop (rxvt_display *display)
173     {
174     display->unreg (this);
175     }
176     };
177     #endif
178    
179     struct xevent_watcher : watcher, callback1<void, XEvent &> {
180     Window window;
181    
182     template<class O1, class O2>
183     xevent_watcher (O1 *object, void (O2::*method) (XEvent &))
184     : callback1<void, XEvent &> (object,method)
185     { }
186    
187     void start (rxvt_display *display, Window window)
188     {
189     this->window = window;
190     display->reg (this);
191     }
192     void stop (rxvt_display *display)
193     {
194     display->unreg (this);
195     }
196     };
197    
198     extern refcache<rxvt_display> displays;
199    
200     /////////////////////////////////////////////////////////////////////////////
201    
202     typedef unsigned long Pixel;
203    
204     struct rxvt_color {
205     #if XFT
206     XftColor c;
207     operator Pixel () const { return c.pixel; }
208     #else
209     Pixel p;
210     operator Pixel () const { return p; }
211     #endif
212    
213     bool operator == (const rxvt_color &b) const { return Pixel (*this) == Pixel (b); }
214     bool operator != (const rxvt_color &b) const { return Pixel (*this) != Pixel (b); }
215    
216 root 1.12 void get (rxvt_screen *screen, unsigned short &cr, unsigned short &cg, unsigned short &cb);
217 root 1.1
218 root 1.12 bool set (rxvt_screen *screen, Pixel p);
219     bool set (rxvt_screen *screen, const char *name);
220     bool set (rxvt_screen *screen, unsigned short cr, unsigned short cg, unsigned short cb);
221 root 1.1
222 root 1.12 rxvt_color fade (rxvt_screen *screen, int percent); // fades to black
223     rxvt_color fade (rxvt_screen *screen, int percent, rxvt_color &fadeto);
224 root 1.1
225 root 1.12 void free (rxvt_screen *screen);
226 root 1.1 };
227    
228     #endif
229