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.33 by ayin, Wed Oct 31 09:55:24 2007 UTC vs.
Revision 1.34 by root, Sun Nov 11 04:08:00 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> 261 template<class O, class M>
241 im_watcher (O object, M method) 262 im_watcher (O object, M method)
242 : callback<void (void)> (object, method) 263 : callback<void (void)> (object, method)
243 { } 264 { }
244 265
245 void start (rxvt_display *display) 266 void start (rxvt_display *display)
246 { 267 {
247 display->reg (this); 268 display->reg (this);
248 } 269 }
270
249 void stop (rxvt_display *display) 271 void stop (rxvt_display *display)
250 { 272 {
251 display->unreg (this); 273 display->unreg (this);
252 } 274 }
253}; 275};
254#endif 276#endif
255 277
256struct xevent_watcher : watcher, callback<void (XEvent &)> { 278struct xevent_watcher : rxvt_watcher, callback<void (XEvent &)> {
257 Window window; 279 Window window;
258 280
259 template<class O, class M> 281 template<class O, class M>
260 xevent_watcher (O object, M method) 282 xevent_watcher (O object, M method)
261 : callback<void (XEvent &)> (object, method) 283 : callback<void (XEvent &)> (object, method)
264 void start (rxvt_display *display, Window window) 286 void start (rxvt_display *display, Window window)
265 { 287 {
266 this->window = window; 288 this->window = window;
267 display->reg (this); 289 display->reg (this);
268 } 290 }
291
269 void stop (rxvt_display *display) 292 void stop (rxvt_display *display)
270 { 293 {
271 display->unreg (this); 294 display->unreg (this);
272 } 295 }
273}; 296};

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines