… | |
… | |
15 | #include "rxvtlib.h" |
15 | #include "rxvtlib.h" |
16 | #include "rxvtutil.h" |
16 | #include "rxvtutil.h" |
17 | |
17 | |
18 | #include "callback.h" |
18 | #include "callback.h" |
19 | |
19 | |
|
|
20 | // see rxvttoolkit.C:xa_names, which must be kept in sync |
|
|
21 | enum { |
|
|
22 | XA_TEXT, |
|
|
23 | XA_COMPOUND_TEXT, |
|
|
24 | XA_UTF8_STRING, |
|
|
25 | XA_MULTIPLE, |
|
|
26 | XA_TARGETS, |
|
|
27 | XA_TIMESTAMP, |
|
|
28 | XA_VT_SELECTION, |
|
|
29 | XA_INCR, |
|
|
30 | XA_WM_PROTOCOLS, |
|
|
31 | XA_WM_DELETE_WINDOW, |
|
|
32 | XA_CLIPBOARD, |
|
|
33 | XA_AVERAGE_WIDTH, |
|
|
34 | XA_WEIGHT_NAME, |
|
|
35 | XA_SLANT, |
|
|
36 | XA_CHARSET_REGISTRY, |
|
|
37 | XA_CHARSET_ENCODING, |
|
|
38 | #if ENABLE_FRILLS |
|
|
39 | XA_MOTIF_WM_HINTS, |
|
|
40 | #endif |
|
|
41 | #if ENABLE_EWMH |
|
|
42 | XA_NET_WM_PID, |
|
|
43 | XA_NET_WM_NAME, |
|
|
44 | XA_NET_WM_ICON_NAME, |
|
|
45 | XA_NET_WM_PING, |
|
|
46 | #endif |
|
|
47 | #if USE_XIM |
|
|
48 | XA_WM_LOCALE_NAME, |
|
|
49 | XA_XIM_SERVERS, |
|
|
50 | #endif |
|
|
51 | #if TRANSPARENT |
|
|
52 | XA_XROOTPMAP_ID, |
|
|
53 | XA_ESETROOT_PMAP_ID, |
|
|
54 | #endif |
|
|
55 | #if ENABLE_XEMBED |
|
|
56 | XA_XEMBED, |
|
|
57 | XA_XEMBED_INFO, |
|
|
58 | #endif |
|
|
59 | #if !ENABLE_MINIMAL |
|
|
60 | // these are usually allocated by other subsystens, but we do it |
|
|
61 | // here to avoid a server roundtrip. |
|
|
62 | XA_SCREEN_RESOURCES, |
|
|
63 | XA_XDCCC_LINEAR_RGB_CORRECTION, |
|
|
64 | XA_XDCCC_LINEAR_RGB_MATRICES, |
|
|
65 | XA_WM_COLORMAP_WINDOWS, |
|
|
66 | XA_WM_STATE, |
|
|
67 | XA_cursor, |
|
|
68 | # if USE_XIM |
|
|
69 | // various selection targets used by XIM |
|
|
70 | XA_TRANSPORT, |
|
|
71 | XA_LOCALES, |
|
|
72 | XA__XIM_PROTOCOL, |
|
|
73 | XA__XIM_XCONNECT, |
|
|
74 | XA__XIM_MOREDATA, |
|
|
75 | # endif |
|
|
76 | #endif |
|
|
77 | NUM_XA |
|
|
78 | }; |
|
|
79 | |
20 | struct rxvt_term; |
80 | struct rxvt_term; |
21 | struct rxvt_display; |
81 | struct rxvt_display; |
22 | |
82 | |
23 | struct im_watcher; |
83 | struct im_watcher; |
24 | struct xevent_watcher; |
84 | struct xevent_watcher; |
… | |
… | |
26 | struct refcounted { |
86 | struct refcounted { |
27 | int referenced; |
87 | int referenced; |
28 | char *id; |
88 | char *id; |
29 | |
89 | |
30 | refcounted (const char *id); |
90 | refcounted (const char *id); |
31 | bool init () { return false; } |
91 | bool ref_init () { return false; } |
|
|
92 | void ref_next () { } |
32 | ~refcounted (); |
93 | ~refcounted (); |
33 | }; |
94 | }; |
34 | |
95 | |
35 | template<class T> |
96 | template<class T> |
36 | struct refcache : vector<T *> { |
97 | struct refcache : vector<T *> { |
37 | T *get (const char *id); |
98 | T *get (const char *id); |
38 | void put (T *obj); |
99 | void put (T *obj); |
|
|
100 | void clear (); |
|
|
101 | |
39 | ~refcache (); |
102 | ~refcache () |
|
|
103 | { |
|
|
104 | clear (); |
|
|
105 | } |
40 | }; |
106 | }; |
41 | |
107 | |
42 | ///////////////////////////////////////////////////////////////////////////// |
108 | ///////////////////////////////////////////////////////////////////////////// |
43 | |
109 | |
44 | #ifdef USE_XIM |
110 | #ifdef USE_XIM |
… | |
… | |
48 | |
114 | |
49 | //public |
115 | //public |
50 | XIM xim; |
116 | XIM xim; |
51 | |
117 | |
52 | rxvt_xim (const char *id) : refcounted (id) { } |
118 | rxvt_xim (const char *id) : refcounted (id) { } |
53 | bool init (); |
119 | bool ref_init (); |
54 | ~rxvt_xim (); |
120 | ~rxvt_xim (); |
55 | }; |
121 | }; |
56 | #endif |
122 | #endif |
57 | |
123 | |
|
|
124 | struct rxvt_screen { |
|
|
125 | rxvt_display *display; |
|
|
126 | Display *xdisp; |
|
|
127 | int depth; |
|
|
128 | Visual *visual; |
|
|
129 | Colormap cmap; |
|
|
130 | |
|
|
131 | void set (rxvt_display *disp); |
|
|
132 | void set (rxvt_display *disp, int bitdepth); |
|
|
133 | void clear (); |
|
|
134 | }; |
|
|
135 | |
58 | struct rxvt_display : refcounted { |
136 | struct rxvt_display : refcounted { |
59 | Atom xa_xim_servers; |
|
|
60 | |
|
|
61 | io_manager_vec<xevent_watcher> xw; |
137 | io_manager_vec<xevent_watcher> xw; |
62 | |
138 | |
63 | io_watcher x_ev; void x_cb (io_watcher &w, short revents); |
139 | io_watcher x_ev; void x_cb (io_watcher &w, short revents); |
64 | |
140 | |
65 | #ifdef USE_XIM |
141 | #ifdef USE_XIM |
… | |
… | |
69 | void im_change_cb (); |
145 | void im_change_cb (); |
70 | void im_change_check (); |
146 | void im_change_check (); |
71 | #endif |
147 | #endif |
72 | |
148 | |
73 | //public |
149 | //public |
74 | Display *display; |
150 | Display *display; |
75 | int depth; |
|
|
76 | int screen; |
151 | int screen; |
77 | Visual *visual; |
|
|
78 | Colormap cmap; |
|
|
79 | Window root; |
152 | Window root; |
80 | rxvt_term *selection_owner; |
153 | rxvt_term *selection_owner; |
|
|
154 | Atom xa[NUM_XA]; |
81 | #ifndef NO_SLOW_LINK_SUPPORT |
155 | #ifndef NO_SLOW_LINK_SUPPORT |
82 | bool is_local; |
156 | bool is_local; |
|
|
157 | #endif |
|
|
158 | #ifdef POINTER_BLANK |
|
|
159 | Cursor blank_cursor; |
83 | #endif |
160 | #endif |
84 | |
161 | |
85 | rxvt_display (const char *id); |
162 | rxvt_display (const char *id); |
|
|
163 | XrmDatabase get_resources (); |
86 | bool init (); |
164 | bool ref_init (); |
|
|
165 | void ref_next (); |
87 | ~rxvt_display (); |
166 | ~rxvt_display (); |
88 | |
|
|
89 | operator Display *() const { return display; } |
|
|
90 | |
167 | |
91 | void flush (); |
168 | void flush (); |
92 | Atom atom (const char *name); |
169 | Atom atom (const char *name); |
93 | void set_selection_owner (rxvt_term *owner); |
170 | void set_selection_owner (rxvt_term *owner); |
94 | |
171 | |
… | |
… | |
144 | extern refcache<rxvt_display> displays; |
221 | extern refcache<rxvt_display> displays; |
145 | |
222 | |
146 | ///////////////////////////////////////////////////////////////////////////// |
223 | ///////////////////////////////////////////////////////////////////////////// |
147 | |
224 | |
148 | typedef unsigned long Pixel; |
225 | typedef unsigned long Pixel; |
|
|
226 | |
|
|
227 | struct rxvt_rgba { |
|
|
228 | unsigned short r, g, b, a; |
|
|
229 | |
|
|
230 | enum { MIN_CC = 0x0000, MAX_CC = 0xffff }; |
|
|
231 | |
|
|
232 | rxvt_rgba () |
|
|
233 | { } |
|
|
234 | |
|
|
235 | rxvt_rgba (unsigned short r, unsigned short g, unsigned short b, unsigned short a = MAX_CC) |
|
|
236 | : r(r), g(g), b(b), a(a) |
|
|
237 | { } |
|
|
238 | }; |
149 | |
239 | |
150 | struct rxvt_color { |
240 | struct rxvt_color { |
151 | #if XFT |
241 | #if XFT |
152 | XftColor c; |
242 | XftColor c; |
153 | operator Pixel () const { return c.pixel; } |
243 | operator Pixel () const { return c.pixel; } |
… | |
… | |
157 | #endif |
247 | #endif |
158 | |
248 | |
159 | bool operator == (const rxvt_color &b) const { return Pixel (*this) == Pixel (b); } |
249 | bool operator == (const rxvt_color &b) const { return Pixel (*this) == Pixel (b); } |
160 | 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); } |
161 | |
251 | |
162 | void get (rxvt_display *display, unsigned short &cr, unsigned short &cg, unsigned short &cb); |
252 | void get (rxvt_screen *screen, rxvt_rgba &rgba); |
163 | |
253 | |
164 | bool set (rxvt_display *display, Pixel p); |
254 | bool alloc (rxvt_screen *screen, rxvt_rgba rgba); |
|
|
255 | |
165 | bool set (rxvt_display *display, const char *name); |
256 | bool set (rxvt_screen *screen, const char *name); |
166 | bool set (rxvt_display *display, unsigned short cr, unsigned short cg, unsigned short cb); |
257 | bool set (rxvt_screen *screen, rxvt_rgba rgba); |
167 | |
258 | |
168 | rxvt_color fade (rxvt_display *, int percent); |
259 | rxvt_color fade (rxvt_screen *screen, int percent); // fades to black |
|
|
260 | rxvt_color fade (rxvt_screen *screen, int percent, rxvt_color &fadeto); |
169 | |
261 | |
170 | void free (rxvt_display *display); |
262 | void free (rxvt_screen *screen); |
171 | }; |
263 | }; |
172 | |
264 | |
173 | #endif |
265 | #endif |
174 | |
266 | |