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