… | |
… | |
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 | #if ENABLE_FRILLS |
|
|
34 | XA_MOTIF_WM_HINTS, |
|
|
35 | #endif |
|
|
36 | #if ENABLE_EWMH |
|
|
37 | XA_NET_WM_PID, |
|
|
38 | XA_NET_WM_NAME, |
|
|
39 | XA_NET_WM_ICON_NAME, |
|
|
40 | XA_NET_WM_PING, |
|
|
41 | #endif |
|
|
42 | #if USE_XIM |
|
|
43 | XA_WM_LOCALE_NAME, |
|
|
44 | XA_XIM_SERVERS, |
|
|
45 | #endif |
|
|
46 | #if TRANSPARENT |
|
|
47 | XA_XROOTPMAP_ID, |
|
|
48 | XA_ESETROOT_PMAP_ID, |
|
|
49 | #endif |
|
|
50 | #if ENABLE_XEMBED |
|
|
51 | XA_XEMBED, |
|
|
52 | XA_XEMBED_INFO, |
|
|
53 | #endif |
|
|
54 | NUM_XA |
|
|
55 | }; |
|
|
56 | |
20 | struct rxvt_term; |
57 | struct rxvt_term; |
21 | struct rxvt_display; |
58 | struct rxvt_display; |
22 | |
59 | |
23 | struct im_watcher; |
60 | struct im_watcher; |
24 | struct xevent_watcher; |
61 | struct xevent_watcher; |
… | |
… | |
26 | struct refcounted { |
63 | struct refcounted { |
27 | int referenced; |
64 | int referenced; |
28 | char *id; |
65 | char *id; |
29 | |
66 | |
30 | refcounted (const char *id); |
67 | refcounted (const char *id); |
31 | bool init () { return false; } |
68 | bool ref_init () { return false; } |
|
|
69 | void ref_next () { } |
32 | ~refcounted (); |
70 | ~refcounted (); |
33 | }; |
71 | }; |
34 | |
72 | |
35 | template<class T> |
73 | template<class T> |
36 | struct refcache : vector<T *> { |
74 | struct refcache : vector<T *> { |
37 | T *get (const char *id); |
75 | T *get (const char *id); |
38 | void put (T *obj); |
76 | void put (T *obj); |
|
|
77 | void clear (); |
|
|
78 | |
39 | ~refcache (); |
79 | ~refcache () |
|
|
80 | { |
|
|
81 | clear (); |
|
|
82 | } |
40 | }; |
83 | }; |
41 | |
84 | |
42 | ///////////////////////////////////////////////////////////////////////////// |
85 | ///////////////////////////////////////////////////////////////////////////// |
43 | |
86 | |
44 | #ifdef USE_XIM |
87 | #ifdef USE_XIM |
… | |
… | |
48 | |
91 | |
49 | //public |
92 | //public |
50 | XIM xim; |
93 | XIM xim; |
51 | |
94 | |
52 | rxvt_xim (const char *id) : refcounted (id) { } |
95 | rxvt_xim (const char *id) : refcounted (id) { } |
53 | bool init (); |
96 | bool ref_init (); |
54 | ~rxvt_xim (); |
97 | ~rxvt_xim (); |
55 | }; |
98 | }; |
56 | #endif |
99 | #endif |
57 | |
100 | |
|
|
101 | struct rxvt_screen { |
|
|
102 | rxvt_display *display; |
|
|
103 | Display *xdisp; |
|
|
104 | int depth; |
|
|
105 | Visual *visual; |
|
|
106 | Colormap cmap; |
|
|
107 | |
|
|
108 | void set (rxvt_display *disp); |
|
|
109 | void set (rxvt_display *disp, int depth); |
|
|
110 | void clear (); |
|
|
111 | }; |
|
|
112 | |
58 | struct rxvt_display : refcounted { |
113 | struct rxvt_display : refcounted { |
59 | Atom xa_xim_servers; |
|
|
60 | |
|
|
61 | io_manager_vec<xevent_watcher> xw; |
114 | io_manager_vec<xevent_watcher> xw; |
62 | |
115 | |
63 | io_watcher x_ev; void x_cb (io_watcher &w, short revents); |
116 | io_watcher x_ev; void x_cb (io_watcher &w, short revents); |
64 | |
117 | |
65 | #ifdef USE_XIM |
118 | #ifdef USE_XIM |
66 | refcache<rxvt_xim> xims; |
119 | refcache<rxvt_xim> xims; |
67 | vector<im_watcher *> imw; |
120 | vector<im_watcher *> imw; |
68 | |
121 | |
69 | void im_change_cb (); |
122 | void im_change_cb (); |
|
|
123 | void im_change_check (); |
70 | #endif |
124 | #endif |
71 | |
125 | |
72 | //public |
126 | //public |
73 | Display *display; |
127 | Display *display; |
74 | int depth; |
|
|
75 | int screen; |
128 | int screen; |
76 | Visual *visual; |
|
|
77 | Colormap cmap; |
|
|
78 | Window root; |
129 | Window root; |
79 | rxvt_term *selection_owner; |
130 | rxvt_term *selection_owner; |
|
|
131 | Atom xa[NUM_XA]; |
80 | #ifndef NO_SLOW_LINK_SUPPORT |
132 | #ifndef NO_SLOW_LINK_SUPPORT |
81 | bool is_local; |
133 | bool is_local; |
|
|
134 | #endif |
|
|
135 | #ifdef POINTER_BLANK |
|
|
136 | Cursor blank_cursor; |
82 | #endif |
137 | #endif |
83 | |
138 | |
84 | rxvt_display (const char *id); |
139 | rxvt_display (const char *id); |
|
|
140 | XrmDatabase get_resources (); |
85 | bool init (); |
141 | bool ref_init (); |
|
|
142 | void ref_next (); |
86 | ~rxvt_display (); |
143 | ~rxvt_display (); |
87 | |
144 | |
88 | void flush (); |
145 | void flush (); |
89 | |
146 | Atom atom (const char *name); |
90 | void set_selection_owner (rxvt_term *owner); |
147 | void set_selection_owner (rxvt_term *owner); |
91 | |
148 | |
92 | void reg (xevent_watcher *w); |
149 | void reg (xevent_watcher *w); |
93 | void unreg (xevent_watcher *w); |
150 | void unreg (xevent_watcher *w); |
94 | |
151 | |
… | |
… | |
97 | void unreg (im_watcher *w); |
154 | void unreg (im_watcher *w); |
98 | |
155 | |
99 | rxvt_xim *get_xim (const char *locale, const char *modifiers); |
156 | rxvt_xim *get_xim (const char *locale, const char *modifiers); |
100 | void put_xim (rxvt_xim *xim); |
157 | void put_xim (rxvt_xim *xim); |
101 | #endif |
158 | #endif |
102 | |
|
|
103 | Atom atom (const char *name); |
|
|
104 | }; |
159 | }; |
105 | |
160 | |
106 | #ifdef USE_XIM |
161 | #ifdef USE_XIM |
107 | struct im_watcher : watcher, callback0<void> { |
162 | struct im_watcher : watcher, callback0<void> { |
108 | template<class O1, class O2> |
163 | template<class O1, class O2> |
… | |
… | |
156 | #endif |
211 | #endif |
157 | |
212 | |
158 | bool operator == (const rxvt_color &b) const { return Pixel (*this) == Pixel (b); } |
213 | bool operator == (const rxvt_color &b) const { return Pixel (*this) == Pixel (b); } |
159 | bool operator != (const rxvt_color &b) const { return Pixel (*this) != Pixel (b); } |
214 | bool operator != (const rxvt_color &b) const { return Pixel (*this) != Pixel (b); } |
160 | |
215 | |
161 | void get (rxvt_display *display, unsigned short &cr, unsigned short &cg, unsigned short &cb); |
216 | void get (rxvt_screen *screen, unsigned short &cr, unsigned short &cg, unsigned short &cb); |
162 | |
217 | |
163 | bool set (rxvt_display *display, Pixel p); |
218 | bool set (rxvt_screen *screen, Pixel p); |
164 | bool set (rxvt_display *display, const char *name); |
219 | bool set (rxvt_screen *screen, const char *name); |
165 | bool set (rxvt_display *display, unsigned short cr, unsigned short cg, unsigned short cb); |
220 | bool set (rxvt_screen *screen, unsigned short cr, unsigned short cg, unsigned short cb); |
166 | |
221 | |
167 | rxvt_color fade (rxvt_display *, int percent); |
222 | rxvt_color fade (rxvt_screen *screen, int percent); // fades to black |
|
|
223 | rxvt_color fade (rxvt_screen *screen, int percent, rxvt_color &fadeto); |
168 | |
224 | |
169 | void free (rxvt_display *display); |
225 | void free (rxvt_screen *screen); |
170 | }; |
226 | }; |
171 | |
227 | |
172 | #endif |
228 | #endif |
173 | |
229 | |