2 * rxvttoolkit.h - provide toolkit-functionality for rxvt.
10 # include <X11/Xft/Xft.h>
24 struct xevent_watcher;
30 refcounted (const char *id);
31 bool ref_init () { return false; }
37 struct refcache : vector<T *> {
38 T *get (const char *id);
48 /////////////////////////////////////////////////////////////////////////////
51 struct rxvt_xim : refcounted {
53 rxvt_display *display;
58 rxvt_xim (const char *id) : refcounted (id) { }
64 struct rxvt_display : refcounted {
67 io_manager_vec<xevent_watcher> xw;
69 io_watcher x_ev; void x_cb (io_watcher &w, short revents);
72 refcache<rxvt_xim> xims;
73 vector<im_watcher *> imw;
76 void im_change_check ();
86 rxvt_term *selection_owner;
87 #ifndef NO_SLOW_LINK_SUPPORT
94 rxvt_display (const char *id);
95 XrmDatabase get_resources ();
100 operator Display *() const { return display; }
103 Atom atom (const char *name);
104 void set_selection_owner (rxvt_term *owner);
106 void reg (xevent_watcher *w);
107 void unreg (xevent_watcher *w);
110 void reg (im_watcher *w);
111 void unreg (im_watcher *w);
113 rxvt_xim *get_xim (const char *locale, const char *modifiers);
114 void put_xim (rxvt_xim *xim);
119 struct im_watcher : watcher, callback0<void> {
120 template<class O1, class O2>
121 im_watcher (O1 *object, void (O2::*method) ())
122 : callback0<void> (object,method)
125 void start (rxvt_display *display)
129 void stop (rxvt_display *display)
131 display->unreg (this);
136 struct xevent_watcher : watcher, callback1<void, XEvent &> {
139 template<class O1, class O2>
140 xevent_watcher (O1 *object, void (O2::*method) (XEvent &))
141 : callback1<void, XEvent &> (object,method)
144 void start (rxvt_display *display, Window window)
146 this->window = window;
149 void stop (rxvt_display *display)
151 display->unreg (this);
155 extern refcache<rxvt_display> displays;
157 /////////////////////////////////////////////////////////////////////////////
159 typedef unsigned long Pixel;
164 operator Pixel () const { return c.pixel; }
167 operator Pixel () const { return p; }
170 bool operator == (const rxvt_color &b) const { return Pixel (*this) == Pixel (b); }
171 bool operator != (const rxvt_color &b) const { return Pixel (*this) != Pixel (b); }
173 void get (rxvt_display *display, unsigned short &cr, unsigned short &cg, unsigned short &cb);
175 bool set (rxvt_display *display, Pixel p);
176 bool set (rxvt_display *display, const char *name);
177 bool set (rxvt_display *display, unsigned short cr, unsigned short cg, unsigned short cb);
179 rxvt_color fade (rxvt_display *, int percent); // fades to black
180 rxvt_color fade (rxvt_display *, int percent, rxvt_color &fadeto);
182 void free (rxvt_display *display);