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.10 by root, Wed Dec 29 19:59:46 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 (XEventsQueued (display, QueuedAlready));
245 274
246 flush (); 275 XFlush (display);
247} 276}
248 277
249void rxvt_display::flush () 278void rxvt_display::flush ()
250{ 279{
251 for (;;) 280 if (XEventsQueued (display, QueuedAlready))
252 { 281 x_cb (x_ev, EVENT_READ);
253 if (!XPending (display))
254 break;
255 282
256 x_cb (x_ev, 0); 283 XFlush (display);
257 }
258} 284}
259 285
260void rxvt_display::reg (xevent_watcher *w) 286void rxvt_display::reg (xevent_watcher *w)
261{ 287{
262 xw.push_back (w); 288 xw.push_back (w);
309 return xim; 335 return xim;
310} 336}
311 337
312void rxvt_display::put_xim (rxvt_xim *xim) 338void rxvt_display::put_xim (rxvt_xim *xim)
313{ 339{
340#if XLIB_IS_RACEFREE
314 xims.put (xim); 341 xims.put (xim);
342#endif
315} 343}
316#endif 344#endif
317 345
318Atom rxvt_display::atom (const char *name) 346Atom rxvt_display::atom (const char *name)
319{ 347{
357} 385}
358 386
359bool 387bool
360rxvt_color::set (rxvt_display *display, const char *name) 388rxvt_color::set (rxvt_display *display, const char *name)
361{ 389{
390#if XFT
391 return XftColorAllocName (display->display, display->visual, display->cmap,
392 name, &c);
393#else
362 XColor xc; 394 XColor xc;
363 395
364 if (XParseColor (display->display, display->cmap, name, &xc)) 396 if (XParseColor (display->display, display->cmap, name, &xc))
365 return set (display, xc.red, xc.green, xc.blue); 397 return set (display, xc.red, xc.green, xc.blue);
366 398
367 return false; 399 return false;
400#endif
368} 401}
369 402
370bool 403bool
371rxvt_color::set (rxvt_display *display, unsigned short cr, unsigned short cg, unsigned short cb) 404rxvt_color::set (rxvt_display *display, unsigned short cr, unsigned short cg, unsigned short cb)
372{ 405{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines