ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/rxvttoolkit.C
(Generate patch)

Comparing rxvt-unicode/src/rxvttoolkit.C (file contents):
Revision 1.2 by root, Sun Aug 15 04:54:21 2004 UTC vs.
Revision 1.5 by root, Tue Sep 7 12:34:05 2004 UTC

1/*--------------------------------*-C-*---------------------------------* 1/*--------------------------------*-C-*---------------------------------*
2 * File: rxvtcolor.C 2 * File: rxvttoolkit.C
3 *----------------------------------------------------------------------* 3 *----------------------------------------------------------------------*
4 * 4 *
5 * All portions of code are copyright by their respective author/s. 5 * All portions of code are copyright by their respective author/s.
6 * Copyright (c) 2003-2004 Marc Lehmann <pcg@goof.com> 6 * Copyright (c) 2003-2004 Marc Lehmann <pcg@goof.com>
7 * 7 *
101#endif 101#endif
102{ 102{
103 rxvt_xim *xim = (rxvt_xim *)client_data; 103 rxvt_xim *xim = (rxvt_xim *)client_data;
104 rxvt_display *display = xim->display; 104 rxvt_display *display = xim->display;
105 105
106 xim->xim = 0;
107
106 display->xims.erase (find (display->xims.begin (), display->xims.end (), xim)); 108 display->xims.erase (find (display->xims.begin (), display->xims.end (), xim));
107
108 display->im_change_cb (); 109 display->im_change_cb ();
109} 110}
110 111
111bool rxvt_xim::init () 112bool rxvt_xim::init ()
112{ 113{
213void rxvt_display::im_change_cb () 214void rxvt_display::im_change_cb ()
214{ 215{
215 for (im_watcher **i = imw.begin (); i != imw.end (); ++i) 216 for (im_watcher **i = imw.begin (); i != imw.end (); ++i)
216 (*i)->call (); 217 (*i)->call ();
217} 218}
219
220void rxvt_display::im_change_check ()
221{
222 // make sure we only call im_change_cb when a new input method
223 // registers, as xlib crashes due to a race otherwise.
224 Atom actual_type, *atoms;
225 int actual_format;
226 unsigned long nitems, bytes_after;
227
228 if (XGetWindowProperty (display, root, xa_xim_servers, 0L, 1000000L,
229 False, XA_ATOM, &actual_type, &actual_format,
230 &nitems, &bytes_after, (unsigned char **)&atoms)
231 != Success )
232 return;
233
234 if (actual_type == XA_ATOM && actual_format == 32)
235 for (int i = 0; i < nitems; i++)
236 if (XGetSelectionOwner (display, atoms[i]))
237 {
238 im_change_cb ();
239 break;
240 }
241
242 XFree (atoms);
243}
218#endif 244#endif
219 245
220void rxvt_display::x_cb (io_watcher &w, short revents) 246void rxvt_display::x_cb (io_watcher &w, short revents)
221{ 247{
222 do 248 do
223 { 249 {
224 XEvent xev; 250 XEvent xev;
225 XNextEvent (display, &xev); 251 XNextEvent (display, &xev);
226 252
227 //printf ("T %d w %lx\n", xev.type, xev.xany.window);//D
228
229#ifdef USE_XIM 253#ifdef USE_XIM
230 if (xev.type == PropertyNotify 254 if (!XFilterEvent (&xev, None))
231 && xev.xany.window == root
232 && xev.xproperty.atom == xa_xim_servers)
233 im_change_cb ();
234#endif
235
236 for (int i = xw.size (); i--; )
237 { 255 {
256
257 if (xev.type == PropertyNotify
258 && xev.xany.window == root
259 && xev.xproperty.atom == xa_xim_servers)
260 im_change_check ();
261#endif
262 for (int i = xw.size (); i--; )
263 {
238 if (!xw[i]) 264 if (!xw[i])
239 xw.erase_unordered (i); 265 xw.erase_unordered (i);
240 else if (xw[i]->window == xev.xany.window) 266 else if (xw[i]->window == xev.xany.window)
241 xw[i]->call (xev); 267 xw[i]->call (xev);
268 }
269#ifdef USE_XIM
242 } 270 }
271#endif
243 } 272 }
244 while (XPending (display)); 273 while (XPending (display));
245 274
246 flush (); 275 flush ();
247} 276}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines