ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvttoolkit.h
Revision: 1.10
Committed: Fri Jan 13 04:59:04 2006 UTC (18 years, 4 months ago) by root
Content type: text/plain
Branch: MAIN
CVS Tags: rel-7_2, rel-7_1, rel-7_0
Changes since 1.9: +0 -2 lines
Log Message:
*** empty log message ***

File Contents

# Content
1 /*
2 * rxvttoolkit.h - provide toolkit-functionality for rxvt.
3 */
4 #ifndef RXVT_TOOLKIT_H
5 #define RXVT_TOOLKIT_H
6
7 #include <X11/Xlib.h>
8
9 #if XFT
10 # include <X11/Xft/Xft.h>
11 #endif
12
13 #include "iom.h"
14
15 #include "rxvtlib.h"
16 #include "rxvtutil.h"
17
18 #include "callback.h"
19
20 struct rxvt_term;
21 struct rxvt_display;
22
23 struct im_watcher;
24 struct xevent_watcher;
25
26 struct refcounted {
27 int referenced;
28 char *id;
29
30 refcounted (const char *id);
31 bool ref_init () { return false; }
32 void ref_next () { }
33 ~refcounted ();
34 };
35
36 template<class T>
37 struct refcache : vector<T *> {
38 T *get (const char *id);
39 void put (T *obj);
40 void clear ();
41
42 ~refcache ()
43 {
44 clear ();
45 }
46 };
47
48 /////////////////////////////////////////////////////////////////////////////
49
50 #ifdef USE_XIM
51 struct rxvt_xim : refcounted {
52 void destroy ();
53 rxvt_display *display;
54
55 //public
56 XIM xim;
57
58 rxvt_xim (const char *id) : refcounted (id) { }
59 bool ref_init ();
60 ~rxvt_xim ();
61 };
62 #endif
63
64 struct rxvt_display : refcounted {
65 Atom xa_xim_servers;
66
67 io_manager_vec<xevent_watcher> xw;
68
69 io_watcher x_ev; void x_cb (io_watcher &w, short revents);
70
71 #ifdef USE_XIM
72 refcache<rxvt_xim> xims;
73 vector<im_watcher *> imw;
74
75 void im_change_cb ();
76 void im_change_check ();
77 #endif
78
79 //public
80 Display *display;
81 int depth;
82 int screen;
83 Visual *visual;
84 Colormap cmap;
85 Window root;
86 rxvt_term *selection_owner;
87 #ifndef NO_SLOW_LINK_SUPPORT
88 bool is_local;
89 #endif
90 #ifdef POINTER_BLANK
91 Cursor blank_cursor;
92 #endif
93
94 rxvt_display (const char *id);
95 XrmDatabase get_resources ();
96 bool ref_init ();
97 void ref_next ();
98 ~rxvt_display ();
99
100 void flush ();
101 Atom atom (const char *name);
102 void set_selection_owner (rxvt_term *owner);
103
104 void reg (xevent_watcher *w);
105 void unreg (xevent_watcher *w);
106
107 #ifdef USE_XIM
108 void reg (im_watcher *w);
109 void unreg (im_watcher *w);
110
111 rxvt_xim *get_xim (const char *locale, const char *modifiers);
112 void put_xim (rxvt_xim *xim);
113 #endif
114 };
115
116 #ifdef USE_XIM
117 struct im_watcher : watcher, callback0<void> {
118 template<class O1, class O2>
119 im_watcher (O1 *object, void (O2::*method) ())
120 : callback0<void> (object,method)
121 { }
122
123 void start (rxvt_display *display)
124 {
125 display->reg (this);
126 }
127 void stop (rxvt_display *display)
128 {
129 display->unreg (this);
130 }
131 };
132 #endif
133
134 struct xevent_watcher : watcher, callback1<void, XEvent &> {
135 Window window;
136
137 template<class O1, class O2>
138 xevent_watcher (O1 *object, void (O2::*method) (XEvent &))
139 : callback1<void, XEvent &> (object,method)
140 { }
141
142 void start (rxvt_display *display, Window window)
143 {
144 this->window = window;
145 display->reg (this);
146 }
147 void stop (rxvt_display *display)
148 {
149 display->unreg (this);
150 }
151 };
152
153 extern refcache<rxvt_display> displays;
154
155 /////////////////////////////////////////////////////////////////////////////
156
157 typedef unsigned long Pixel;
158
159 struct rxvt_color {
160 #if XFT
161 XftColor c;
162 operator Pixel () const { return c.pixel; }
163 #else
164 Pixel p;
165 operator Pixel () const { return p; }
166 #endif
167
168 bool operator == (const rxvt_color &b) const { return Pixel (*this) == Pixel (b); }
169 bool operator != (const rxvt_color &b) const { return Pixel (*this) != Pixel (b); }
170
171 void get (rxvt_display *display, unsigned short &cr, unsigned short &cg, unsigned short &cb);
172
173 bool set (rxvt_display *display, Pixel p);
174 bool set (rxvt_display *display, const char *name);
175 bool set (rxvt_display *display, unsigned short cr, unsigned short cg, unsigned short cb);
176
177 rxvt_color fade (rxvt_display *, int percent); // fades to black
178 rxvt_color fade (rxvt_display *, int percent, rxvt_color &fadeto);
179
180 void free (rxvt_display *display);
181 };
182
183 #endif
184