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

Comparing rxvt-unicode/src/rxvttoolkit.h (file contents):
Revision 1.34 by root, Sun Nov 11 04:08:00 2007 UTC vs.
Revision 1.39 by root, Fri Dec 14 06:17:27 2007 UTC

101 101
102struct im_watcher; 102struct im_watcher;
103struct xevent_watcher; 103struct xevent_watcher;
104 104
105template<class watcher> 105template<class watcher>
106struct event_vec : vector<watcher *> { 106struct event_vec : vector<watcher *>
107{
107 void erase_unordered (unsigned int pos) 108 void erase_unordered (unsigned int pos)
108 { 109 {
109 watcher *w = (*this)[this->size () - 1]; 110 watcher *w = (*this)[this->size () - 1];
110 this->pop_back (); 111 this->pop_back ();
111 112
113 if (((*this)[pos] = w)) // '=' is correct! 114 if (((*this)[pos] = w)) // '=' is correct!
114 w->active = pos + 1; 115 w->active = pos + 1;
115 } 116 }
116}; 117};
117 118
118struct rxvt_watcher { 119struct rxvt_watcher
120{
119 int active; /* 0 == inactive, else index into respective vector */ 121 int active; /* 0 == inactive, else index into respective vector */
120 122
121 bool is_active () { return active; } 123 bool is_active () { return active; }
122 124
123 rxvt_watcher () : active (0) { } 125 rxvt_watcher () : active (0) { }
124}; 126};
125 127
126struct refcounted { 128struct refcounted
129{
127 int referenced; 130 int referenced;
128 char *id; 131 char *id;
129 132
130 refcounted (const char *id); 133 refcounted (const char *id);
131 bool ref_init () { return false; } 134 bool ref_init () { return false; }
132 void ref_next () { } 135 void ref_next () { }
133 ~refcounted (); 136 ~refcounted ();
134}; 137};
135 138
136template<class T> 139template<class T>
137struct refcache : vector<T *> { 140struct refcache : vector<T *>
141{
138 T *get (const char *id); 142 T *get (const char *id);
139 void put (T *obj); 143 void put (T *obj);
140 void clear (); 144 void clear ();
141 145
142 ~refcache () 146 ~refcache ()
147 151
148///////////////////////////////////////////////////////////////////////////// 152/////////////////////////////////////////////////////////////////////////////
149 153
150struct rxvt_screen; 154struct rxvt_screen;
151 155
152struct rxvt_drawable { 156struct rxvt_drawable
157{
153 rxvt_screen *screen; 158 rxvt_screen *screen;
154 Drawable drawable; 159 Drawable drawable;
155 operator Drawable() { return drawable; } 160 operator Drawable() { return drawable; }
156 161
157#if XFT 162#if XFT
173}; 178};
174 179
175///////////////////////////////////////////////////////////////////////////// 180/////////////////////////////////////////////////////////////////////////////
176 181
177#ifdef USE_XIM 182#ifdef USE_XIM
178struct rxvt_xim : refcounted { 183struct rxvt_xim : refcounted
184{
179 void destroy (); 185 void destroy ();
180 rxvt_display *display; 186 rxvt_display *display;
181 187
182//public 188//public
183 XIM xim; 189 XIM xim;
186 bool ref_init (); 192 bool ref_init ();
187 ~rxvt_xim (); 193 ~rxvt_xim ();
188}; 194};
189#endif 195#endif
190 196
191struct rxvt_screen { 197struct rxvt_screen
198{
192 rxvt_display *display; 199 rxvt_display *display;
193 Display *dpy; 200 Display *dpy;
194 int depth; 201 int depth;
195 Visual *visual; 202 Visual *visual;
196 Colormap cmap; 203 Colormap cmap;
208 void set (rxvt_display *disp); 215 void set (rxvt_display *disp);
209 void select_visual (int bitdepth); 216 void select_visual (int bitdepth);
210 void clear (); 217 void clear ();
211}; 218};
212 219
213struct rxvt_display : refcounted { 220struct rxvt_display : refcounted
221{
214 event_vec<xevent_watcher> xw; 222 event_vec<xevent_watcher> xw;
215 223
224 ev::prepare flush_ev; void flush_cb (ev::prepare &w, int revents);
216 ev::io x_ev; void x_cb (ev::io &w, int revents); 225 ev::io x_ev ; void x_cb (ev::io &w, int revents);
217 226
218#ifdef USE_XIM 227#ifdef USE_XIM
219 refcache<rxvt_xim> xims; 228 refcache<rxvt_xim> xims;
220 vector<im_watcher *> imw; 229 vector<im_watcher *> imw;
221 230
238 XrmDatabase get_resources (bool refresh); 247 XrmDatabase get_resources (bool refresh);
239 bool ref_init (); 248 bool ref_init ();
240 void ref_next (); 249 void ref_next ();
241 ~rxvt_display (); 250 ~rxvt_display ();
242 251
243 void flush (); 252 void flush ()
253 {
254 flush_ev.start ();
255 }
256
244 Atom atom (const char *name); 257 Atom atom (const char *name);
245 void set_selection_owner (rxvt_term *owner); 258 void set_selection_owner (rxvt_term *owner);
246 259
247 void reg (xevent_watcher *w); 260 void reg (xevent_watcher *w);
248 void unreg (xevent_watcher *w); 261 void unreg (xevent_watcher *w);
256#endif 269#endif
257}; 270};
258 271
259#ifdef USE_XIM 272#ifdef USE_XIM
260struct im_watcher : rxvt_watcher, callback<void (void)> { 273struct im_watcher : rxvt_watcher, callback<void (void)> {
261 template<class O, class M>
262 im_watcher (O object, M method)
263 : callback<void (void)> (object, method)
264 { }
265
266 void start (rxvt_display *display) 274 void start (rxvt_display *display)
267 { 275 {
268 display->reg (this); 276 display->reg (this);
269 } 277 }
270 278
273 display->unreg (this); 281 display->unreg (this);
274 } 282 }
275}; 283};
276#endif 284#endif
277 285
278struct xevent_watcher : rxvt_watcher, callback<void (XEvent &)> { 286struct xevent_watcher : rxvt_watcher, callback<void (XEvent &)>
287{
279 Window window; 288 Window window;
280
281 template<class O, class M>
282 xevent_watcher (O object, M method)
283 : callback<void (XEvent &)> (object, method)
284 { }
285 289
286 void start (rxvt_display *display, Window window) 290 void start (rxvt_display *display, Window window)
287 { 291 {
288 this->window = window; 292 this->window = window;
289 display->reg (this); 293 display->reg (this);
299 303
300///////////////////////////////////////////////////////////////////////////// 304/////////////////////////////////////////////////////////////////////////////
301 305
302typedef unsigned long Pixel; 306typedef unsigned long Pixel;
303 307
304struct rgba { 308struct rgba
309{
305 unsigned short r, g, b, a; 310 unsigned short r, g, b, a;
306 311
307 enum { MIN_CC = 0x0000, MAX_CC = 0xffff }; 312 enum { MIN_CC = 0x0000, MAX_CC = 0xffff };
308 313
309 rgba () 314 rgba ()
312 rgba (unsigned short r, unsigned short g, unsigned short b, unsigned short a = MAX_CC) 317 rgba (unsigned short r, unsigned short g, unsigned short b, unsigned short a = MAX_CC)
313 : r(r), g(g), b(b), a(a) 318 : r(r), g(g), b(b), a(a)
314 { } 319 { }
315}; 320};
316 321
317struct rxvt_color { 322struct rxvt_color
323{
318#if XFT 324#if XFT
319 XftColor c; 325 XftColor c;
320#else 326#else
321 XColor c; 327 XColor c;
322#endif 328#endif
336 bool set (rxvt_screen *screen, const rgba &color); 342 bool set (rxvt_screen *screen, const rgba &color);
337 343
338 void fade (rxvt_screen *screen, int percent, rxvt_color &result, const rgba &to = rgba (0, 0, 0)); 344 void fade (rxvt_screen *screen, int percent, rxvt_color &result, const rgba &to = rgba (0, 0, 0));
339}; 345};
340 346
341#endif 347#if TRACE_PIXMAPS
348Pixmap trace_XCreatePixmap (const char *file, int line, Display *dpy, Window r, unsigned int w, unsigned int h, unsigned int d);
349void trace_XFreePixmap (const char *file, int line, Display *dpy, Pixmap p);
342 350
351# define XCreatePixmap(dpy,r,w,h,d) trace_XCreatePixmap (__FILE__,__LINE__,dpy,r,w,h,d)
352# define XFreePixmap(dpy,p) trace_XFreePixmap (__FILE__,__LINE__,dpy,p)
353#endif
354
355#endif
356

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines