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.1 by root, Sun Aug 15 00:37:04 2004 UTC vs.
Revision 1.8 by root, Wed Dec 15 05:30:40 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 *
32# include <sys/un.h> 32# include <sys/un.h>
33#endif 33#endif
34 34
35refcounted::refcounted (const char *id) 35refcounted::refcounted (const char *id)
36{ 36{
37 this->id = STRDUP (id); 37 this->id = strdup (id);
38} 38}
39 39
40refcounted::~refcounted () 40refcounted::~refcounted ()
41{ 41{
42 free (id); 42 free (id);
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 flush ();
247} 276}
248 277
249void rxvt_display::flush () 278void rxvt_display::flush ()
250{ 279{
251 for (;;) 280 XFlush (display);
252 {
253 if (!XPending (display))
254 break;
255
256 x_cb (x_ev, 0);
257 }
258} 281}
259 282
260void rxvt_display::reg (xevent_watcher *w) 283void rxvt_display::reg (xevent_watcher *w)
261{ 284{
262 xw.push_back (w); 285 xw.push_back (w);
357} 380}
358 381
359bool 382bool
360rxvt_color::set (rxvt_display *display, const char *name) 383rxvt_color::set (rxvt_display *display, const char *name)
361{ 384{
385#if XFT
386 return XftColorAllocName (display->display, display->visual, display->cmap,
387 name, &c);
388#else
362 XColor xc; 389 XColor xc;
363 390
364 if (XParseColor (display->display, display->cmap, name, &xc)) 391 if (XParseColor (display->display, display->cmap, name, &xc))
365 return set (display, xc.red, xc.green, xc.blue); 392 return set (display, xc.red, xc.green, xc.blue);
366 393
367 return false; 394 return false;
395#endif
368} 396}
369 397
370bool 398bool
371rxvt_color::set (rxvt_display *display, unsigned short cr, unsigned short cg, unsigned short cb) 399rxvt_color::set (rxvt_display *display, unsigned short cr, unsigned short cg, unsigned short cb)
372{ 400{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines