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.38 by root, Fri Dec 14 05:25:26 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"
65#endif 65#endif
66#if USE_XIM 66#if USE_XIM
67 XA_WM_LOCALE_NAME, 67 XA_WM_LOCALE_NAME,
68 XA_XIM_SERVERS, 68 XA_XIM_SERVERS,
69#endif 69#endif
70#if TRANSPARENT 70#if ENABLE_TRANSPARENCY
71 XA_XROOTPMAP_ID, 71 XA_XROOTPMAP_ID,
72 XA_ESETROOT_PMAP_ID, 72 XA_ESETROOT_PMAP_ID,
73#endif 73#endif
74#if ENABLE_XEMBED 74#if ENABLE_XEMBED
75 XA_XEMBED, 75 XA_XEMBED,
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{
108 void erase_unordered (unsigned int pos)
109 {
110 watcher *w = (*this)[this->size () - 1];
111 this->pop_back ();
112
113 if (!this->empty ())
114 if (((*this)[pos] = w)) // '=' is correct!
115 w->active = pos + 1;
116 }
117};
118
119struct rxvt_watcher
120{
121 int active; /* 0 == inactive, else index into respective vector */
122
123 bool is_active () { return active; }
124
125 rxvt_watcher () : active (0) { }
126};
127
105struct refcounted { 128struct refcounted
129{
106 int referenced; 130 int referenced;
107 char *id; 131 char *id;
108 132
109 refcounted (const char *id); 133 refcounted (const char *id);
110 bool ref_init () { return false; } 134 bool ref_init () { return false; }
111 void ref_next () { } 135 void ref_next () { }
112 ~refcounted (); 136 ~refcounted ();
113}; 137};
114 138
115template<class T> 139template<class T>
116struct refcache : vector<T *> { 140struct refcache : vector<T *>
141{
117 T *get (const char *id); 142 T *get (const char *id);
118 void put (T *obj); 143 void put (T *obj);
119 void clear (); 144 void clear ();
120 145
121 ~refcache () 146 ~refcache ()
126 151
127///////////////////////////////////////////////////////////////////////////// 152/////////////////////////////////////////////////////////////////////////////
128 153
129struct rxvt_screen; 154struct rxvt_screen;
130 155
131struct rxvt_drawable { 156struct rxvt_drawable
157{
132 rxvt_screen *screen; 158 rxvt_screen *screen;
133 Drawable drawable; 159 Drawable drawable;
134 operator Drawable() { return drawable; } 160 operator Drawable() { return drawable; }
135 161
136#if XFT 162#if XFT
152}; 178};
153 179
154///////////////////////////////////////////////////////////////////////////// 180/////////////////////////////////////////////////////////////////////////////
155 181
156#ifdef USE_XIM 182#ifdef USE_XIM
157struct rxvt_xim : refcounted { 183struct rxvt_xim : refcounted
184{
158 void destroy (); 185 void destroy ();
159 rxvt_display *display; 186 rxvt_display *display;
160 187
161//public 188//public
162 XIM xim; 189 XIM xim;
165 bool ref_init (); 192 bool ref_init ();
166 ~rxvt_xim (); 193 ~rxvt_xim ();
167}; 194};
168#endif 195#endif
169 196
170struct rxvt_screen { 197struct rxvt_screen
198{
171 rxvt_display *display; 199 rxvt_display *display;
172 Display *dpy; 200 Display *dpy;
173 int depth; 201 int depth;
174 Visual *visual; 202 Visual *visual;
175 Colormap cmap; 203 Colormap cmap;
183 211
184 rxvt_screen (); 212 rxvt_screen ();
185#endif 213#endif
186 214
187 void set (rxvt_display *disp); 215 void set (rxvt_display *disp);
188 void set (rxvt_display *disp, int bitdepth); 216 void select_visual (int bitdepth);
189 void clear (); 217 void clear ();
190}; 218};
191 219
192struct rxvt_display : refcounted { 220struct rxvt_display : refcounted
221{
193 io_manager_vec<xevent_watcher> xw; 222 event_vec<xevent_watcher> xw;
194 223
195 io_watcher x_ev; void x_cb (io_watcher &w, short revents); 224 ev::prepare flush_ev; void flush_cb (ev::prepare &w, int revents);
225 ev::io x_ev ; void x_cb (ev::io &w, int revents);
196 226
197#ifdef USE_XIM 227#ifdef USE_XIM
198 refcache<rxvt_xim> xims; 228 refcache<rxvt_xim> xims;
199 vector<im_watcher *> imw; 229 vector<im_watcher *> imw;
200 230
234 void put_xim (rxvt_xim *xim); 264 void put_xim (rxvt_xim *xim);
235#endif 265#endif
236}; 266};
237 267
238#ifdef USE_XIM 268#ifdef USE_XIM
239struct im_watcher : watcher, callback0<void> { 269struct 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) 270 void start (rxvt_display *display)
246 { 271 {
247 display->reg (this); 272 display->reg (this);
248 } 273 }
274
249 void stop (rxvt_display *display) 275 void stop (rxvt_display *display)
250 { 276 {
251 display->unreg (this); 277 display->unreg (this);
252 } 278 }
253}; 279};
254#endif 280#endif
255 281
256struct xevent_watcher : watcher, callback1<void, XEvent &> { 282struct xevent_watcher : rxvt_watcher, callback<void (XEvent &)>
283{
257 Window window; 284 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 285
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};
276 299
277///////////////////////////////////////////////////////////////////////////// 300/////////////////////////////////////////////////////////////////////////////
278 301
279typedef unsigned long Pixel; 302typedef unsigned long Pixel;
280 303
281struct rgba { 304struct rgba
305{
282 unsigned short r, g, b, a; 306 unsigned short r, g, b, a;
283 307
284 enum { MIN_CC = 0x0000, MAX_CC = 0xffff }; 308 enum { MIN_CC = 0x0000, MAX_CC = 0xffff };
285 309
286 rgba () 310 rgba ()
289 rgba (unsigned short r, unsigned short g, unsigned short b, unsigned short a = MAX_CC) 313 rgba (unsigned short r, unsigned short g, unsigned short b, unsigned short a = MAX_CC)
290 : r(r), g(g), b(b), a(a) 314 : r(r), g(g), b(b), a(a)
291 { } 315 { }
292}; 316};
293 317
294struct rxvt_color { 318struct rxvt_color
319{
295#if XFT 320#if XFT
296 XftColor c; 321 XftColor c;
297#else 322#else
298 XColor c; 323 XColor c;
299#endif 324#endif
306 bool alloc (rxvt_screen *screen, const rgba &color); 331 bool alloc (rxvt_screen *screen, const rgba &color);
307 void free (rxvt_screen *screen); 332 void free (rxvt_screen *screen);
308 333
309 void get (rgba &color); 334 void get (rgba &color);
310 void get (XColor &color); 335 void get (XColor &color);
311 336
312 bool set (rxvt_screen *screen, const char *name); 337 bool set (rxvt_screen *screen, const char *name);
313 bool set (rxvt_screen *screen, const rgba &color); 338 bool set (rxvt_screen *screen, const rgba &color);
314 339
315 void fade (rxvt_screen *screen, int percent, rxvt_color &result, const rgba &to = rgba (0, 0, 0)); 340 void fade (rxvt_screen *screen, int percent, rxvt_color &result, const rgba &to = rgba (0, 0, 0));
316}; 341};
317 342
318#endif 343#if TRACE_PIXMAPS
344Pixmap trace_XCreatePixmap (const char *file, int line, Display *dpy, Window r, unsigned int w, unsigned int h, unsigned int d);
345void trace_XFreePixmap (const char *file, int line, Display *dpy, Pixmap p);
319 346
347# define XCreatePixmap(dpy,r,w,h,d) trace_XCreatePixmap (__FILE__,__LINE__,dpy,r,w,h,d)
348# define XFreePixmap(dpy,p) trace_XFreePixmap (__FILE__,__LINE__,dpy,p)
349#endif
350
351#endif
352

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines