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.2 by root, Wed Aug 25 02:33:09 2004 UTC vs.
Revision 1.24 by root, Sat Feb 18 14:14:43 2006 UTC

15#include "rxvtlib.h" 15#include "rxvtlib.h"
16#include "rxvtutil.h" 16#include "rxvtutil.h"
17 17
18#include "callback.h" 18#include "callback.h"
19 19
20// see rxvttoolkit.C:xa_names, which must be kept in sync
21enum {
22 XA_TEXT,
23 XA_COMPOUND_TEXT,
24 XA_UTF8_STRING,
25 XA_MULTIPLE,
26 XA_TARGETS,
27 XA_TIMESTAMP,
28 XA_VT_SELECTION,
29 XA_INCR,
30 XA_WM_PROTOCOLS,
31 XA_WM_DELETE_WINDOW,
32 XA_CLIPBOARD,
33 XA_AVERAGE_WIDTH,
34 XA_WEIGHT_NAME,
35 XA_SLANT,
36 XA_CHARSET_REGISTRY,
37 XA_CHARSET_ENCODING,
38#if ENABLE_FRILLS
39 XA_MOTIF_WM_HINTS,
40#endif
41#if ENABLE_EWMH
42 XA_NET_WM_PID,
43 XA_NET_WM_NAME,
44 XA_NET_WM_ICON_NAME,
45 XA_NET_WM_PING,
46#endif
47#if USE_XIM
48 XA_WM_LOCALE_NAME,
49 XA_XIM_SERVERS,
50#endif
51#if TRANSPARENT
52 XA_XROOTPMAP_ID,
53 XA_ESETROOT_PMAP_ID,
54#endif
55#if ENABLE_XEMBED
56 XA_XEMBED,
57 XA_XEMBED_INFO,
58#endif
59#if !ENABLE_MINIMAL
60 // these are usually allocated by other subsystens, but we do it
61 // here to avoid a server roundtrip.
62 XA_SCREEN_RESOURCES,
63 XA_XDCCC_LINEAR_RGB_CORRECTION,
64 XA_XDCCC_LINEAR_RGB_MATRICES,
65 XA_WM_COLORMAP_WINDOWS,
66 XA_WM_STATE,
67 XA_cursor,
68# if USE_XIM
69 // various selection targets used by XIM
70 XA_TRANSPORT,
71 XA_LOCALES,
72 XA__XIM_PROTOCOL,
73 XA__XIM_XCONNECT,
74 XA__XIM_MOREDATA,
75# endif
76#endif
77 NUM_XA
78};
79
20struct rxvt_term; 80struct rxvt_term;
21struct rxvt_display; 81struct rxvt_display;
22 82
23struct im_watcher; 83struct im_watcher;
24struct xevent_watcher; 84struct xevent_watcher;
26struct refcounted { 86struct refcounted {
27 int referenced; 87 int referenced;
28 char *id; 88 char *id;
29 89
30 refcounted (const char *id); 90 refcounted (const char *id);
31 bool init () { return false; } 91 bool ref_init () { return false; }
92 void ref_next () { }
32 ~refcounted (); 93 ~refcounted ();
33}; 94};
34 95
35template<class T> 96template<class T>
36struct refcache : vector<T *> { 97struct refcache : vector<T *> {
37 T *get (const char *id); 98 T *get (const char *id);
38 void put (T *obj); 99 void put (T *obj);
100 void clear ();
101
39 ~refcache (); 102 ~refcache ()
103 {
104 clear ();
105 }
106};
107
108/////////////////////////////////////////////////////////////////////////////
109
110struct rxvt_screen;
111
112struct rxvt_drawable {
113 rxvt_screen *screen;
114 Drawable drawable;
115 operator Drawable() { return drawable; }
116
117#if XFT
118 XftDraw *xftdrawable;
119 operator XftDraw *();
120#endif
121
122 rxvt_drawable (rxvt_screen *screen, Drawable drawable)
123 : screen(screen),
124#if XFT
125 xftdrawable(0),
126#endif
127 drawable(drawable)
128 { }
129
130#if XFT
131 ~rxvt_drawable ();
132#endif
40}; 133};
41 134
42///////////////////////////////////////////////////////////////////////////// 135/////////////////////////////////////////////////////////////////////////////
43 136
44#ifdef USE_XIM 137#ifdef USE_XIM
48 141
49//public 142//public
50 XIM xim; 143 XIM xim;
51 144
52 rxvt_xim (const char *id) : refcounted (id) { } 145 rxvt_xim (const char *id) : refcounted (id) { }
53 bool init (); 146 bool ref_init ();
54 ~rxvt_xim (); 147 ~rxvt_xim ();
55}; 148};
56#endif 149#endif
57 150
151struct rxvt_screen {
152 rxvt_display *display;
153 Display *dpy;
154 int depth;
155 Visual *visual;
156 Colormap cmap;
157
158#if XFT
159 // scratch pixmap
160 rxvt_drawable *scratch_area;
161 int scratch_w, scratch_h;
162
163 rxvt_drawable &scratch_drawable (int w, int h);
164
165 rxvt_screen ();
166#endif
167
168 void set (rxvt_display *disp);
169 void set (rxvt_display *disp, int bitdepth);
170 void clear ();
171};
172
58struct rxvt_display : refcounted { 173struct rxvt_display : refcounted {
59 Atom xa_xim_servers;
60
61 io_manager_vec<xevent_watcher> xw; 174 io_manager_vec<xevent_watcher> xw;
62 175
63 io_watcher x_ev; void x_cb (io_watcher &w, short revents); 176 io_watcher x_ev; void x_cb (io_watcher &w, short revents);
64 177
65#ifdef USE_XIM 178#ifdef USE_XIM
66 refcache<rxvt_xim> xims; 179 refcache<rxvt_xim> xims;
67 vector<im_watcher *> imw; 180 vector<im_watcher *> imw;
68 181
69 void im_change_cb (); 182 void im_change_cb ();
183 void im_change_check ();
70#endif 184#endif
71 185
72//public 186//public
73 Display *display; 187 Display *dpy;
74 int depth;
75 int screen; 188 int screen;
76 Visual *visual;
77 Colormap cmap;
78 Window root; 189 Window root;
79 rxvt_term *selection_owner; 190 rxvt_term *selection_owner;
191 Atom xa[NUM_XA];
80#ifndef NO_SLOW_LINK_SUPPORT 192#ifndef NO_SLOW_LINK_SUPPORT
81 bool is_local; 193 bool is_local;
194#endif
195#ifdef POINTER_BLANK
196 Cursor blank_cursor;
82#endif 197#endif
83 198
84 rxvt_display (const char *id); 199 rxvt_display (const char *id);
200 XrmDatabase get_resources (bool refresh);
85 bool init (); 201 bool ref_init ();
202 void ref_next ();
86 ~rxvt_display (); 203 ~rxvt_display ();
87 204
88 void flush (); 205 void flush ();
89 206 Atom atom (const char *name);
90 void set_selection_owner (rxvt_term *owner); 207 void set_selection_owner (rxvt_term *owner);
91 208
92 void reg (xevent_watcher *w); 209 void reg (xevent_watcher *w);
93 void unreg (xevent_watcher *w); 210 void unreg (xevent_watcher *w);
94 211
97 void unreg (im_watcher *w); 214 void unreg (im_watcher *w);
98 215
99 rxvt_xim *get_xim (const char *locale, const char *modifiers); 216 rxvt_xim *get_xim (const char *locale, const char *modifiers);
100 void put_xim (rxvt_xim *xim); 217 void put_xim (rxvt_xim *xim);
101#endif 218#endif
102
103 Atom atom (const char *name);
104}; 219};
105 220
106#ifdef USE_XIM 221#ifdef USE_XIM
107struct im_watcher : watcher, callback0<void> { 222struct im_watcher : watcher, callback0<void> {
108 template<class O1, class O2> 223 template<class O1, class O2>
144 259
145///////////////////////////////////////////////////////////////////////////// 260/////////////////////////////////////////////////////////////////////////////
146 261
147typedef unsigned long Pixel; 262typedef unsigned long Pixel;
148 263
264struct rgba {
265 unsigned short r, g, b, a;
266
267 enum { MIN_CC = 0x0000, MAX_CC = 0xffff };
268
269 rgba ()
270 { }
271
272 rgba (unsigned short r, unsigned short g, unsigned short b, unsigned short a = MAX_CC)
273 : r(r), g(g), b(b), a(a)
274 { }
275};
276
149struct rxvt_color { 277struct rxvt_color {
150#if XFT 278#if XFT
151 XftColor c; 279 XftColor c;
280#else
281 XColor c;
282#endif
283
152 operator Pixel () const { return c.pixel; } 284 operator Pixel () const { return c.pixel; }
153#else
154 Pixel p;
155 operator Pixel () const { return p; }
156#endif
157 285
158 bool operator == (const rxvt_color &b) const { return Pixel (*this) == Pixel (b); } 286 bool operator == (const rxvt_color &b) const { return Pixel (*this) == Pixel (b); }
159 bool operator != (const rxvt_color &b) const { return Pixel (*this) != Pixel (b); } 287 bool operator != (const rxvt_color &b) const { return Pixel (*this) != Pixel (b); }
160 288
161 void get (rxvt_display *display, unsigned short &cr, unsigned short &cg, unsigned short &cb); 289 bool alloc (rxvt_screen *screen, const rgba &color);
290 void free (rxvt_screen *screen);
291
292 void get (rgba &color);
293 void get (XColor &color);
162 294
163 bool set (rxvt_display *display, Pixel p);
164 bool set (rxvt_display *display, const char *name); 295 bool set (rxvt_screen *screen, const char *name);
165 bool set (rxvt_display *display, unsigned short cr, unsigned short cg, unsigned short cb); 296 bool set (rxvt_screen *screen, const rgba &color);
166 297
167 rxvt_color fade (rxvt_display *, int percent); 298 void fade (rxvt_screen *screen, int percent, rxvt_color &result, const rgba &to = rgba (0, 0, 0));
168
169 void free (rxvt_display *display);
170}; 299};
171 300
172#endif 301#endif
173 302

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines