2 * rxvttoolkit.h - provide toolkit-functionality for rxvt.
10 # include <X11/Xft/Xft.h>
20 // see rxvttoolkit.C:xa_names, which must be kept in sync
60 // these are usually allocated by other subsystens, but we do it
61 // here to avoid a server roundtrip.
63 XA_XDCCC_LINEAR_RGB_CORRECTION,
64 XA_XDCCC_LINEAR_RGB_MATRICES,
65 XA_WM_COLORMAP_WINDOWS,
75 struct xevent_watcher;
81 refcounted (const char *id);
82 bool ref_init () { return false; }
88 struct refcache : vector<T *> {
89 T *get (const char *id);
99 /////////////////////////////////////////////////////////////////////////////
102 struct rxvt_xim : refcounted {
104 rxvt_display *display;
109 rxvt_xim (const char *id) : refcounted (id) { }
116 rxvt_display *display;
122 void set (rxvt_display *disp);
123 void set (rxvt_display *disp, int bitdepth);
127 struct rxvt_display : refcounted {
128 io_manager_vec<xevent_watcher> xw;
130 io_watcher x_ev; void x_cb (io_watcher &w, short revents);
133 refcache<rxvt_xim> xims;
134 vector<im_watcher *> imw;
136 void im_change_cb ();
137 void im_change_check ();
144 rxvt_term *selection_owner;
146 #ifndef NO_SLOW_LINK_SUPPORT
153 rxvt_display (const char *id);
154 XrmDatabase get_resources ();
160 Atom atom (const char *name);
161 void set_selection_owner (rxvt_term *owner);
163 void reg (xevent_watcher *w);
164 void unreg (xevent_watcher *w);
167 void reg (im_watcher *w);
168 void unreg (im_watcher *w);
170 rxvt_xim *get_xim (const char *locale, const char *modifiers);
171 void put_xim (rxvt_xim *xim);
176 struct im_watcher : watcher, callback0<void> {
177 template<class O1, class O2>
178 im_watcher (O1 *object, void (O2::*method) ())
179 : callback0<void> (object,method)
182 void start (rxvt_display *display)
186 void stop (rxvt_display *display)
188 display->unreg (this);
193 struct xevent_watcher : watcher, callback1<void, XEvent &> {
196 template<class O1, class O2>
197 xevent_watcher (O1 *object, void (O2::*method) (XEvent &))
198 : callback1<void, XEvent &> (object,method)
201 void start (rxvt_display *display, Window window)
203 this->window = window;
206 void stop (rxvt_display *display)
208 display->unreg (this);
212 extern refcache<rxvt_display> displays;
214 /////////////////////////////////////////////////////////////////////////////
216 typedef unsigned long Pixel;
219 unsigned short r, g, b, a;
221 enum { MIN_CC = 0x0000, MAX_CC = 0xffff };
226 rxvt_rgba (unsigned short r, unsigned short g, unsigned short b, unsigned short a = MAX_CC)
227 : r(r), g(g), b(b), a(a)
234 operator Pixel () const { return c.pixel; }
237 operator Pixel () const { return p; }
240 bool operator == (const rxvt_color &b) const { return Pixel (*this) == Pixel (b); }
241 bool operator != (const rxvt_color &b) const { return Pixel (*this) != Pixel (b); }
243 void get (rxvt_screen *screen, rxvt_rgba &rgba);
245 bool set (rxvt_screen *screen, const char *name);
246 bool set (rxvt_screen *screen, rxvt_rgba rgba);
248 rxvt_color fade (rxvt_screen *screen, int percent); // fades to black
249 rxvt_color fade (rxvt_screen *screen, int percent, rxvt_color &fadeto);
251 void free (rxvt_screen *screen);