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.12 by root, Mon Jan 17 00:59:24 2005 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 *
82 delete obj; 82 delete obj;
83 } 83 }
84} 84}
85 85
86template<class T> 86template<class T>
87refcache<T>::~refcache () 87void refcache<T>::clear ()
88{ 88{
89 while (this->size ()) 89 while (this->size ())
90 put (*this->begin ()); 90 put (*this->begin ());
91} 91}
92 92
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{
165 sockaddr_un sa; 166 sockaddr_un sa;
166 socklen_t sl = sizeof (sa); 167 socklen_t sl = sizeof (sa);
167 168
168 if (!getsockname (fd, (sockaddr *)&sa, &sl)) 169 if (!getsockname (fd, (sockaddr *)&sa, &sl))
169 is_local = sa.sun_family == AF_LOCAL; 170 is_local = sa.sun_family == AF_LOCAL;
171#endif
172
173#ifdef POINTER_BLANK
174 XColor blackcolour;
175 blackcolour.red = 0;
176 blackcolour.green = 0;
177 blackcolour.blue = 0;
178 Font f = XLoadFont (display, "fixed");
179 blank_cursor = XCreateGlyphCursor (display, f, f, ' ', ' ',
180 &blackcolour, &blackcolour);
181 XUnloadFont (display, f);
170#endif 182#endif
171 183
172#ifdef PREFER_24BIT 184#ifdef PREFER_24BIT
173 /* 185 /*
174 * If depth is not 24, look for a 24bit visual. 186 * If depth is not 24, look for a 24bit visual.
202} 214}
203 215
204rxvt_display::~rxvt_display () 216rxvt_display::~rxvt_display ()
205{ 217{
206 x_ev.stop (); 218 x_ev.stop ();
219#ifdef USE_XIM
220 xims.clear ();
221#endif
207 222
208 if (display) 223 if (display)
209 XCloseDisplay (display); 224 XCloseDisplay (display);
210} 225}
211 226
213void rxvt_display::im_change_cb () 228void rxvt_display::im_change_cb ()
214{ 229{
215 for (im_watcher **i = imw.begin (); i != imw.end (); ++i) 230 for (im_watcher **i = imw.begin (); i != imw.end (); ++i)
216 (*i)->call (); 231 (*i)->call ();
217} 232}
233
234void rxvt_display::im_change_check ()
235{
236 // make sure we only call im_change_cb when a new input method
237 // registers, as xlib crashes due to a race otherwise.
238 Atom actual_type, *atoms;
239 int actual_format;
240 unsigned long nitems, bytes_after;
241
242 if (XGetWindowProperty (display, root, xa_xim_servers, 0L, 1000000L,
243 False, XA_ATOM, &actual_type, &actual_format,
244 &nitems, &bytes_after, (unsigned char **)&atoms)
245 != Success )
246 return;
247
248 if (actual_type == XA_ATOM && actual_format == 32)
249 for (int i = 0; i < nitems; i++)
250 if (XGetSelectionOwner (display, atoms[i]))
251 {
252 im_change_cb ();
253 break;
254 }
255
256 XFree (atoms);
257}
218#endif 258#endif
219 259
220void rxvt_display::x_cb (io_watcher &w, short revents) 260void rxvt_display::x_cb (io_watcher &w, short revents)
221{ 261{
222 do 262 do
223 { 263 {
224 XEvent xev; 264 XEvent xev;
225 XNextEvent (display, &xev); 265 XNextEvent (display, &xev);
226 266
227 //printf ("T %d w %lx\n", xev.type, xev.xany.window);//D
228
229#ifdef USE_XIM 267#ifdef USE_XIM
230 if (xev.type == PropertyNotify 268 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 { 269 {
270
271 if (xev.type == PropertyNotify
272 && xev.xany.window == root
273 && xev.xproperty.atom == xa_xim_servers)
274 im_change_check ();
275#endif
276 for (int i = xw.size (); i--; )
277 {
238 if (!xw[i]) 278 if (!xw[i])
239 xw.erase_unordered (i); 279 xw.erase_unordered (i);
240 else if (xw[i]->window == xev.xany.window) 280 else if (xw[i]->window == xev.xany.window)
241 xw[i]->call (xev); 281 xw[i]->call (xev);
282 }
283#ifdef USE_XIM
242 } 284 }
285#endif
243 } 286 }
244 while (XPending (display)); 287 while (XEventsQueued (display, QueuedAlready));
245 288
246 flush (); 289 XFlush (display);
247} 290}
248 291
249void rxvt_display::flush () 292void rxvt_display::flush ()
250{ 293{
251 for (;;) 294 if (XEventsQueued (display, QueuedAlready))
252 { 295 x_cb (x_ev, EVENT_READ);
253 if (!XPending (display))
254 break;
255 296
256 x_cb (x_ev, 0); 297 XFlush (display);
257 }
258} 298}
259 299
260void rxvt_display::reg (xevent_watcher *w) 300void rxvt_display::reg (xevent_watcher *w)
261{ 301{
262 xw.push_back (w); 302 xw.push_back (w);
309 return xim; 349 return xim;
310} 350}
311 351
312void rxvt_display::put_xim (rxvt_xim *xim) 352void rxvt_display::put_xim (rxvt_xim *xim)
313{ 353{
354#if XLIB_IS_RACEFREE
314 xims.put (xim); 355 xims.put (xim);
356#endif
315} 357}
316#endif 358#endif
317 359
318Atom rxvt_display::atom (const char *name) 360Atom rxvt_display::atom (const char *name)
319{ 361{
357} 399}
358 400
359bool 401bool
360rxvt_color::set (rxvt_display *display, const char *name) 402rxvt_color::set (rxvt_display *display, const char *name)
361{ 403{
404#if XFT
405 return XftColorAllocName (display->display, display->visual, display->cmap,
406 name, &c);
407#else
362 XColor xc; 408 XColor xc;
363 409
364 if (XParseColor (display->display, display->cmap, name, &xc)) 410 if (XParseColor (display->display, display->cmap, name, &xc))
365 return set (display, xc.red, xc.green, xc.blue); 411 return set (display, xc.red, xc.green, xc.blue);
366 412
367 return false; 413 return false;
414#endif
368} 415}
369 416
370bool 417bool
371rxvt_color::set (rxvt_display *display, unsigned short cr, unsigned short cg, unsigned short cb) 418rxvt_color::set (rxvt_display *display, unsigned short cr, unsigned short cg, unsigned short cb)
372{ 419{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines