… | |
… | |
430 | bool rxvt_display::ref_init () |
430 | bool 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; |
… | |
… | |
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 |
… | |
… | |
668 | Atom rxvt_display::atom (const char *name) |
691 | Atom rxvt_display::atom (const char *name) |
669 | { |
692 | { |
670 | return XInternAtom (dpy, name, False); |
693 | return XInternAtom (dpy, name, False); |
671 | } |
694 | } |
672 | |
695 | |
|
|
696 | Pixmap |
|
|
697 | rxvt_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 | |
675 | template class refcache<rxvt_display>; |
720 | template class refcache<rxvt_display>; |
676 | refcache<rxvt_display> displays; |
721 | refcache<rxvt_display> displays; |
677 | |
722 | |
… | |
… | |
686 | |
731 | |
687 | bool |
732 | bool |
688 | rxvt_color::alloc (rxvt_screen *screen, const rgba &color) |
733 | rxvt_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; |
… | |
… | |
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 | |
756 | bool |
802 | bool |
… | |
… | |
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 | |
918 | void |
965 | void |
919 | rxvt_selection::stop () |
966 | rxvt_selection::stop () |
920 | { |
967 | { |
… | |
… | |
960 | } |
1007 | } |
961 | |
1008 | |
962 | void |
1009 | void |
963 | rxvt_selection::finish (char *data, unsigned int len) |
1010 | rxvt_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; |