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.32 by sasha, Thu Jul 12 22:33:16 2007 UTC vs.
Revision 1.36 by root, Tue Dec 4 14:50:44 2007 UTC

27 27
28#if XFT 28#if XFT
29# include <X11/Xft/Xft.h> 29# include <X11/Xft/Xft.h>
30#endif 30#endif
31 31
32#include "iom.h" 32#include "ev_cpp.h"
33 33
34#include "rxvtlib.h" 34#include "rxvtlib.h"
35#include "rxvtutil.h" 35#include "rxvtutil.h"
36 36
37#include "callback.h" 37#include "callback.h"
100struct rxvt_display; 100struct rxvt_display;
101 101
102struct im_watcher; 102struct im_watcher;
103struct xevent_watcher; 103struct xevent_watcher;
104 104
105template<class watcher>
106struct event_vec : vector<watcher *> {
107 void erase_unordered (unsigned int pos)
108 {
109 watcher *w = (*this)[this->size () - 1];
110 this->pop_back ();
111
112 if (!this->empty ())
113 if (((*this)[pos] = w)) // '=' is correct!
114 w->active = pos + 1;
115 }
116};
117
118struct rxvt_watcher {
119 int active; /* 0 == inactive, else index into respective vector */
120
121 bool is_active () { return active; }
122
123 rxvt_watcher () : active (0) { }
124};
125
105struct refcounted { 126struct refcounted {
106 int referenced; 127 int referenced;
107 char *id; 128 char *id;
108 129
109 refcounted (const char *id); 130 refcounted (const char *id);
188 void select_visual (int bitdepth); 209 void select_visual (int bitdepth);
189 void clear (); 210 void clear ();
190}; 211};
191 212
192struct rxvt_display : refcounted { 213struct rxvt_display : refcounted {
193 io_manager_vec<xevent_watcher> xw; 214 event_vec<xevent_watcher> xw;
194 215
195 io_watcher x_ev; void x_cb (io_watcher &w, short revents); 216 ev::io x_ev; void x_cb (ev::io &w, int revents);
196 217
197#ifdef USE_XIM 218#ifdef USE_XIM
198 refcache<rxvt_xim> xims; 219 refcache<rxvt_xim> xims;
199 vector<im_watcher *> imw; 220 vector<im_watcher *> imw;
200 221
234 void put_xim (rxvt_xim *xim); 255 void put_xim (rxvt_xim *xim);
235#endif 256#endif
236}; 257};
237 258
238#ifdef USE_XIM 259#ifdef USE_XIM
239struct im_watcher : watcher, callback<void (void)> { 260struct im_watcher : rxvt_watcher, callback<void (void)> {
240 template<class O, class M>
241 im_watcher (O object, M method)
242 : callback<void (void)> (object, method)
243 { }
244
245 void start (rxvt_display *display) 261 void start (rxvt_display *display)
246 { 262 {
247 display->reg (this); 263 display->reg (this);
248 } 264 }
265
249 void stop (rxvt_display *display) 266 void stop (rxvt_display *display)
250 { 267 {
251 display->unreg (this); 268 display->unreg (this);
252 } 269 }
253}; 270};
254#endif 271#endif
255 272
256struct xevent_watcher : watcher, callback<void (XEvent &)> { 273struct xevent_watcher : rxvt_watcher, callback<void (XEvent &)> {
257 Window window; 274 Window window;
258
259 template<class O, class M>
260 xevent_watcher (O object, M method)
261 : callback<void (XEvent &)> (object, method)
262 { }
263 275
264 void start (rxvt_display *display, Window window) 276 void start (rxvt_display *display, Window window)
265 { 277 {
266 this->window = window; 278 this->window = window;
267 display->reg (this); 279 display->reg (this);
268 } 280 }
281
269 void stop (rxvt_display *display) 282 void stop (rxvt_display *display)
270 { 283 {
271 display->unreg (this); 284 display->unreg (this);
272 } 285 }
273}; 286};
306 bool alloc (rxvt_screen *screen, const rgba &color); 319 bool alloc (rxvt_screen *screen, const rgba &color);
307 void free (rxvt_screen *screen); 320 void free (rxvt_screen *screen);
308 321
309 void get (rgba &color); 322 void get (rgba &color);
310 void get (XColor &color); 323 void get (XColor &color);
311 324
312 bool set (rxvt_screen *screen, const char *name); 325 bool set (rxvt_screen *screen, const char *name);
313 bool set (rxvt_screen *screen, const rgba &color); 326 bool set (rxvt_screen *screen, const rgba &color);
314 327
315 void fade (rxvt_screen *screen, int percent, rxvt_color &result, const rgba &to = rgba (0, 0, 0)); 328 void fade (rxvt_screen *screen, int percent, rxvt_color &result, const rgba &to = rgba (0, 0, 0));
316}; 329};
317 330
318#endif 331#if TRACE_PIXMAPS
332Pixmap trace_XCreatePixmap (const char *file, int line, Display *dpy, Window r, unsigned int w, unsigned int h, unsigned int d);
333void trace_XFreePixmap (const char *file, int line, Display *dpy, Pixmap p);
319 334
335# define XCreatePixmap(dpy,r,w,h,d) trace_XCreatePixmap (__FILE__,__LINE__,dpy,r,w,h,d)
336# define XFreePixmap(dpy,p) trace_XFreePixmap (__FILE__,__LINE__,dpy,p)
337#endif
338
339#endif
340

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines