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.103 by root, Fri Sep 4 15:40:13 2009 UTC vs.
Revision 1.113 by sf-exg, Fri Jan 14 11:09:54 2011 UTC

33 33
34#if XFT 34#if XFT
35# include <X11/extensions/Xrender.h> 35# include <X11/extensions/Xrender.h>
36#endif 36#endif
37 37
38const char *const xa_names[] = 38static const char *const xa_names[] =
39{ 39{
40 "TEXT", 40 "TEXT",
41 "COMPOUND_TEXT", 41 "COMPOUND_TEXT",
42 "UTF8_STRING", 42 "UTF8_STRING",
43 "MULTIPLE", 43 "MULTIPLE",
227{ 227{
228} 228}
229 229
230rxvt_drawable &rxvt_screen::scratch_drawable (int w, int h) 230rxvt_drawable &rxvt_screen::scratch_drawable (int w, int h)
231{ 231{
232 // it's actually faster to re-allocate every time. don't ask me
233 // why, but its likely no big deal there are no roundtrips
234 // (I think/hope).
235 if (!scratch_area || w > scratch_w || h > scratch_h || 1/*D*/) 232 if (!scratch_area || w > scratch_w || h > scratch_h)
236 { 233 {
237 if (scratch_area) 234 if (scratch_area)
238 { 235 {
239 XFreePixmap (dpy, scratch_area->drawable); 236 XFreePixmap (dpy, scratch_area->drawable);
240 delete scratch_area; 237 delete scratch_area;
297///////////////////////////////////////////////////////////////////////////// 294/////////////////////////////////////////////////////////////////////////////
298 295
299rxvt_display::rxvt_display (const char *id) 296rxvt_display::rxvt_display (const char *id)
300: refcounted (id) 297: refcounted (id)
301, selection_owner (0) 298, selection_owner (0)
299, clipboard_owner (0)
302{ 300{
303 x_ev .set<rxvt_display, &rxvt_display::x_cb > (this); 301 x_ev .set<rxvt_display, &rxvt_display::x_cb > (this);
304 flush_ev.set<rxvt_display, &rxvt_display::flush_cb> (this); 302 flush_ev.set<rxvt_display, &rxvt_display::flush_cb> (this);
305} 303}
306 304
361 XA_STRING, &actual_type, &actual_format, 359 XA_STRING, &actual_type, &actual_format,
362 &nitems, &nremaining, 360 &nitems, &nremaining,
363 (unsigned char **)&val) == Success 361 (unsigned char **)&val) == Success
364 && actual_type == XA_STRING 362 && actual_type == XA_STRING
365 && actual_format == 8) 363 && actual_format == 8)
366 displayResource = val; 364 displayResource = val;
367 else 365 else
368 { 366 {
369 displayResource = 0; 367 displayResource = 0;
370 368
371 if (val) 369 if (val)
372 XFree(val); 370 XFree (val);
373 } 371 }
374 372
375#if XLIB_ILLEGAL_ACCESS 373#if XLIB_ILLEGAL_ACCESS
376 dpy->xdefaults = displayResource; 374 dpy->xdefaults = displayResource;
377#endif 375#endif
378 } 376 }
426bool rxvt_display::ref_init () 424bool rxvt_display::ref_init ()
427{ 425{
428#ifdef LOCAL_X_IS_UNIX 426#ifdef LOCAL_X_IS_UNIX
429 if (id[0] == ':') 427 if (id[0] == ':')
430 { 428 {
431 val = rxvt_malloc (5 + strlen (id) + 1); 429 if (!(val = rxvt_temp_buf<char> (5 + strlen (id) + 1)))
430 return false;
432 strcpy (val, "unix/"); 431 strcpy (val, "unix/");
433 strcat (val, id); 432 strcat (val, id);
434 dpy = XOpenDisplay (val); 433 dpy = XOpenDisplay (val);
435 free (val);
436 } 434 }
437 else 435 else
438#endif 436#endif
439 dpy = 0; 437 dpy = 0;
440 438
445 return false; 443 return false;
446 444
447 screen = DefaultScreen (dpy); 445 screen = DefaultScreen (dpy);
448 root = DefaultRootWindow (dpy); 446 root = DefaultRootWindow (dpy);
449 447
450 assert (sizeof (xa_names) / sizeof (char *) == NUM_XA); 448 assert (ARRAY_LENGTH(xa_names) == NUM_XA);
451 XInternAtoms (dpy, (char **)xa_names, NUM_XA, False, xa); 449 XInternAtoms (dpy, (char **)xa_names, NUM_XA, False, xa);
452 450
453 XrmSetDatabase (dpy, get_resources (false)); 451 XrmSetDatabase (dpy, get_resources (false));
454 452
455#ifdef POINTER_BLANK 453#ifdef POINTER_BLANK
463 XUnloadFont (dpy, f); 461 XUnloadFont (dpy, f);
464#endif 462#endif
465 463
466 int fd = XConnectionNumber (dpy); 464 int fd = XConnectionNumber (dpy);
467 465
468 // try to detect wether we have a local connection. 466 // try to detect whether we have a local connection.
469 // assume unix domain socket == local, everything else not 467 // assume unix domain socket == local, everything else not
470 // TODO: might want to check for inet/127.0.0.1 468 // TODO: might want to check for inet/127.0.0.1
471 is_local = 0; 469 is_local = 0;
472 sockaddr_un sa; 470 sockaddr_un sa;
473 socklen_t sl = sizeof (sa); 471 socklen_t sl = sizeof (sa);
487} 485}
488 486
489void 487void
490rxvt_display::ref_next () 488rxvt_display::ref_next ()
491{ 489{
492 // TODO: somehow check wether the database files/resources changed 490 // TODO: somehow check whether the database files/resources changed
493 // before affording re-loading/parsing 491 // before affording re-loading/parsing
494 XrmDestroyDatabase (XrmGetDatabase (dpy)); 492 XrmDestroyDatabase (XrmGetDatabase (dpy));
495 XrmSetDatabase (dpy, get_resources (true)); 493 XrmSetDatabase (dpy, get_resources (true));
496} 494}
497 495
506 x_ev.stop (); 504 x_ev.stop ();
507 flush_ev.stop (); 505 flush_ev.stop ();
508#ifdef USE_XIM 506#ifdef USE_XIM
509 xims.clear (); 507 xims.clear ();
510#endif 508#endif
509 XrmDestroyDatabase (XrmGetDatabase (dpy));
511 XCloseDisplay (dpy); 510 XCloseDisplay (dpy);
512} 511}
513 512
514#ifdef USE_XIM 513#ifdef USE_XIM
515void rxvt_display::im_change_cb () 514void rxvt_display::im_change_cb ()
527 unsigned long nitems, bytes_after; 526 unsigned long nitems, bytes_after;
528 527
529 if (XGetWindowProperty (dpy, root, xa[XA_XIM_SERVERS], 0L, 1000000L, 528 if (XGetWindowProperty (dpy, root, xa[XA_XIM_SERVERS], 0L, 1000000L,
530 False, XA_ATOM, &actual_type, &actual_format, 529 False, XA_ATOM, &actual_type, &actual_format,
531 &nitems, &bytes_after, (unsigned char **)&atoms) 530 &nitems, &bytes_after, (unsigned char **)&atoms)
532 != Success ) 531 != Success)
533 return; 532 return;
534 533
535 if (actual_type == XA_ATOM && actual_format == 32) 534 if (actual_type == XA_ATOM && actual_format == 32)
536 for (int i = 0; i < nitems; i++) 535 for (int i = 0; i < nitems; i++)
537 if (XGetSelectionOwner (dpy, atoms[i])) 536 if (XGetSelectionOwner (dpy, atoms[i]))
538 { 537 {
539 im_change_cb (); 538 im_change_cb ();
540 break; 539 break;
600 xw[w->active - 1] = 0; 599 xw[w->active - 1] = 0;
601 w->active = 0; 600 w->active = 0;
602 } 601 }
603} 602}
604 603
605void rxvt_display::set_selection_owner (rxvt_term *owner) 604void rxvt_display::set_selection_owner (rxvt_term *owner, bool clipboard)
606{ 605{
606 rxvt_term * &cur_owner = !clipboard ? selection_owner : clipboard_owner;
607
607 if (selection_owner && selection_owner != owner) 608 if (cur_owner && cur_owner != owner)
608 { 609 {
609 rxvt_term *owner = selection_owner; 610 rxvt_term *term = cur_owner;
610
611 owner->selection_clear (); 611 term->selection_clear (clipboard);
612 owner->flush (); 612 term->flush ();
613 } 613 }
614 614
615 selection_owner = owner; 615 cur_owner = owner;
616} 616}
617 617
618#ifdef USE_XIM 618#ifdef USE_XIM
619 619
620void rxvt_display::reg (im_watcher *w) 620void rxvt_display::reg (im_watcher *w)
633 int l, m; 633 int l, m;
634 634
635 l = strlen (locale); 635 l = strlen (locale);
636 m = strlen (modifiers); 636 m = strlen (modifiers);
637 637
638 if (!(id = (char *)malloc (l + m + 2))) 638 if (!(id = rxvt_temp_buf<char> (l + m + 2)))
639 return 0; 639 return 0;
640 640
641 memcpy (id, locale, l); id[l] = '\n'; 641 memcpy (id, locale, l); id[l] = '\n';
642 memcpy (id + l + 1, modifiers, m); id[l + m + 1] = 0; 642 memcpy (id + l + 1, modifiers, m); id[l + m + 1] = 0;
643 643
644 rxvt_xim *xim = xims.get (id); 644 rxvt_xim *xim = xims.get (id);
645
646 free (id);
647 645
648 return xim; 646 return xim;
649} 647}
650 648
651void rxvt_display::put_xim (rxvt_xim *xim) 649void rxvt_display::put_xim (rxvt_xim *xim)
884 lerp (c.a, to.a, percent) 882 lerp (c.a, to.a, percent)
885 ) 883 )
886 ); 884 );
887} 885}
888 886
889#if TRACE_PIXMAPS
890# undef XCreatePixmap
891# undef XFreePixmap
892Pixmap trace_XCreatePixmap (const char *file, int line, Display *dpy, Window r, unsigned int w, unsigned int h, unsigned int d)
893{
894 Pixmap res = XCreatePixmap (dpy, r, w, h, d);
895 fprintf (stderr, "%s:%d: XCreatePixmap (%p,%lX,%u,%u,%u) returned %lX\n", file, line, dpy, r, w, h, d, res);
896 return res;
897}
898
899void trace_XFreePixmap (const char *file, int line, Display *dpy, Pixmap p)
900{
901 fprintf (stderr, "%s:%d: XFreePixmap (%p,%lX)\n", file, line, dpy, p);
902 XFreePixmap (dpy,p);
903}
904#endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines