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.126 by sf-exg, Wed May 25 08:55:52 2011 UTC vs.
Revision 1.133 by sf-exg, Sun Jun 3 17:48:28 2012 UTC

430bool rxvt_display::ref_init () 430bool rxvt_display::ref_init ()
431{ 431{
432#ifdef LOCAL_X_IS_UNIX 432#ifdef LOCAL_X_IS_UNIX
433 if (id[0] == ':') 433 if (id[0] == ':')
434 { 434 {
435 if (!(val = rxvt_temp_buf<char> (5 + strlen (id) + 1))) 435 char *val = rxvt_temp_buf<char> (5 + strlen (id) + 1);
436 return false; 436
437 strcpy (val, "unix/"); 437 strcpy (val, "unix/");
438 strcat (val, id); 438 strcat (val, id);
439
439 dpy = XOpenDisplay (val); 440 dpy = XOpenDisplay (val);
440 } 441 }
441 else 442 else
442#endif 443#endif
443 dpy = 0; 444 dpy = 0;
449 return false; 450 return false;
450 451
451 screen = DefaultScreen (dpy); 452 screen = DefaultScreen (dpy);
452 root = DefaultRootWindow (dpy); 453 root = DefaultRootWindow (dpy);
453 454
454 assert (ARRAY_LENGTH(xa_names) == NUM_XA); 455 assert (ecb_array_length (xa_names) == NUM_XA);
455 XInternAtoms (dpy, (char **)xa_names, NUM_XA, False, xa); 456 XInternAtoms (dpy, (char **)xa_names, NUM_XA, False, xa);
456 457
457 XrmSetDatabase (dpy, get_resources (false)); 458 XrmSetDatabase (dpy, get_resources (false));
458 459
459#ifdef POINTER_BLANK 460#ifdef POINTER_BLANK
465 blank_cursor = XCreateGlyphCursor (dpy, f, f, ' ', ' ', 466 blank_cursor = XCreateGlyphCursor (dpy, f, f, ' ', ' ',
466 &blackcolour, &blackcolour); 467 &blackcolour, &blackcolour);
467 XUnloadFont (dpy, f); 468 XUnloadFont (dpy, f);
468#endif 469#endif
469 470
471 flags = 0;
472#if XRENDER
473 int major, minor;
474 if (XRenderQueryVersion (dpy, &major, &minor))
475 {
476 flags |= DISPLAY_HAS_RENDER;
477
478 if (major > 0 || (major == 0 && minor >= 11))
479 flags |= DISPLAY_HAS_RENDER_MUL;
480
481 XFilters *filters = XRenderQueryFilters (dpy, root);
482 if (filters)
483 {
484 for (int i = 0; i < filters->nfilter; i++)
485 if (!strcmp (filters->filter[i], FilterConvolution))
486 flags |= DISPLAY_HAS_RENDER_CONV;
487
488 XFree (filters);
489 }
490 }
491#endif
492
470 int fd = XConnectionNumber (dpy); 493 int fd = XConnectionNumber (dpy);
471 494
472 // try to detect whether we have a local connection. 495 // try to detect whether we have a local connection.
473 // assume unix domain socket == local, everything else not 496 // assume unix domain socket == local, everything else not
474 // TODO: might want to check for inet/127.0.0.1 497 // TODO: might want to check for inet/127.0.0.1
668Atom rxvt_display::atom (const char *name) 691Atom rxvt_display::atom (const char *name)
669{ 692{
670 return XInternAtom (dpy, name, False); 693 return XInternAtom (dpy, name, False);
671} 694}
672 695
696Pixmap
697rxvt_display::get_pixmap_property (Atom property)
698{
699 Pixmap pixmap = None;
700
701 int aformat;
702 unsigned long nitems, bytes_after;
703 Atom atype;
704 unsigned char *prop;
705 int result = XGetWindowProperty (dpy, root, property,
706 0L, 1L, False, XA_PIXMAP, &atype, &aformat,
707 &nitems, &bytes_after, &prop);
708 if (result == Success)
709 {
710 if (atype == XA_PIXMAP)
711 pixmap = *(Pixmap *)prop;
712 XFree (prop);
713 }
714
715 return pixmap;
716}
717
673///////////////////////////////////////////////////////////////////////////// 718/////////////////////////////////////////////////////////////////////////////
674 719
675template class refcache<rxvt_display>; 720template class refcache<rxvt_display>;
676refcache<rxvt_display> displays; 721refcache<rxvt_display> displays;
677 722
686 731
687bool 732bool
688rxvt_color::alloc (rxvt_screen *screen, const rgba &color) 733rxvt_color::alloc (rxvt_screen *screen, const rgba &color)
689{ 734{
690 //TODO: only supports 24 bit 735 //TODO: only supports 24 bit
691 int alpha = color.a >= 0xff00 ? 0xffff : color.a; 736 unsigned int alpha = color.a >= 0xff00 ? 0xffff : color.a;
692 737
693#if XFT 738#if XFT
694 XRenderPictFormat *format; 739 XRenderPictFormat *format;
695 740
696 // FUCKING Xft gets it wrong, of course, so work around it. 741 // FUCKING Xft gets it wrong, of course, so work around it.
725 d.red = color.r; 770 d.red = color.r;
726 d.green = color.g; 771 d.green = color.g;
727 d.blue = color.b; 772 d.blue = color.b;
728 d.alpha = alpha; 773 d.alpha = alpha;
729 774
730 return XftColorAllocValue (screen->dpy, screen->visual, screen->cmap, &d, &c); 775 if (XftColorAllocValue (screen->dpy, screen->visual, screen->cmap, &d, &c))
776 return true;
731 } 777 }
732#else 778#else
733 c.red = color.r; 779 c.red = color.r;
734 c.green = color.g; 780 c.green = color.g;
735 c.blue = color.b; 781 c.blue = color.b;
736 782
737 if (screen->visual->c_class == TrueColor) 783 if (screen->visual->c_class == TrueColor)
738 { 784 {
739 c.pixel = (color.r >> (16 - rxvt_popcount (screen->visual->red_mask )) << rxvt_ctz (screen->visual->red_mask )) 785 c.pixel = (color.r >> (16 - ecb_popcount32 (screen->visual->red_mask )) << ecb_ctz32 (screen->visual->red_mask ))
740 | (color.g >> (16 - rxvt_popcount (screen->visual->green_mask)) << rxvt_ctz (screen->visual->green_mask)) 786 | (color.g >> (16 - ecb_popcount32 (screen->visual->green_mask)) << ecb_ctz32 (screen->visual->green_mask))
741 | (color.b >> (16 - rxvt_popcount (screen->visual->blue_mask )) << rxvt_ctz (screen->visual->blue_mask )); 787 | (color.b >> (16 - ecb_popcount32 (screen->visual->blue_mask )) << ecb_ctz32 (screen->visual->blue_mask ));
742 788
743 return true; 789 return true;
744 } 790 }
745 else if (XAllocColor (screen->dpy, screen->cmap, &c)) 791 else if (XAllocColor (screen->dpy, screen->cmap, &c))
746 return true; 792 return true;
747 else 793#endif
794
748 c.pixel = (color.r + color.g + color.b) > 128*3 795 c.pixel = (color.r + color.g + color.b) > 128*3
749 ? WhitePixelOfScreen (DefaultScreenOfDisplay (screen->dpy)) 796 ? WhitePixelOfScreen (DefaultScreenOfDisplay (screen->dpy))
750 : BlackPixelOfScreen (DefaultScreenOfDisplay (screen->dpy)); 797 : BlackPixelOfScreen (DefaultScreenOfDisplay (screen->dpy));
751#endif
752 798
753 return false; 799 return false;
754} 800}
755 801
756bool 802bool
911 957
912 incr_buf = 0; 958 incr_buf = 0;
913 incr_buf_size = incr_buf_fill = 0; 959 incr_buf_size = incr_buf_fill = 0;
914 selection_wait = Sel_normal; 960 selection_wait = Sel_normal;
915 selection_type = selnum; 961 selection_type = selnum;
962 cb_sv = 0;
916} 963}
917 964
918void 965void
919rxvt_selection::stop () 966rxvt_selection::stop ()
920{ 967{
960} 1007}
961 1008
962void 1009void
963rxvt_selection::finish (char *data, unsigned int len) 1010rxvt_selection::finish (char *data, unsigned int len)
964{ 1011{
965 if (term) 1012 if (!cb_sv)
966 { 1013 {
967 if (data) 1014 if (data)
968 term->paste (data, len); 1015 term->paste (data, len);
969 1016
970 term->selection_req = 0; 1017 term->selection_req = 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines