… | |
… | |
58 | # endif |
58 | # endif |
59 | |
59 | |
60 | void |
60 | void |
61 | rxvt_term::bg_destroy () |
61 | rxvt_term::bg_destroy () |
62 | { |
62 | { |
|
|
63 | # ifdef BG_IMAGE_FROM_FILE |
|
|
64 | for (vector<rxvt_image>::iterator bg_image = image_vec.begin (); bg_image < image_vec.end (); bg_image++) |
|
|
65 | bg_image->destroy (); |
|
|
66 | # endif |
|
|
67 | |
63 | if (bg_pixmap) |
68 | if (bg_pixmap) |
64 | XFreePixmap (dpy, bg_pixmap); |
69 | XFreePixmap (dpy, bg_pixmap); |
65 | } |
70 | } |
66 | |
71 | |
67 | bool |
72 | bool |
… | |
… | |
85 | if (bg_flags & BG_IS_TRANSPARENT) |
90 | if (bg_flags & BG_IS_TRANSPARENT) |
86 | return true; |
91 | return true; |
87 | # endif |
92 | # endif |
88 | |
93 | |
89 | # ifdef BG_IMAGE_FROM_FILE |
94 | # ifdef BG_IMAGE_FROM_FILE |
90 | if (bg_image.flags & IM_IS_SET) |
95 | for (vector<rxvt_image>::iterator bg_image = image_vec.begin (); bg_image < image_vec.end (); bg_image++) |
91 | { |
96 | { |
92 | if ((bg_image.flags & IM_IS_SIZE_SENSITIVE) |
97 | if ((bg_image->flags & IM_IS_SIZE_SENSITIVE) |
93 | || bg_image.width () > szHint.width |
98 | || bg_image->width () > szHint.width |
94 | || bg_image.height () > szHint.height) |
99 | || bg_image->height () > szHint.height) |
95 | return true; |
100 | return true; |
96 | } |
101 | } |
97 | # endif |
102 | # endif |
98 | |
103 | |
99 | return false; |
104 | return false; |
… | |
… | |
106 | if (bg_flags & BG_IS_TRANSPARENT) |
111 | if (bg_flags & BG_IS_TRANSPARENT) |
107 | return true; |
112 | return true; |
108 | # endif |
113 | # endif |
109 | |
114 | |
110 | # ifdef BG_IMAGE_FROM_FILE |
115 | # ifdef BG_IMAGE_FROM_FILE |
111 | if (bg_image.flags & IM_IS_SET) |
116 | for (vector<rxvt_image>::iterator bg_image = image_vec.begin (); bg_image < image_vec.end (); bg_image++) |
112 | { |
117 | { |
113 | if (bg_image.flags & IM_ROOT_ALIGN) |
118 | if (bg_image->flags & IM_ROOT_ALIGN) |
114 | return true; |
119 | return true; |
115 | } |
120 | } |
116 | # endif |
121 | # endif |
117 | |
122 | |
118 | return false; |
123 | return false; |
… | |
… | |
534 | |
539 | |
535 | if (need_blend) |
540 | if (need_blend) |
536 | tmp_pixmap = XCreatePixmap (dpy, vt, new_pmap_width, new_pmap_height, 32); |
541 | tmp_pixmap = XCreatePixmap (dpy, vt, new_pmap_width, new_pmap_height, 32); |
537 | else |
542 | else |
538 | { |
543 | { |
|
|
544 | // optimise bg pixmap size when tiling, but only if there are no |
|
|
545 | // other pixbufs to render. Otherwise, the bg pixmap size must |
|
|
546 | // be equal to the window size. |
539 | if (image.flags & IM_TILE) |
547 | if ((image.flags & IM_TILE) |
|
|
548 | && image_vec.size () == 1) |
540 | { |
549 | { |
541 | new_pmap_width = min (image_width, target_width); |
550 | new_pmap_width = min (image_width, target_width); |
542 | new_pmap_height = min (image_height, target_height); |
551 | new_pmap_height = min (image_height, target_height); |
543 | } |
552 | } |
544 | |
553 | |
… | |
… | |
610 | |
619 | |
611 | Picture mask = create_xrender_mask (dpy, vt, False, False); |
620 | Picture mask = create_xrender_mask (dpy, vt, False, False); |
612 | |
621 | |
613 | XRenderColor mask_c; |
622 | XRenderColor mask_c; |
614 | |
623 | |
615 | mask_c.alpha = 0x8000; |
624 | mask_c.alpha = gdk_pixbuf_get_has_alpha (image.pixbuf) ? 0xffff : image.alpha; |
616 | mask_c.red = |
625 | mask_c.red = |
617 | mask_c.green = |
626 | mask_c.green = |
618 | mask_c.blue = 0; |
627 | mask_c.blue = 0; |
619 | XRenderFillRectangle (dpy, PictOpSrc, mask, &mask_c, 0, 0, 1, 1); |
628 | XRenderFillRectangle (dpy, PictOpSrc, mask, &mask_c, 0, 0, 1, 1); |
620 | |
629 | |
… | |
… | |
639 | |
648 | |
640 | return ret; |
649 | return ret; |
641 | } |
650 | } |
642 | # endif /* HAVE_PIXBUF */ |
651 | # endif /* HAVE_PIXBUF */ |
643 | |
652 | |
|
|
653 | # ifndef NO_RESOURCES |
|
|
654 | static int |
|
|
655 | rxvt_define_image (XrmDatabase *database ecb_unused, |
|
|
656 | XrmBindingList bindings ecb_unused, |
|
|
657 | XrmQuarkList quarks, |
|
|
658 | XrmRepresentation *type ecb_unused, |
|
|
659 | XrmValue *value, |
|
|
660 | XPointer closure ecb_unused) |
|
|
661 | { |
|
|
662 | int size; |
|
|
663 | |
|
|
664 | for (size = 0; quarks[size] != NULLQUARK; size++) |
|
|
665 | ; |
|
|
666 | |
|
|
667 | if (size >= 2) |
|
|
668 | { |
|
|
669 | int id = strtol (XrmQuarkToString (quarks[size-2]), 0, 0); |
|
|
670 | if (id >= 1) |
|
|
671 | GET_R->parse_image (id, XrmQuarkToString (quarks[size-1]), (char *)value->addr); |
|
|
672 | } |
|
|
673 | return False; |
|
|
674 | } |
|
|
675 | |
|
|
676 | void |
|
|
677 | rxvt_term::parse_image (int id, const char *type, const char *arg) |
|
|
678 | { |
|
|
679 | if (image_vec.size () < id + 1) |
|
|
680 | image_vec.resize (id + 1); |
|
|
681 | |
|
|
682 | rxvt_image *image = &image_vec[id]; |
|
|
683 | } |
|
|
684 | # endif |
|
|
685 | |
|
|
686 | rxvt_image::rxvt_image () |
|
|
687 | { |
|
|
688 | alpha = |
|
|
689 | flags = |
|
|
690 | h_scale = |
|
|
691 | v_scale = |
|
|
692 | h_align = |
|
|
693 | v_align = 0; |
|
|
694 | |
|
|
695 | # ifdef HAVE_PIXBUF |
|
|
696 | pixbuf = 0; |
|
|
697 | # endif |
|
|
698 | } |
|
|
699 | |
644 | bool |
700 | bool |
645 | rxvt_image::set_file (const char *file) |
701 | rxvt_image::set_file_geometry (const char *file) |
646 | { |
702 | { |
647 | if (!file || !*file) |
703 | if (!file || !*file) |
648 | return false; |
704 | return false; |
649 | |
705 | |
650 | bool ret = false; |
|
|
651 | const char *p = strchr (file, ';'); |
706 | const char *p = strchr (file, ';'); |
652 | |
707 | |
653 | if (p) |
708 | if (p) |
654 | { |
709 | { |
655 | size_t len = p - file; |
710 | size_t len = p - file; |
… | |
… | |
657 | memcpy (f, file, len); |
712 | memcpy (f, file, len); |
658 | f[len] = '\0'; |
713 | f[len] = '\0'; |
659 | file = f; |
714 | file = f; |
660 | } |
715 | } |
661 | |
716 | |
|
|
717 | bool ret = set_file (file); |
|
|
718 | alpha = 0x8000; |
|
|
719 | if (ret && p) |
|
|
720 | set_geometry (p + 1); |
|
|
721 | return ret; |
|
|
722 | } |
|
|
723 | |
|
|
724 | bool |
|
|
725 | rxvt_image::set_file (const char *file) |
|
|
726 | { |
|
|
727 | bool ret = false; |
|
|
728 | |
662 | # ifdef HAVE_PIXBUF |
729 | # ifdef HAVE_PIXBUF |
663 | GdkPixbuf *image = gdk_pixbuf_new_from_file (file, NULL); |
730 | GdkPixbuf *image = gdk_pixbuf_new_from_file (file, NULL); |
664 | if (image) |
731 | if (image) |
665 | { |
732 | { |
666 | if (pixbuf) |
733 | if (pixbuf) |
… | |
… | |
670 | } |
737 | } |
671 | # endif |
738 | # endif |
672 | |
739 | |
673 | if (ret) |
740 | if (ret) |
674 | { |
741 | { |
|
|
742 | alpha = 0xffff; |
675 | flags = IM_IS_SET | IM_IS_SIZE_SENSITIVE; |
743 | flags = IM_IS_SET | IM_IS_SIZE_SENSITIVE; |
676 | h_scale = v_scale = defaultScale; |
744 | h_scale = v_scale = defaultScale; |
677 | h_align = v_align = defaultAlign; |
745 | h_align = v_align = defaultAlign; |
678 | |
|
|
679 | if (p) |
|
|
680 | set_geometry (p + 1); |
|
|
681 | } |
746 | } |
682 | |
747 | |
683 | return ret; |
748 | return ret; |
684 | } |
749 | } |
685 | |
750 | |
… | |
… | |
1098 | bg_flags |= BG_IS_VALID; |
1163 | bg_flags |= BG_IS_VALID; |
1099 | } |
1164 | } |
1100 | # endif |
1165 | # endif |
1101 | |
1166 | |
1102 | # ifdef BG_IMAGE_FROM_FILE |
1167 | # ifdef BG_IMAGE_FROM_FILE |
1103 | if (bg_image.flags & IM_IS_SET) |
1168 | for (vector<rxvt_image>::iterator bg_image = image_vec.begin (); bg_image < image_vec.end (); bg_image++) |
1104 | { |
1169 | { |
1105 | if (render_image (bg_image)) |
1170 | if (render_image (*bg_image)) |
1106 | bg_flags |= BG_IS_VALID; |
1171 | bg_flags |= BG_IS_VALID; |
1107 | } |
1172 | } |
1108 | # endif |
1173 | # endif |
1109 | |
1174 | |
1110 | if (!(bg_flags & BG_IS_VALID)) |
1175 | if (!(bg_flags & BG_IS_VALID)) |
… | |
… | |
1143 | if (!strcmp (filters->filter[i], FilterConvolution)) |
1208 | if (!strcmp (filters->filter[i], FilterConvolution)) |
1144 | bg_flags |= BG_HAS_RENDER_CONV; |
1209 | bg_flags |= BG_HAS_RENDER_CONV; |
1145 | |
1210 | |
1146 | XFree (filters); |
1211 | XFree (filters); |
1147 | } |
1212 | } |
|
|
1213 | #endif |
|
|
1214 | |
|
|
1215 | #ifdef BG_IMAGE_FROM_FILE |
|
|
1216 | if (rs[Rs_backgroundPixmap]) |
|
|
1217 | { |
|
|
1218 | rxvt_image *image = new_image (); |
|
|
1219 | if (!image->set_file_geometry (rs[Rs_backgroundPixmap])) |
|
|
1220 | image_vec.pop_back (); |
|
|
1221 | } |
|
|
1222 | |
|
|
1223 | # ifndef NO_RESOURCES |
|
|
1224 | find_resources ("image", "Image", XrmEnumAllLevels, rxvt_define_image); |
|
|
1225 | vector<rxvt_image>::iterator bg_image = image_vec.begin (); |
|
|
1226 | while (bg_image != image_vec.end ()) |
|
|
1227 | { |
|
|
1228 | if (!(bg_image->flags & IM_IS_SET)) |
|
|
1229 | bg_image = image_vec.erase (bg_image); |
|
|
1230 | else |
|
|
1231 | bg_image++; |
|
|
1232 | } |
|
|
1233 | # endif |
|
|
1234 | |
|
|
1235 | if (image_vec.size () > 0 |
|
|
1236 | && !bg_window_position_sensitive ()) |
|
|
1237 | update_background (); |
1148 | #endif |
1238 | #endif |
1149 | } |
1239 | } |
1150 | |
1240 | |
1151 | #endif /* HAVE_BG_PIXMAP */ |
1241 | #endif /* HAVE_BG_PIXMAP */ |
1152 | |
1242 | |