… | |
… | |
58 | # endif |
58 | # endif |
59 | |
59 | |
60 | void |
60 | void |
61 | rxvt_term::bg_destroy () |
61 | rxvt_term::bg_destroy () |
62 | { |
62 | { |
|
|
63 | # if BG_IMAGE_FROM_FILE |
|
|
64 | fimage.destroy (); |
|
|
65 | # endif |
|
|
66 | |
63 | if (bg_pixmap) |
67 | if (bg_pixmap) |
64 | XFreePixmap (dpy, bg_pixmap); |
68 | XFreePixmap (dpy, bg_pixmap); |
65 | } |
69 | } |
66 | |
70 | |
67 | bool |
71 | bool |
… | |
… | |
79 | } |
83 | } |
80 | |
84 | |
81 | bool |
85 | bool |
82 | rxvt_term::bg_window_size_sensitive () |
86 | rxvt_term::bg_window_size_sensitive () |
83 | { |
87 | { |
84 | # ifdef ENABLE_TRANSPARENCY |
88 | # if ENABLE_TRANSPARENCY |
85 | if (bg_flags & BG_IS_TRANSPARENT) |
89 | if (bg_flags & BG_IS_TRANSPARENT) |
86 | return true; |
90 | return true; |
87 | # endif |
91 | # endif |
88 | |
92 | |
89 | # ifdef BG_IMAGE_FROM_FILE |
93 | # if BG_IMAGE_FROM_FILE |
90 | if (bg_image.flags & IM_IS_SET) |
94 | if (fimage.flags & IM_IS_SET) |
91 | { |
95 | { |
92 | if ((bg_image.flags & IM_IS_SIZE_SENSITIVE) |
96 | if ((fimage.flags & IM_IS_SIZE_SENSITIVE) |
93 | || bg_image.width () > szHint.width |
97 | || fimage.width () > szHint.width |
94 | || bg_image.height () > szHint.height) |
98 | || fimage.height () > szHint.height) |
95 | return true; |
99 | return true; |
96 | } |
100 | } |
97 | # endif |
101 | # endif |
98 | |
102 | |
99 | return false; |
103 | return false; |
100 | } |
104 | } |
101 | |
105 | |
102 | bool |
106 | bool |
103 | rxvt_term::bg_window_position_sensitive () |
107 | rxvt_term::bg_window_position_sensitive () |
104 | { |
108 | { |
105 | # ifdef ENABLE_TRANSPARENCY |
109 | # if ENABLE_TRANSPARENCY |
106 | if (bg_flags & BG_IS_TRANSPARENT) |
110 | if (bg_flags & BG_IS_TRANSPARENT) |
107 | return true; |
111 | return true; |
108 | # endif |
112 | # endif |
109 | |
113 | |
110 | # ifdef BG_IMAGE_FROM_FILE |
114 | # if BG_IMAGE_FROM_FILE |
111 | if (bg_image.flags & IM_IS_SET) |
115 | if (fimage.flags & IM_IS_SET) |
112 | { |
116 | { |
113 | if (bg_image.flags & IM_ROOT_ALIGN) |
117 | if (fimage.flags & IM_ROOT_ALIGN) |
114 | return true; |
118 | return true; |
115 | } |
119 | } |
116 | # endif |
120 | # endif |
117 | |
121 | |
118 | return false; |
122 | return false; |
119 | } |
123 | } |
120 | |
124 | |
121 | # ifdef BG_IMAGE_FROM_FILE |
125 | # if BG_IMAGE_FROM_FILE |
122 | static inline int |
126 | static inline int |
123 | make_align_position (int align, int window_size, int image_size) |
127 | make_align_position (int align, int window_size, int image_size) |
124 | { |
128 | { |
125 | if (align >= 0 && align <= 100) |
129 | if (align >= 0 && align <= 100) |
126 | return lerp (0, window_size - image_size, align); |
130 | return lerp (0, window_size - image_size, align); |
… | |
… | |
298 | h_align = x; |
302 | h_align = x; |
299 | v_align = y; |
303 | v_align = y; |
300 | changed = true; |
304 | changed = true; |
301 | } |
305 | } |
302 | |
306 | |
303 | if (!(flags & IM_TILE) |
307 | if (is_size_sensitive ()) |
304 | || h_scale || v_scale |
|
|
305 | || (!(flags & IM_ROOT_ALIGN) && (h_align || v_align))) |
|
|
306 | flags |= IM_IS_SIZE_SENSITIVE; |
308 | flags |= IM_IS_SIZE_SENSITIVE; |
307 | else |
309 | else |
308 | flags &= ~IM_IS_SIZE_SENSITIVE; |
310 | flags &= ~IM_IS_SIZE_SENSITIVE; |
309 | |
311 | |
310 | return changed; |
312 | return changed; |
… | |
… | |
344 | x = make_align_position (image.h_align, target_width, w); |
346 | x = make_align_position (image.h_align, target_width, w); |
345 | y = make_align_position (image.v_align, target_height, h); |
347 | y = make_align_position (image.v_align, target_height, h); |
346 | } |
348 | } |
347 | } |
349 | } |
348 | |
350 | |
349 | # ifdef HAVE_PIXBUF |
351 | # if HAVE_PIXBUF |
350 | bool |
352 | bool |
351 | rxvt_term::pixbuf_to_pixmap (GdkPixbuf *pixbuf, Pixmap pixmap, GC gc, |
353 | rxvt_term::pixbuf_to_pixmap (GdkPixbuf *pixbuf, Pixmap pixmap, GC gc, |
352 | int src_x, int src_y, int dst_x, int dst_y, |
354 | int src_x, int src_y, int dst_x, int dst_y, |
353 | unsigned int width, unsigned int height, bool argb) |
355 | unsigned int width, unsigned int height, bool argb) |
354 | { |
356 | { |
… | |
… | |
481 | return false; |
483 | return false; |
482 | |
484 | |
483 | bool need_blend = bg_flags & BG_IS_VALID; |
485 | bool need_blend = bg_flags & BG_IS_VALID; |
484 | |
486 | |
485 | if (need_blend |
487 | if (need_blend |
486 | && !(bg_flags & BG_HAS_RENDER)) |
488 | && !(display->flags & DISPLAY_HAS_RENDER)) |
487 | return false; |
489 | return false; |
488 | |
490 | |
489 | GdkPixbuf *result; |
491 | GdkPixbuf *result; |
490 | |
492 | |
491 | int image_width = gdk_pixbuf_get_width (pixbuf); |
493 | int image_width = gdk_pixbuf_get_width (pixbuf); |
… | |
… | |
596 | src_x, src_y, |
598 | src_x, src_y, |
597 | dst_x, dst_y, |
599 | dst_x, dst_y, |
598 | dst_width, dst_height, need_blend); |
600 | dst_width, dst_height, need_blend); |
599 | } |
601 | } |
600 | |
602 | |
|
|
603 | if (image.need_blur ()) |
|
|
604 | blur_pixmap (tmp_pixmap, new_pmap_width, new_pmap_height, need_blend, image.h_blurRadius, image.v_blurRadius); |
|
|
605 | if (image.need_tint ()) |
|
|
606 | tint_pixmap (tmp_pixmap, new_pmap_width, new_pmap_height, need_blend, image.tint, image.tint_set, image.shade); |
|
|
607 | |
601 | #if XRENDER |
608 | #if XRENDER |
602 | if (need_blend) |
609 | if (need_blend) |
603 | { |
610 | { |
604 | XRenderPictFormat *argb_format = XRenderFindStandardFormat (dpy, PictStandardARGB32); |
611 | XRenderPictFormat *argb_format = XRenderFindStandardFormat (dpy, PictStandardARGB32); |
605 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
612 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
… | |
… | |
610 | |
617 | |
611 | Picture mask = create_xrender_mask (dpy, vt, False, False); |
618 | Picture mask = create_xrender_mask (dpy, vt, False, False); |
612 | |
619 | |
613 | XRenderColor mask_c; |
620 | XRenderColor mask_c; |
614 | |
621 | |
615 | mask_c.alpha = 0x8000; |
622 | mask_c.alpha = image.alpha; |
616 | mask_c.red = |
623 | mask_c.red = |
617 | mask_c.green = |
624 | mask_c.green = |
618 | mask_c.blue = 0; |
625 | mask_c.blue = 0; |
619 | XRenderFillRectangle (dpy, PictOpSrc, mask, &mask_c, 0, 0, 1, 1); |
626 | XRenderFillRectangle (dpy, PictOpSrc, mask, &mask_c, 0, 0, 1, 1); |
620 | |
627 | |
… | |
… | |
639 | |
646 | |
640 | return ret; |
647 | return ret; |
641 | } |
648 | } |
642 | # endif /* HAVE_PIXBUF */ |
649 | # endif /* HAVE_PIXBUF */ |
643 | |
650 | |
|
|
651 | rxvt_image::rxvt_image () |
|
|
652 | { |
|
|
653 | alpha = 0xffff; |
|
|
654 | flags = 0; |
|
|
655 | h_scale = |
|
|
656 | v_scale = defaultScale; |
|
|
657 | h_align = |
|
|
658 | v_align = defaultAlign; |
|
|
659 | |
|
|
660 | # if HAVE_PIXBUF |
|
|
661 | pixbuf = 0; |
|
|
662 | # endif |
|
|
663 | } |
|
|
664 | |
644 | bool |
665 | bool |
645 | rxvt_image::set_file (const char *file) |
666 | rxvt_image::set_file_geometry (const char *file) |
646 | { |
667 | { |
647 | if (!file || !*file) |
668 | if (!file || !*file) |
648 | return false; |
669 | return false; |
649 | |
670 | |
650 | bool ret = false; |
|
|
651 | const char *p = strchr (file, ';'); |
671 | const char *p = strchr (file, ';'); |
652 | |
672 | |
653 | if (p) |
673 | if (p) |
654 | { |
674 | { |
655 | size_t len = p - file; |
675 | size_t len = p - file; |
… | |
… | |
657 | memcpy (f, file, len); |
677 | memcpy (f, file, len); |
658 | f[len] = '\0'; |
678 | f[len] = '\0'; |
659 | file = f; |
679 | file = f; |
660 | } |
680 | } |
661 | |
681 | |
|
|
682 | bool ret = set_file (file); |
|
|
683 | alpha = 0x8000; |
|
|
684 | if (ret) |
|
|
685 | set_geometry (p ? p + 1 : ""); |
|
|
686 | return ret; |
|
|
687 | } |
|
|
688 | |
|
|
689 | bool |
|
|
690 | rxvt_image::set_file (const char *file) |
|
|
691 | { |
|
|
692 | bool ret = false; |
|
|
693 | |
662 | # ifdef HAVE_PIXBUF |
694 | # if HAVE_PIXBUF |
663 | GdkPixbuf *image = gdk_pixbuf_new_from_file (file, NULL); |
695 | GdkPixbuf *image = gdk_pixbuf_new_from_file (file, NULL); |
664 | if (image) |
696 | if (image) |
665 | { |
697 | { |
666 | if (pixbuf) |
698 | if (pixbuf) |
667 | g_object_unref (pixbuf); |
699 | g_object_unref (pixbuf); |
… | |
… | |
669 | ret = true; |
701 | ret = true; |
670 | } |
702 | } |
671 | # endif |
703 | # endif |
672 | |
704 | |
673 | if (ret) |
705 | if (ret) |
674 | { |
706 | flags |= IM_IS_SET; |
675 | flags = IM_IS_SET | IM_IS_SIZE_SENSITIVE; |
|
|
676 | h_scale = v_scale = defaultScale; |
|
|
677 | h_align = v_align = defaultAlign; |
|
|
678 | |
|
|
679 | if (p) |
|
|
680 | set_geometry (p + 1); |
|
|
681 | } |
|
|
682 | |
707 | |
683 | return ret; |
708 | return ret; |
684 | } |
709 | } |
685 | |
710 | |
686 | # endif /* BG_IMAGE_FROM_FILE */ |
711 | # endif /* BG_IMAGE_FROM_FILE */ |
687 | |
712 | |
688 | # ifdef ENABLE_TRANSPARENCY |
|
|
689 | bool |
713 | bool |
690 | rxvt_term::bg_set_blur (const char *geom) |
714 | image_effects::set_blur (const char *geom) |
691 | { |
715 | { |
692 | bool changed = false; |
716 | bool changed = false; |
693 | unsigned int hr, vr; |
717 | unsigned int hr, vr; |
694 | int junk; |
718 | int junk; |
695 | int geom_flags = XParseGeometry (geom, &junk, &junk, &hr, &vr); |
719 | int geom_flags = XParseGeometry (geom, &junk, &junk, &hr, &vr); |
… | |
… | |
716 | |
740 | |
717 | return changed; |
741 | return changed; |
718 | } |
742 | } |
719 | |
743 | |
720 | bool |
744 | bool |
721 | rxvt_term::bg_set_tint (rxvt_color &new_tint) |
745 | image_effects::set_tint (const rxvt_color &new_tint) |
722 | { |
746 | { |
723 | if (!(bg_flags & BG_TINT_SET) || tint != new_tint) |
747 | if (!tint_set || tint != new_tint) |
724 | { |
748 | { |
725 | tint = new_tint; |
749 | tint = new_tint; |
726 | bg_flags |= BG_TINT_SET; |
750 | tint_set = true; |
727 | |
|
|
728 | rgba c; |
|
|
729 | tint.get (c); |
|
|
730 | if ((c.r <= 0x00ff || c.r >= 0xff00) |
|
|
731 | && (c.g <= 0x00ff || c.g >= 0xff00) |
|
|
732 | && (c.b <= 0x00ff || c.b >= 0xff00)) |
|
|
733 | bg_flags |= BG_TINT_BITAND; |
|
|
734 | else |
|
|
735 | bg_flags &= ~BG_TINT_BITAND; |
|
|
736 | |
751 | |
737 | return true; |
752 | return true; |
738 | } |
753 | } |
739 | |
754 | |
740 | return false; |
755 | return false; |
741 | } |
756 | } |
742 | |
757 | |
743 | bool |
758 | bool |
744 | rxvt_term::bg_set_shade (const char *shade_str) |
759 | image_effects::set_shade (const char *shade_str) |
745 | { |
760 | { |
746 | int new_shade = atoi (shade_str); |
761 | int new_shade = atoi (shade_str); |
747 | |
762 | |
748 | clamp_it (new_shade, -100, 200); |
763 | clamp_it (new_shade, -100, 200); |
749 | if (new_shade < 0) |
764 | if (new_shade < 0) |
… | |
… | |
780 | params[i+2] = XDoubleToFixed (kernel[i] / sum); |
795 | params[i+2] = XDoubleToFixed (kernel[i] / sum); |
781 | } |
796 | } |
782 | #endif |
797 | #endif |
783 | |
798 | |
784 | bool |
799 | bool |
785 | rxvt_term::blur_pixmap (Pixmap pixmap, int width, int height) |
800 | rxvt_term::blur_pixmap (Pixmap pixmap, int width, int height, bool argb, int h_blurRadius, int v_blurRadius) |
786 | { |
801 | { |
787 | bool ret = false; |
802 | bool ret = false; |
788 | #if XRENDER |
803 | #if XRENDER |
789 | if (!(bg_flags & BG_HAS_RENDER_CONV)) |
804 | if (!(display->flags & DISPLAY_HAS_RENDER_CONV)) |
790 | return false; |
805 | return false; |
791 | |
806 | |
792 | int size = max (h_blurRadius, v_blurRadius) * 2 + 1; |
807 | int size = max (h_blurRadius, v_blurRadius) * 2 + 1; |
793 | double *kernel = (double *)malloc (size * sizeof (double)); |
808 | double *kernel = (double *)malloc (size * sizeof (double)); |
794 | XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed)); |
809 | XFixed *params = (XFixed *)malloc ((size + 2) * sizeof (XFixed)); |
795 | |
810 | |
796 | XRenderPictureAttributes pa; |
811 | XRenderPictureAttributes pa; |
797 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
812 | XRenderPictFormat *format = argb ? XRenderFindStandardFormat (dpy, PictStandardARGB32) |
|
|
813 | : XRenderFindVisualFormat (dpy, visual); |
798 | |
814 | |
799 | pa.repeat = RepeatPad; |
815 | pa.repeat = RepeatPad; |
800 | Picture src = XRenderCreatePicture (dpy, pixmap, format, CPRepeat, &pa); |
816 | Picture src = XRenderCreatePicture (dpy, pixmap, format, CPRepeat, &pa); |
801 | Pixmap tmp = XCreatePixmap (dpy, pixmap, width, height, depth); |
817 | Pixmap tmp = XCreatePixmap (dpy, pixmap, width, height, depth); |
802 | Picture dst = XRenderCreatePicture (dpy, tmp, format, CPRepeat, &pa); |
818 | Picture dst = XRenderCreatePicture (dpy, tmp, format, CPRepeat, &pa); |
… | |
… | |
845 | #endif |
861 | #endif |
846 | return ret; |
862 | return ret; |
847 | } |
863 | } |
848 | |
864 | |
849 | bool |
865 | bool |
850 | rxvt_term::tint_pixmap (Pixmap pixmap, int width, int height) |
866 | rxvt_term::tint_pixmap (Pixmap pixmap, int width, int height, bool argb, rxvt_color &tint, bool tint_set, int shade) |
851 | { |
867 | { |
852 | bool ret = false; |
868 | bool ret = false; |
853 | |
869 | |
854 | if (shade == 100 && (bg_flags & BG_TINT_BITAND)) |
870 | rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC); |
|
|
871 | |
|
|
872 | if (tint_set) |
|
|
873 | tint.get (c); |
|
|
874 | |
|
|
875 | if (shade == 100 |
|
|
876 | && (c.r <= 0x00ff || c.r >= 0xff00) |
|
|
877 | && (c.g <= 0x00ff || c.g >= 0xff00) |
|
|
878 | && (c.b <= 0x00ff || c.b >= 0xff00)) |
855 | { |
879 | { |
856 | XGCValues gcv; |
880 | XGCValues gcv; |
857 | GC gc; |
881 | GC gc; |
858 | |
882 | |
859 | /* In this case we can tint image server-side getting significant |
883 | /* In this case we can tint image server-side getting significant |
… | |
… | |
869 | ret = true; |
893 | ret = true; |
870 | XFreeGC (dpy, gc); |
894 | XFreeGC (dpy, gc); |
871 | } |
895 | } |
872 | } |
896 | } |
873 | # if XRENDER |
897 | # if XRENDER |
874 | else if (bg_flags & BG_HAS_RENDER) |
898 | else if (display->flags & DISPLAY_HAS_RENDER) |
875 | { |
899 | { |
876 | rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC); |
|
|
877 | |
|
|
878 | if (bg_flags & BG_TINT_SET) |
|
|
879 | tint.get (c); |
|
|
880 | |
|
|
881 | if (shade <= 100) |
900 | if (shade <= 100) |
882 | { |
901 | { |
883 | c.r = c.r * shade / 100; |
902 | c.r = c.r * shade / 100; |
884 | c.g = c.g * shade / 100; |
903 | c.g = c.g * shade / 100; |
885 | c.b = c.b * shade / 100; |
904 | c.b = c.b * shade / 100; |
… | |
… | |
889 | c.r = c.r * (200 - shade) / 100; |
908 | c.r = c.r * (200 - shade) / 100; |
890 | c.g = c.g * (200 - shade) / 100; |
909 | c.g = c.g * (200 - shade) / 100; |
891 | c.b = c.b * (200 - shade) / 100; |
910 | c.b = c.b * (200 - shade) / 100; |
892 | } |
911 | } |
893 | |
912 | |
894 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
913 | XRenderPictFormat *format = argb ? XRenderFindStandardFormat (dpy, PictStandardARGB32) |
|
|
914 | : XRenderFindVisualFormat (dpy, visual); |
895 | |
915 | |
896 | Picture back_pic = XRenderCreatePicture (dpy, pixmap, format, 0, 0); |
916 | Picture back_pic = XRenderCreatePicture (dpy, pixmap, format, 0, 0); |
897 | |
917 | |
898 | Picture overlay_pic = create_xrender_mask (dpy, pixmap, True, False); |
918 | Picture overlay_pic = create_xrender_mask (dpy, pixmap, True, False); |
899 | |
919 | |
… | |
… | |
935 | # endif |
955 | # endif |
936 | |
956 | |
937 | return ret; |
957 | return ret; |
938 | } |
958 | } |
939 | |
959 | |
|
|
960 | # if ENABLE_TRANSPARENCY |
940 | /* |
961 | /* |
941 | * Builds a pixmap of the same size as the terminal window that contains |
962 | * Builds a pixmap of the same size as the terminal window that contains |
942 | * the tiled portion of the root pixmap that is supposed to be covered by |
963 | * the tiled portion of the root pixmap that is supposed to be covered by |
943 | * our window. |
964 | * our window. |
944 | */ |
965 | */ |
945 | bool |
966 | bool |
946 | rxvt_term::make_transparency_pixmap () |
967 | rxvt_term::render_root_image () |
947 | { |
968 | { |
948 | bool ret = false; |
969 | bool ret = false; |
949 | |
970 | |
950 | /* root dimensions may change from call to call - but Display structure should |
971 | /* root dimensions may change from call to call - but Display structure should |
951 | * be always up-to-date, so let's use it : |
972 | * be always up-to-date, so let's use it : |
… | |
… | |
987 | Pixmap recoded_root_pmap = root_pixmap; |
1008 | Pixmap recoded_root_pmap = root_pixmap; |
988 | |
1009 | |
989 | if (root_pixmap != None && root_depth != depth) |
1010 | if (root_pixmap != None && root_depth != depth) |
990 | { |
1011 | { |
991 | #if XRENDER |
1012 | #if XRENDER |
992 | if (bg_flags & BG_HAS_RENDER) |
1013 | if (display->flags & DISPLAY_HAS_RENDER) |
993 | { |
1014 | { |
994 | recoded_root_pmap = XCreatePixmap (dpy, vt, root_pmap_width, root_pmap_height, depth); |
1015 | recoded_root_pmap = XCreatePixmap (dpy, vt, root_pmap_width, root_pmap_height, depth); |
995 | |
1016 | |
996 | XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, screen)); |
1017 | XRenderPictFormat *src_format = XRenderFindVisualFormat (dpy, DefaultVisual (dpy, screen)); |
997 | Picture src = XRenderCreatePicture (dpy, root_pixmap, src_format, 0, 0); |
1018 | Picture src = XRenderCreatePicture (dpy, root_pixmap, src_format, 0, 0); |
… | |
… | |
1035 | |
1056 | |
1036 | if (gc) |
1057 | if (gc) |
1037 | { |
1058 | { |
1038 | XFillRectangle (dpy, bg_pixmap, gc, 0, 0, window_width, window_height); |
1059 | XFillRectangle (dpy, bg_pixmap, gc, 0, 0, window_width, window_height); |
1039 | ret = true; |
1060 | ret = true; |
1040 | bool need_blur = h_blurRadius && v_blurRadius; |
1061 | bool need_blur = root_effects.need_blur (); |
1041 | bool need_tint = shade != 100 || (bg_flags & BG_TINT_SET); |
1062 | bool need_tint = root_effects.need_tint (); |
1042 | |
1063 | |
1043 | if (!(bg_flags & BG_CLIENT_RENDER)) |
|
|
1044 | { |
|
|
1045 | if (need_blur) |
1064 | if (need_blur) |
|
|
1065 | { |
|
|
1066 | if (blur_pixmap (bg_pixmap, window_width, window_height, false, |
|
|
1067 | root_effects.h_blurRadius, root_effects.v_blurRadius)) |
|
|
1068 | need_blur = false; |
|
|
1069 | } |
|
|
1070 | if (need_tint) |
|
|
1071 | { |
|
|
1072 | if (tint_pixmap (bg_pixmap, window_width, window_height, false, |
|
|
1073 | root_effects.tint, root_effects.tint_set, root_effects.shade)) |
|
|
1074 | need_tint = false; |
|
|
1075 | } |
|
|
1076 | if (need_tint) |
|
|
1077 | { |
|
|
1078 | XImage *ximage = XGetImage (dpy, bg_pixmap, 0, 0, bg_pmap_width, bg_pmap_height, AllPlanes, ZPixmap); |
|
|
1079 | if (ximage) |
1046 | { |
1080 | { |
1047 | if (blur_pixmap (bg_pixmap, window_width, window_height)) |
1081 | /* our own client-side tinting */ |
1048 | need_blur = false; |
1082 | tint_ximage (ximage, root_effects.tint, root_effects.tint_set, root_effects.shade); |
|
|
1083 | |
|
|
1084 | XPutImage (dpy, bg_pixmap, gc, ximage, 0, 0, 0, 0, ximage->width, ximage->height); |
|
|
1085 | XDestroyImage (ximage); |
1049 | } |
1086 | } |
1050 | if (need_tint) |
|
|
1051 | { |
|
|
1052 | if (tint_pixmap (bg_pixmap, window_width, window_height)) |
|
|
1053 | need_tint = false; |
|
|
1054 | } |
1087 | } |
1055 | if (need_tint) |
|
|
1056 | { |
|
|
1057 | XImage *ximage = XGetImage (dpy, bg_pixmap, 0, 0, bg_pmap_width, bg_pmap_height, AllPlanes, ZPixmap); |
|
|
1058 | if (ximage) |
|
|
1059 | { |
|
|
1060 | /* our own client-side tinting */ |
|
|
1061 | tint_ximage (ximage); |
|
|
1062 | |
|
|
1063 | XPutImage (dpy, bg_pixmap, gc, ximage, 0, 0, 0, 0, ximage->width, ximage->height); |
|
|
1064 | XDestroyImage (ximage); |
|
|
1065 | } |
|
|
1066 | } |
|
|
1067 | } /* server side rendering completed */ |
|
|
1068 | |
1088 | |
1069 | XFreeGC (dpy, gc); |
1089 | XFreeGC (dpy, gc); |
1070 | } |
1090 | } |
1071 | |
1091 | |
1072 | if (recoded_root_pmap != root_pixmap) |
1092 | if (recoded_root_pmap != root_pixmap) |
… | |
… | |
1076 | } |
1096 | } |
1077 | |
1097 | |
1078 | void |
1098 | void |
1079 | rxvt_term::bg_set_root_pixmap () |
1099 | rxvt_term::bg_set_root_pixmap () |
1080 | { |
1100 | { |
1081 | Pixmap new_root_pixmap = get_pixmap_property (xa[XA_XROOTPMAP_ID]); |
1101 | Pixmap new_root_pixmap = display->get_pixmap_property (xa[XA_XROOTPMAP_ID]); |
1082 | if (new_root_pixmap == None) |
1102 | if (new_root_pixmap == None) |
1083 | new_root_pixmap = get_pixmap_property (xa[XA_ESETROOT_PMAP_ID]); |
1103 | new_root_pixmap = display->get_pixmap_property (xa[XA_ESETROOT_PMAP_ID]); |
1084 | |
1104 | |
1085 | root_pixmap = new_root_pixmap; |
1105 | root_pixmap = new_root_pixmap; |
1086 | } |
1106 | } |
1087 | # endif /* ENABLE_TRANSPARENCY */ |
1107 | # endif /* ENABLE_TRANSPARENCY */ |
1088 | |
1108 | |
1089 | bool |
1109 | void |
1090 | rxvt_term::bg_render () |
1110 | rxvt_term::bg_render () |
1091 | { |
1111 | { |
|
|
1112 | if (bg_flags & BG_INHIBIT_RENDER) |
|
|
1113 | return; |
|
|
1114 | |
1092 | bg_invalidate (); |
1115 | bg_invalidate (); |
1093 | # ifdef ENABLE_TRANSPARENCY |
1116 | # if ENABLE_TRANSPARENCY |
1094 | if (bg_flags & BG_IS_TRANSPARENT) |
1117 | if (bg_flags & BG_IS_TRANSPARENT) |
1095 | { |
1118 | { |
1096 | /* we need to re-generate transparency pixmap in that case ! */ |
1119 | /* we need to re-generate transparency pixmap in that case ! */ |
1097 | if (make_transparency_pixmap ()) |
1120 | if (render_root_image ()) |
1098 | bg_flags |= BG_IS_VALID; |
1121 | bg_flags |= BG_IS_VALID; |
1099 | } |
1122 | } |
1100 | # endif |
1123 | # endif |
1101 | |
1124 | |
1102 | # ifdef BG_IMAGE_FROM_FILE |
1125 | # if BG_IMAGE_FROM_FILE |
1103 | if (bg_image.flags & IM_IS_SET) |
1126 | if (fimage.flags & IM_IS_SET) |
1104 | { |
1127 | { |
1105 | if (render_image (bg_image)) |
1128 | if (render_image (fimage)) |
1106 | bg_flags |= BG_IS_VALID; |
1129 | bg_flags |= BG_IS_VALID; |
1107 | } |
1130 | } |
1108 | # endif |
1131 | # endif |
1109 | |
1132 | |
1110 | if (!(bg_flags & BG_IS_VALID)) |
1133 | if (!(bg_flags & BG_IS_VALID)) |
… | |
… | |
1118 | |
1141 | |
1119 | scr_recolour (false); |
1142 | scr_recolour (false); |
1120 | bg_flags |= BG_NEEDS_REFRESH; |
1143 | bg_flags |= BG_NEEDS_REFRESH; |
1121 | |
1144 | |
1122 | bg_valid_since = ev::now (); |
1145 | bg_valid_since = ev::now (); |
1123 | |
|
|
1124 | return true; |
|
|
1125 | } |
1146 | } |
1126 | |
1147 | |
1127 | void |
1148 | void |
1128 | rxvt_term::bg_init () |
1149 | rxvt_term::bg_init () |
1129 | { |
1150 | { |
1130 | #ifdef ENABLE_TRANSPARENCY |
1151 | #if BG_IMAGE_FROM_FILE |
1131 | shade = 100; |
1152 | if (rs[Rs_backgroundPixmap]) |
|
|
1153 | { |
|
|
1154 | if (fimage.set_file_geometry (rs[Rs_backgroundPixmap]) |
|
|
1155 | && !bg_window_position_sensitive ()) |
|
|
1156 | update_background (); |
|
|
1157 | } |
1132 | #endif |
1158 | #endif |
1133 | |
|
|
1134 | bg_flags &= ~(BG_HAS_RENDER | BG_HAS_RENDER_CONV); |
|
|
1135 | #if XRENDER |
|
|
1136 | int major, minor; |
|
|
1137 | if (XRenderQueryVersion (dpy, &major, &minor)) |
|
|
1138 | bg_flags |= BG_HAS_RENDER; |
|
|
1139 | XFilters *filters = XRenderQueryFilters (dpy, vt); |
|
|
1140 | if (filters) |
|
|
1141 | { |
|
|
1142 | for (int i = 0; i < filters->nfilter; i++) |
|
|
1143 | if (!strcmp (filters->filter[i], FilterConvolution)) |
|
|
1144 | bg_flags |= BG_HAS_RENDER_CONV; |
|
|
1145 | |
|
|
1146 | XFree (filters); |
|
|
1147 | } |
|
|
1148 | #endif |
|
|
1149 | } |
1159 | } |
1150 | |
1160 | |
1151 | #endif /* HAVE_BG_PIXMAP */ |
|
|
1152 | |
|
|
1153 | #ifdef ENABLE_TRANSPARENCY |
|
|
1154 | /* based on code from aterm-0.4.2 */ |
1161 | /* based on code from aterm-0.4.2 */ |
1155 | |
1162 | |
1156 | static inline void |
1163 | static inline void |
1157 | fill_lut (uint32_t *lookup, uint32_t mask, int sh, unsigned short low, unsigned short high) |
1164 | fill_lut (uint32_t *lookup, uint32_t mask, int sh, unsigned short low, unsigned short high) |
1158 | { |
1165 | { |
… | |
… | |
1164 | lookup[i] = (tmp / 0xffff) << sh; |
1171 | lookup[i] = (tmp / 0xffff) << sh; |
1165 | } |
1172 | } |
1166 | } |
1173 | } |
1167 | |
1174 | |
1168 | void |
1175 | void |
1169 | rxvt_term::tint_ximage (XImage *ximage) |
1176 | rxvt_term::tint_ximage (XImage *ximage, rxvt_color &tint, bool tint_set, int shade) |
1170 | { |
1177 | { |
1171 | unsigned int size_r, size_g, size_b; |
1178 | unsigned int size_r, size_g, size_b; |
1172 | int sh_r, sh_g, sh_b; |
1179 | int sh_r, sh_g, sh_b; |
1173 | uint32_t mask_r, mask_g, mask_b; |
1180 | uint32_t mask_r, mask_g, mask_b; |
1174 | uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b; |
1181 | uint32_t *lookup, *lookup_r, *lookup_g, *lookup_b; |
… | |
… | |
1199 | lookup_g = lookup + size_r; |
1206 | lookup_g = lookup + size_r; |
1200 | lookup_b = lookup + size_r + size_g; |
1207 | lookup_b = lookup + size_r + size_g; |
1201 | |
1208 | |
1202 | rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC); |
1209 | rgba c (rgba::MAX_CC, rgba::MAX_CC, rgba::MAX_CC); |
1203 | |
1210 | |
1204 | if (bg_flags & BG_TINT_SET) |
1211 | if (tint_set) |
1205 | tint.get (c); |
1212 | tint.get (c); |
1206 | |
1213 | |
1207 | /* prepare limits for color transformation (each channel is handled separately) */ |
1214 | /* prepare limits for color transformation (each channel is handled separately) */ |
1208 | if (shade > 100) |
1215 | if (shade > 100) |
1209 | { |
1216 | { |
… | |
… | |
1259 | } |
1266 | } |
1260 | } |
1267 | } |
1261 | |
1268 | |
1262 | free (lookup); |
1269 | free (lookup); |
1263 | } |
1270 | } |
1264 | #endif /* ENABLE_TRANSPARENCY */ |
1271 | |
|
|
1272 | #endif /* HAVE_BG_PIXMAP */ |