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.27 by root, Mon Feb 20 22:42:01 2006 UTC vs.
Revision 1.40 by ayin, Wed Dec 26 14:22:30 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"
35#include "rxvtutil.h" 34#include "rxvtutil.h"
36 35
37#include "callback.h" 36#include "callback.h"
38 37
39// see rxvttoolkit.C:xa_names, which must be kept in sync 38// see rxvttoolkit.C:xa_names, which must be kept in sync
65#endif 64#endif
66#if USE_XIM 65#if USE_XIM
67 XA_WM_LOCALE_NAME, 66 XA_WM_LOCALE_NAME,
68 XA_XIM_SERVERS, 67 XA_XIM_SERVERS,
69#endif 68#endif
70#if TRANSPARENT 69#if ENABLE_TRANSPARENCY
71 XA_XROOTPMAP_ID, 70 XA_XROOTPMAP_ID,
72 XA_ESETROOT_PMAP_ID, 71 XA_ESETROOT_PMAP_ID,
73#endif 72#endif
74#if ENABLE_XEMBED 73#if ENABLE_XEMBED
75 XA_XEMBED, 74 XA_XEMBED,
100struct rxvt_display; 99struct rxvt_display;
101 100
102struct im_watcher; 101struct im_watcher;
103struct xevent_watcher; 102struct xevent_watcher;
104 103
104template<class watcher>
105struct event_vec : vector<watcher *>
106{
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{
120 int active; /* 0 == inactive, else index into respective vector */
121
122 bool is_active () { return active; }
123
124 rxvt_watcher () : active (0) { }
125};
126
105struct refcounted { 127struct refcounted
128{
106 int referenced; 129 int referenced;
107 char *id; 130 char *id;
108 131
109 refcounted (const char *id); 132 refcounted (const char *id);
110 bool ref_init () { return false; } 133 bool ref_init () { return false; }
111 void ref_next () { } 134 void ref_next () { }
112 ~refcounted (); 135 ~refcounted ();
113}; 136};
114 137
115template<class T> 138template<class T>
116struct refcache : vector<T *> { 139struct refcache : vector<T *>
140{
117 T *get (const char *id); 141 T *get (const char *id);
118 void put (T *obj); 142 void put (T *obj);
119 void clear (); 143 void clear ();
120 144
121 ~refcache () 145 ~refcache ()
126 150
127///////////////////////////////////////////////////////////////////////////// 151/////////////////////////////////////////////////////////////////////////////
128 152
129struct rxvt_screen; 153struct rxvt_screen;
130 154
131struct rxvt_drawable { 155struct rxvt_drawable
156{
132 rxvt_screen *screen; 157 rxvt_screen *screen;
133 Drawable drawable; 158 Drawable drawable;
134 operator Drawable() { return drawable; } 159 operator Drawable() { return drawable; }
135 160
136#if XFT 161#if XFT
152}; 177};
153 178
154///////////////////////////////////////////////////////////////////////////// 179/////////////////////////////////////////////////////////////////////////////
155 180
156#ifdef USE_XIM 181#ifdef USE_XIM
157struct rxvt_xim : refcounted { 182struct rxvt_xim : refcounted
183{
158 void destroy (); 184 void destroy ();
159 rxvt_display *display; 185 rxvt_display *display;
160 186
161//public 187//public
162 XIM xim; 188 XIM xim;
165 bool ref_init (); 191 bool ref_init ();
166 ~rxvt_xim (); 192 ~rxvt_xim ();
167}; 193};
168#endif 194#endif
169 195
170struct rxvt_screen { 196struct rxvt_screen
197{
171 rxvt_display *display; 198 rxvt_display *display;
172 Display *dpy; 199 Display *dpy;
173 int depth; 200 int depth;
174 Visual *visual; 201 Visual *visual;
175 Colormap cmap; 202 Colormap cmap;
183 210
184 rxvt_screen (); 211 rxvt_screen ();
185#endif 212#endif
186 213
187 void set (rxvt_display *disp); 214 void set (rxvt_display *disp);
188 void set (rxvt_display *disp, int bitdepth); 215 void select_visual (int bitdepth);
189 void clear (); 216 void clear ();
190}; 217};
191 218
192struct rxvt_display : refcounted { 219struct rxvt_display : refcounted
220{
193 io_manager_vec<xevent_watcher> xw; 221 event_vec<xevent_watcher> xw;
194 222
195 io_watcher x_ev; void x_cb (io_watcher &w, short revents); 223 ev::prepare flush_ev; void flush_cb (ev::prepare &w, int revents);
224 ev::io x_ev ; void x_cb (ev::io &w, int revents);
196 225
197#ifdef USE_XIM 226#ifdef USE_XIM
198 refcache<rxvt_xim> xims; 227 refcache<rxvt_xim> xims;
199 vector<im_watcher *> imw; 228 vector<im_watcher *> imw;
200 229
217 XrmDatabase get_resources (bool refresh); 246 XrmDatabase get_resources (bool refresh);
218 bool ref_init (); 247 bool ref_init ();
219 void ref_next (); 248 void ref_next ();
220 ~rxvt_display (); 249 ~rxvt_display ();
221 250
222 void flush (); 251 void flush ()
252 {
253 flush_ev.start ();
254 }
255
223 Atom atom (const char *name); 256 Atom atom (const char *name);
224 void set_selection_owner (rxvt_term *owner); 257 void set_selection_owner (rxvt_term *owner);
225 258
226 void reg (xevent_watcher *w); 259 void reg (xevent_watcher *w);
227 void unreg (xevent_watcher *w); 260 void unreg (xevent_watcher *w);
234 void put_xim (rxvt_xim *xim); 267 void put_xim (rxvt_xim *xim);
235#endif 268#endif
236}; 269};
237 270
238#ifdef USE_XIM 271#ifdef USE_XIM
239struct im_watcher : watcher, callback0<void> { 272struct im_watcher : rxvt_watcher, callback<void (void)> {
240 template<class O1, class O2>
241 im_watcher (O1 *object, void (O2::*method) ())
242 : callback0<void> (object,method)
243 { }
244
245 void start (rxvt_display *display) 273 void start (rxvt_display *display)
246 { 274 {
247 display->reg (this); 275 display->reg (this);
248 } 276 }
277
249 void stop (rxvt_display *display) 278 void stop (rxvt_display *display)
250 { 279 {
251 display->unreg (this); 280 display->unreg (this);
252 } 281 }
253}; 282};
254#endif 283#endif
255 284
256struct xevent_watcher : watcher, callback1<void, XEvent &> { 285struct xevent_watcher : rxvt_watcher, callback<void (XEvent &)>
286{
257 Window window; 287 Window window;
258
259 template<class O1, class O2>
260 xevent_watcher (O1 *object, void (O2::*method) (XEvent &))
261 : callback1<void, XEvent &> (object,method)
262 { }
263 288
264 void start (rxvt_display *display, Window window) 289 void start (rxvt_display *display, Window window)
265 { 290 {
266 this->window = window; 291 this->window = window;
267 display->reg (this); 292 display->reg (this);
268 } 293 }
294
269 void stop (rxvt_display *display) 295 void stop (rxvt_display *display)
270 { 296 {
271 display->unreg (this); 297 display->unreg (this);
272 } 298 }
273}; 299};
276 302
277///////////////////////////////////////////////////////////////////////////// 303/////////////////////////////////////////////////////////////////////////////
278 304
279typedef unsigned long Pixel; 305typedef unsigned long Pixel;
280 306
281struct rgba { 307struct rgba
308{
282 unsigned short r, g, b, a; 309 unsigned short r, g, b, a;
283 310
284 enum { MIN_CC = 0x0000, MAX_CC = 0xffff }; 311 enum { MIN_CC = 0x0000, MAX_CC = 0xffff };
285 312
286 rgba () 313 rgba ()
289 rgba (unsigned short r, unsigned short g, unsigned short b, unsigned short a = MAX_CC) 316 rgba (unsigned short r, unsigned short g, unsigned short b, unsigned short a = MAX_CC)
290 : r(r), g(g), b(b), a(a) 317 : r(r), g(g), b(b), a(a)
291 { } 318 { }
292}; 319};
293 320
294struct rxvt_color { 321struct rxvt_color
322{
295#if XFT 323#if XFT
296 XftColor c; 324 XftColor c;
297#else 325#else
298 XColor c; 326 XColor c;
299#endif 327#endif
306 bool alloc (rxvt_screen *screen, const rgba &color); 334 bool alloc (rxvt_screen *screen, const rgba &color);
307 void free (rxvt_screen *screen); 335 void free (rxvt_screen *screen);
308 336
309 void get (rgba &color); 337 void get (rgba &color);
310 void get (XColor &color); 338 void get (XColor &color);
311 339
312 bool set (rxvt_screen *screen, const char *name); 340 bool set (rxvt_screen *screen, const char *name);
313 bool set (rxvt_screen *screen, const rgba &color); 341 bool set (rxvt_screen *screen, const rgba &color);
314 342
315 void fade (rxvt_screen *screen, int percent, rxvt_color &result, const rgba &to = rgba (0, 0, 0)); 343 void fade (rxvt_screen *screen, int percent, rxvt_color &result, const rgba &to = rgba (0, 0, 0));
316}; 344};
317 345
318#endif 346#if TRACE_PIXMAPS
347Pixmap trace_XCreatePixmap (const char *file, int line, Display *dpy, Window r, unsigned int w, unsigned int h, unsigned int d);
348void trace_XFreePixmap (const char *file, int line, Display *dpy, Pixmap p);
319 349
350# define XCreatePixmap(dpy,r,w,h,d) trace_XCreatePixmap (__FILE__,__LINE__,dpy,r,w,h,d)
351# define XFreePixmap(dpy,p) trace_XFreePixmap (__FILE__,__LINE__,dpy,p)
352#endif
353
354#endif
355

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines