ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvttoolkit.h
Revision: 1.11
Committed: Wed Jan 25 02:42:06 2006 UTC (18 years, 4 months ago) by root
Content type: text/plain
Branch: MAIN
Changes since 1.10: +38 -2 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     struct rxvt_display : refcounted {
102     io_manager_vec<xevent_watcher> xw;
103    
104     io_watcher x_ev; void x_cb (io_watcher &w, short revents);
105    
106     #ifdef USE_XIM
107     refcache<rxvt_xim> xims;
108     vector<im_watcher *> imw;
109    
110     void im_change_cb ();
111 root 1.3 void im_change_check ();
112 root 1.1 #endif
113    
114     //public
115 root 1.7 Display *display;
116     int depth;
117     int screen;
118     Visual *visual;
119     Colormap cmap;
120     Window root;
121 root 1.1 rxvt_term *selection_owner;
122 root 1.11 Atom xa[NUM_XA];
123 root 1.1 #ifndef NO_SLOW_LINK_SUPPORT
124 root 1.7 bool is_local;
125     #endif
126     #ifdef POINTER_BLANK
127     Cursor blank_cursor;
128 root 1.1 #endif
129    
130     rxvt_display (const char *id);
131 root 1.9 XrmDatabase get_resources ();
132     bool ref_init ();
133     void ref_next ();
134 root 1.1 ~rxvt_display ();
135    
136     void flush ();
137 root 1.5 Atom atom (const char *name);
138 root 1.1 void set_selection_owner (rxvt_term *owner);
139    
140     void reg (xevent_watcher *w);
141     void unreg (xevent_watcher *w);
142    
143     #ifdef USE_XIM
144     void reg (im_watcher *w);
145     void unreg (im_watcher *w);
146    
147     rxvt_xim *get_xim (const char *locale, const char *modifiers);
148     void put_xim (rxvt_xim *xim);
149     #endif
150     };
151    
152     #ifdef USE_XIM
153     struct im_watcher : watcher, callback0<void> {
154     template<class O1, class O2>
155     im_watcher (O1 *object, void (O2::*method) ())
156     : callback0<void> (object,method)
157     { }
158    
159     void start (rxvt_display *display)
160     {
161     display->reg (this);
162     }
163     void stop (rxvt_display *display)
164     {
165     display->unreg (this);
166     }
167     };
168     #endif
169    
170     struct xevent_watcher : watcher, callback1<void, XEvent &> {
171     Window window;
172    
173     template<class O1, class O2>
174     xevent_watcher (O1 *object, void (O2::*method) (XEvent &))
175     : callback1<void, XEvent &> (object,method)
176     { }
177    
178     void start (rxvt_display *display, Window window)
179     {
180     this->window = window;
181     display->reg (this);
182     }
183     void stop (rxvt_display *display)
184     {
185     display->unreg (this);
186     }
187     };
188    
189     extern refcache<rxvt_display> displays;
190    
191     /////////////////////////////////////////////////////////////////////////////
192    
193     typedef unsigned long Pixel;
194    
195     struct rxvt_color {
196     #if XFT
197     XftColor c;
198     operator Pixel () const { return c.pixel; }
199     #else
200     Pixel p;
201     operator Pixel () const { return p; }
202     #endif
203    
204     bool operator == (const rxvt_color &b) const { return Pixel (*this) == Pixel (b); }
205     bool operator != (const rxvt_color &b) const { return Pixel (*this) != Pixel (b); }
206    
207     void get (rxvt_display *display, unsigned short &cr, unsigned short &cg, unsigned short &cb);
208    
209     bool set (rxvt_display *display, Pixel p);
210     bool set (rxvt_display *display, const char *name);
211     bool set (rxvt_display *display, unsigned short cr, unsigned short cg, unsigned short cb);
212    
213 root 1.8 rxvt_color fade (rxvt_display *, int percent); // fades to black
214     rxvt_color fade (rxvt_display *, int percent, rxvt_color &fadeto);
215 root 1.1
216     void free (rxvt_display *display);
217     };
218    
219     #endif
220