… | |
… | |
27 | |
27 | |
28 | #if XFT |
28 | #if XFT |
29 | # include <X11/Xft/Xft.h> |
29 | # include <X11/Xft/Xft.h> |
30 | #endif |
30 | #endif |
31 | |
31 | |
32 | #include "iom.h" |
32 | #include "ev_cpp.h" |
33 | |
33 | |
34 | #include "rxvtlib.h" |
34 | #include "rxvtlib.h" |
35 | #include "rxvtutil.h" |
35 | #include "rxvtutil.h" |
36 | |
36 | |
37 | #include "callback.h" |
37 | #include "callback.h" |
… | |
… | |
65 | #endif |
65 | #endif |
66 | #if USE_XIM |
66 | #if USE_XIM |
67 | XA_WM_LOCALE_NAME, |
67 | XA_WM_LOCALE_NAME, |
68 | XA_XIM_SERVERS, |
68 | XA_XIM_SERVERS, |
69 | #endif |
69 | #endif |
70 | #if TRANSPARENT |
70 | #if ENABLE_TRANSPARENCY |
71 | XA_XROOTPMAP_ID, |
71 | XA_XROOTPMAP_ID, |
72 | XA_ESETROOT_PMAP_ID, |
72 | XA_ESETROOT_PMAP_ID, |
73 | #endif |
73 | #endif |
74 | #if ENABLE_XEMBED |
74 | #if ENABLE_XEMBED |
75 | XA_XEMBED, |
75 | XA_XEMBED, |
… | |
… | |
100 | struct rxvt_display; |
100 | struct rxvt_display; |
101 | |
101 | |
102 | struct im_watcher; |
102 | struct im_watcher; |
103 | struct xevent_watcher; |
103 | struct xevent_watcher; |
104 | |
104 | |
|
|
105 | template<class watcher> |
|
|
106 | struct event_vec : vector<watcher *> { |
|
|
107 | void erase_unordered (unsigned int pos) |
|
|
108 | { |
|
|
109 | watcher *w = (*this)[this->size () - 1]; |
|
|
110 | this->pop_back (); |
|
|
111 | |
|
|
112 | if (!this->empty ()) |
|
|
113 | if (((*this)[pos] = w)) // '=' is correct! |
|
|
114 | w->active = pos + 1; |
|
|
115 | } |
|
|
116 | }; |
|
|
117 | |
|
|
118 | struct rxvt_watcher { |
|
|
119 | int active; /* 0 == inactive, else index into respective vector */ |
|
|
120 | |
|
|
121 | bool is_active () { return active; } |
|
|
122 | |
|
|
123 | rxvt_watcher () : active (0) { } |
|
|
124 | }; |
|
|
125 | |
105 | struct refcounted { |
126 | struct refcounted { |
106 | int referenced; |
127 | int referenced; |
107 | char *id; |
128 | char *id; |
108 | |
129 | |
109 | refcounted (const char *id); |
130 | refcounted (const char *id); |
… | |
… | |
183 | |
204 | |
184 | rxvt_screen (); |
205 | rxvt_screen (); |
185 | #endif |
206 | #endif |
186 | |
207 | |
187 | void set (rxvt_display *disp); |
208 | void set (rxvt_display *disp); |
188 | void set (rxvt_display *disp, int bitdepth); |
209 | void select_visual (int bitdepth); |
189 | void clear (); |
210 | void clear (); |
190 | }; |
211 | }; |
191 | |
212 | |
192 | struct rxvt_display : refcounted { |
213 | struct rxvt_display : refcounted { |
193 | io_manager_vec<xevent_watcher> xw; |
214 | event_vec<xevent_watcher> xw; |
194 | |
215 | |
195 | io_watcher x_ev; void x_cb (io_watcher &w, short revents); |
216 | ev::io x_ev; void x_cb (ev::io &w, int revents); |
196 | |
217 | |
197 | #ifdef USE_XIM |
218 | #ifdef USE_XIM |
198 | refcache<rxvt_xim> xims; |
219 | refcache<rxvt_xim> xims; |
199 | vector<im_watcher *> imw; |
220 | vector<im_watcher *> imw; |
200 | |
221 | |
… | |
… | |
234 | void put_xim (rxvt_xim *xim); |
255 | void put_xim (rxvt_xim *xim); |
235 | #endif |
256 | #endif |
236 | }; |
257 | }; |
237 | |
258 | |
238 | #ifdef USE_XIM |
259 | #ifdef USE_XIM |
239 | struct im_watcher : watcher, callback<void (void)> { |
260 | struct im_watcher : rxvt_watcher, callback<void (void)> { |
240 | template<class O, class M> |
261 | template<class O, class M> |
241 | im_watcher (O object, M method) |
262 | im_watcher (O object, M method) |
242 | : callback<void (void)> (object, method) |
263 | : callback<void (void)> (object, method) |
243 | { } |
264 | { } |
244 | |
265 | |
245 | void start (rxvt_display *display) |
266 | void start (rxvt_display *display) |
246 | { |
267 | { |
247 | display->reg (this); |
268 | display->reg (this); |
248 | } |
269 | } |
|
|
270 | |
249 | void stop (rxvt_display *display) |
271 | void stop (rxvt_display *display) |
250 | { |
272 | { |
251 | display->unreg (this); |
273 | display->unreg (this); |
252 | } |
274 | } |
253 | }; |
275 | }; |
254 | #endif |
276 | #endif |
255 | |
277 | |
256 | struct xevent_watcher : watcher, callback<void (XEvent &)> { |
278 | struct xevent_watcher : rxvt_watcher, callback<void (XEvent &)> { |
257 | Window window; |
279 | Window window; |
258 | |
280 | |
259 | template<class O, class M> |
281 | template<class O, class M> |
260 | xevent_watcher (O object, M method) |
282 | xevent_watcher (O object, M method) |
261 | : callback<void (XEvent &)> (object, method) |
283 | : callback<void (XEvent &)> (object, method) |
… | |
… | |
264 | void start (rxvt_display *display, Window window) |
286 | void start (rxvt_display *display, Window window) |
265 | { |
287 | { |
266 | this->window = window; |
288 | this->window = window; |
267 | display->reg (this); |
289 | display->reg (this); |
268 | } |
290 | } |
|
|
291 | |
269 | void stop (rxvt_display *display) |
292 | void stop (rxvt_display *display) |
270 | { |
293 | { |
271 | display->unreg (this); |
294 | display->unreg (this); |
272 | } |
295 | } |
273 | }; |
296 | }; |
… | |
… | |
306 | bool alloc (rxvt_screen *screen, const rgba &color); |
329 | bool alloc (rxvt_screen *screen, const rgba &color); |
307 | void free (rxvt_screen *screen); |
330 | void free (rxvt_screen *screen); |
308 | |
331 | |
309 | void get (rgba &color); |
332 | void get (rgba &color); |
310 | void get (XColor &color); |
333 | void get (XColor &color); |
311 | |
334 | |
312 | bool set (rxvt_screen *screen, const char *name); |
335 | bool set (rxvt_screen *screen, const char *name); |
313 | bool set (rxvt_screen *screen, const rgba &color); |
336 | bool set (rxvt_screen *screen, const rgba &color); |
314 | |
337 | |
315 | void fade (rxvt_screen *screen, int percent, rxvt_color &result, const rgba &to = rgba (0, 0, 0)); |
338 | void fade (rxvt_screen *screen, int percent, rxvt_color &result, const rgba &to = rgba (0, 0, 0)); |
316 | }; |
339 | }; |