… | |
… | |
102 | put (*this->begin ()); |
102 | put (*this->begin ()); |
103 | } |
103 | } |
104 | |
104 | |
105 | ///////////////////////////////////////////////////////////////////////////// |
105 | ///////////////////////////////////////////////////////////////////////////// |
106 | |
106 | |
|
|
107 | #ifdef USE_XIM |
107 | static void |
108 | static void |
108 | im_destroy_cb (XIM unused1, XPointer client_data, XPointer unused3) |
109 | im_destroy_cb (XIM unused1, XPointer client_data, XPointer unused3) |
109 | { |
110 | { |
110 | rxvt_xim *xim = (rxvt_xim *)client_data; |
111 | rxvt_xim *xim = (rxvt_xim *)client_data; |
111 | rxvt_display *display = xim->display; |
112 | rxvt_display *display = xim->display; |
… | |
… | |
126 | |
127 | |
127 | XIMCallback ximcallback; |
128 | XIMCallback ximcallback; |
128 | ximcallback.client_data = (XPointer)this; |
129 | ximcallback.client_data = (XPointer)this; |
129 | ximcallback.callback = im_destroy_cb; |
130 | ximcallback.callback = im_destroy_cb; |
130 | |
131 | |
|
|
132 | ((void (*)(XIM, ...)) XSetIMValues) |
131 | XSetIMValues (xim, XNDestroyCallback, &ximcallback, NULL); |
133 | (xim, XNDestroyCallback, &ximcallback, NULL); |
132 | |
134 | |
133 | return true; |
135 | return true; |
134 | } |
136 | } |
135 | |
137 | |
136 | rxvt_xim::~rxvt_xim () |
138 | rxvt_xim::~rxvt_xim () |
137 | { |
139 | { |
138 | if (xim) |
140 | if (xim) |
139 | XCloseIM (xim); |
141 | XCloseIM (xim); |
140 | } |
142 | } |
|
|
143 | #endif |
141 | |
144 | |
142 | ///////////////////////////////////////////////////////////////////////////// |
145 | ///////////////////////////////////////////////////////////////////////////// |
143 | |
146 | |
144 | rxvt_display::rxvt_display (const char *id) |
147 | rxvt_display::rxvt_display (const char *id) |
145 | : refcounted (id) |
148 | : refcounted (id) |
… | |
… | |
183 | int fd = XConnectionNumber (display); |
186 | int fd = XConnectionNumber (display); |
184 | x_ev.start (fd, EVENT_READ); |
187 | x_ev.start (fd, EVENT_READ); |
185 | fcntl (fd, F_SETFD, FD_CLOEXEC); |
188 | fcntl (fd, F_SETFD, FD_CLOEXEC); |
186 | |
189 | |
187 | XSelectInput (display, root, PropertyChangeMask); |
190 | XSelectInput (display, root, PropertyChangeMask); |
|
|
191 | #ifdef USE_XIM |
188 | xa_xim_servers = XInternAtom (display, "XIM_SERVERS", 0); |
192 | xa_xim_servers = XInternAtom (display, "XIM_SERVERS", 0); |
|
|
193 | #endif |
189 | |
194 | |
190 | flush (); |
195 | flush (); |
191 | |
196 | |
192 | return true; |
197 | return true; |
193 | } |
198 | } |
… | |
… | |
198 | |
203 | |
199 | if (display) |
204 | if (display) |
200 | XCloseDisplay (display); |
205 | XCloseDisplay (display); |
201 | } |
206 | } |
202 | |
207 | |
|
|
208 | #ifdef USE_XIM |
203 | void rxvt_display::im_change_cb () |
209 | void rxvt_display::im_change_cb () |
204 | { |
210 | { |
205 | for (im_watcher **i = imw.begin (); i != imw.end (); ++i) |
211 | for (im_watcher **i = imw.begin (); i != imw.end (); ++i) |
206 | (*i)->call (); |
212 | (*i)->call (); |
207 | } |
213 | } |
|
|
214 | #endif |
208 | |
215 | |
209 | void rxvt_display::x_cb (io_watcher &w, short revents) |
216 | void rxvt_display::x_cb (io_watcher &w, short revents) |
210 | { |
217 | { |
211 | do |
218 | do |
212 | { |
219 | { |
213 | XEvent xev; |
220 | XEvent xev; |
214 | XNextEvent (display, &xev); |
221 | XNextEvent (display, &xev); |
215 | |
222 | |
216 | //printf ("T %d w %lx\n", xev.type, xev.xany.window);//D |
223 | //printf ("T %d w %lx\n", xev.type, xev.xany.window);//D |
217 | |
224 | |
|
|
225 | #ifdef USE_XIM |
218 | if (xev.type == PropertyNotify |
226 | if (xev.type == PropertyNotify |
219 | && xev.xany.window == root |
227 | && xev.xany.window == root |
220 | && xev.xproperty.atom == xa_xim_servers) |
228 | && xev.xproperty.atom == xa_xim_servers) |
221 | im_change_cb (); |
229 | im_change_cb (); |
|
|
230 | #endif |
222 | |
231 | |
223 | for (int i = xw.size (); i--; ) |
232 | for (int i = xw.size (); i--; ) |
224 | { |
233 | { |
225 | if (!xw[i]) |
234 | if (!xw[i]) |
226 | xw.erase_unordered (i); |
235 | xw.erase_unordered (i); |
… | |
… | |
256 | { |
265 | { |
257 | if (w->active) |
266 | if (w->active) |
258 | xw[w->active - 1] = 0; |
267 | xw[w->active - 1] = 0; |
259 | } |
268 | } |
260 | |
269 | |
261 | void rxvt_display::reg (im_watcher *w) |
|
|
262 | { |
|
|
263 | imw.push_back (w); |
|
|
264 | } |
|
|
265 | |
|
|
266 | void rxvt_display::unreg (im_watcher *w) |
|
|
267 | { |
|
|
268 | imw.erase (find (imw.begin (), imw.end (), w)); |
|
|
269 | } |
|
|
270 | |
|
|
271 | void rxvt_display::set_selection_owner (rxvt_term *owner) |
270 | void rxvt_display::set_selection_owner (rxvt_term *owner) |
272 | { |
271 | { |
273 | if (selection_owner && selection_owner != owner) |
272 | if (selection_owner && selection_owner != owner) |
274 | selection_owner->selection_clear (); |
273 | selection_owner->selection_clear (); |
275 | |
274 | |
276 | selection_owner = owner; |
275 | selection_owner = owner; |
277 | } |
276 | } |
278 | |
277 | |
|
|
278 | #ifdef USE_XIM |
|
|
279 | void rxvt_display::reg (im_watcher *w) |
|
|
280 | { |
|
|
281 | imw.push_back (w); |
|
|
282 | } |
|
|
283 | |
|
|
284 | void rxvt_display::unreg (im_watcher *w) |
|
|
285 | { |
|
|
286 | imw.erase (find (imw.begin (), imw.end (), w)); |
|
|
287 | } |
|
|
288 | |
279 | rxvt_xim *rxvt_display::get_xim (const char *locale, const char *modifiers) |
289 | rxvt_xim *rxvt_display::get_xim (const char *locale, const char *modifiers) |
280 | { |
290 | { |
281 | char *id; |
291 | char *id; |
282 | int l, m; |
292 | int l, m; |
283 | |
293 | |
… | |
… | |
299 | |
309 | |
300 | void rxvt_display::put_xim (rxvt_xim *xim) |
310 | void rxvt_display::put_xim (rxvt_xim *xim) |
301 | { |
311 | { |
302 | xims.put (xim); |
312 | xims.put (xim); |
303 | } |
313 | } |
|
|
314 | #endif |
304 | |
315 | |
305 | Atom rxvt_display::atom (const char *name) |
316 | Atom rxvt_display::atom (const char *name) |
306 | { |
317 | { |
307 | return XInternAtom (display, name, False); |
318 | return XInternAtom (display, name, False); |
308 | } |
319 | } |