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,
69 // various selection targets used by XIM
84 struct xevent_watcher;
90 refcounted (const char *id);
91 bool ref_init () { return false; }
97 struct refcache : vector<T *> {
98 T *get (const char *id);
108 /////////////////////////////////////////////////////////////////////////////
111 struct rxvt_xim : refcounted {
113 rxvt_display *display;
118 rxvt_xim (const char *id) : refcounted (id) { }
125 rxvt_display *display;
131 void set (rxvt_display *disp);
132 void set (rxvt_display *disp, int bitdepth);
136 struct rxvt_display : refcounted {
137 io_manager_vec<xevent_watcher> xw;
139 io_watcher x_ev; void x_cb (io_watcher &w, short revents);
142 refcache<rxvt_xim> xims;
143 vector<im_watcher *> imw;
145 void im_change_cb ();
146 void im_change_check ();
153 rxvt_term *selection_owner;
155 #ifndef NO_SLOW_LINK_SUPPORT
162 rxvt_display (const char *id);
163 XrmDatabase get_resources ();
169 Atom atom (const char *name);
170 void set_selection_owner (rxvt_term *owner);
172 void reg (xevent_watcher *w);
173 void unreg (xevent_watcher *w);
176 void reg (im_watcher *w);
177 void unreg (im_watcher *w);
179 rxvt_xim *get_xim (const char *locale, const char *modifiers);
180 void put_xim (rxvt_xim *xim);
185 struct im_watcher : watcher, callback0<void> {
186 template<class O1, class O2>
187 im_watcher (O1 *object, void (O2::*method) ())
188 : callback0<void> (object,method)
191 void start (rxvt_display *display)
195 void stop (rxvt_display *display)
197 display->unreg (this);
202 struct xevent_watcher : watcher, callback1<void, XEvent &> {
205 template<class O1, class O2>
206 xevent_watcher (O1 *object, void (O2::*method) (XEvent &))
207 : callback1<void, XEvent &> (object,method)
210 void start (rxvt_display *display, Window window)
212 this->window = window;
215 void stop (rxvt_display *display)
217 display->unreg (this);
221 extern refcache<rxvt_display> displays;
223 /////////////////////////////////////////////////////////////////////////////
225 typedef unsigned long Pixel;
228 unsigned short r, g, b, a;
230 enum { MIN_CC = 0x0000, MAX_CC = 0xffff };
235 rgba (unsigned short r, unsigned short g, unsigned short b, unsigned short a = MAX_CC)
236 : r(r), g(g), b(b), a(a)
247 operator Pixel () const { return c.pixel; }
249 bool operator == (const rxvt_color &b) const { return Pixel (*this) == Pixel (b); }
250 bool operator != (const rxvt_color &b) const { return Pixel (*this) != Pixel (b); }
252 bool alloc (rxvt_screen *screen, const rgba &color);
253 void free (rxvt_screen *screen);
255 void get (rgba &color);
256 void get (XColor &color);
258 bool set (rxvt_screen *screen, const char *name);
259 bool set (rxvt_screen *screen, const rgba &color);
261 void fade (rxvt_screen *screen, int percent, rxvt_color &result, const rgba &to = rgba (0, 0, 0));