… | |
… | |
59 | |
59 | |
60 | void |
60 | void |
61 | rxvt_term::bg_destroy () |
61 | rxvt_term::bg_destroy () |
62 | { |
62 | { |
63 | # if BG_IMAGE_FROM_FILE |
63 | # if 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 (); |
64 | fimage.destroy (); |
66 | # endif |
65 | # endif |
67 | |
66 | |
68 | if (bg_pixmap) |
67 | if (bg_pixmap) |
69 | XFreePixmap (dpy, bg_pixmap); |
68 | XFreePixmap (dpy, bg_pixmap); |
70 | } |
69 | } |
… | |
… | |
90 | if (bg_flags & BG_IS_TRANSPARENT) |
89 | if (bg_flags & BG_IS_TRANSPARENT) |
91 | return true; |
90 | return true; |
92 | # endif |
91 | # endif |
93 | |
92 | |
94 | # if BG_IMAGE_FROM_FILE |
93 | # if BG_IMAGE_FROM_FILE |
95 | for (vector<rxvt_image>::iterator bg_image = image_vec.begin (); bg_image < image_vec.end (); bg_image++) |
94 | if (fimage.flags & IM_IS_SET) |
96 | { |
95 | { |
97 | if ((bg_image->flags & IM_IS_SIZE_SENSITIVE) |
96 | if ((fimage.flags & IM_IS_SIZE_SENSITIVE) |
98 | || bg_image->width () > szHint.width |
97 | || fimage.width () > szHint.width |
99 | || bg_image->height () > szHint.height) |
98 | || fimage.height () > szHint.height) |
100 | return true; |
99 | return true; |
101 | } |
100 | } |
102 | # endif |
101 | # endif |
103 | |
102 | |
104 | return false; |
103 | return false; |
… | |
… | |
111 | if (bg_flags & BG_IS_TRANSPARENT) |
110 | if (bg_flags & BG_IS_TRANSPARENT) |
112 | return true; |
111 | return true; |
113 | # endif |
112 | # endif |
114 | |
113 | |
115 | # if BG_IMAGE_FROM_FILE |
114 | # if BG_IMAGE_FROM_FILE |
116 | for (vector<rxvt_image>::iterator bg_image = image_vec.begin (); bg_image < image_vec.end (); bg_image++) |
115 | if (fimage.flags & IM_IS_SET) |
117 | { |
116 | { |
118 | if (bg_image->flags & IM_ROOT_ALIGN) |
117 | if (fimage.flags & IM_ROOT_ALIGN) |
119 | return true; |
118 | return true; |
120 | } |
119 | } |
121 | # endif |
120 | # endif |
122 | |
121 | |
123 | return false; |
122 | return false; |
… | |
… | |
537 | |
536 | |
538 | if (need_blend) |
537 | if (need_blend) |
539 | tmp_pixmap = XCreatePixmap (dpy, vt, new_pmap_width, new_pmap_height, 32); |
538 | tmp_pixmap = XCreatePixmap (dpy, vt, new_pmap_width, new_pmap_height, 32); |
540 | else |
539 | else |
541 | { |
540 | { |
542 | // optimise bg pixmap size when tiling, but only if there are no |
|
|
543 | // other pixbufs to render. Otherwise, the bg pixmap size must |
|
|
544 | // be equal to the window size. |
|
|
545 | if ((image.flags & IM_TILE) |
541 | if (image.flags & IM_TILE) |
546 | && image_vec.size () == 1) |
|
|
547 | { |
542 | { |
548 | new_pmap_width = min (image_width, target_width); |
543 | new_pmap_width = min (image_width, target_width); |
549 | new_pmap_height = min (image_height, target_height); |
544 | new_pmap_height = min (image_height, target_height); |
550 | } |
545 | } |
551 | |
546 | |
… | |
… | |
650 | XFreePixmap (dpy, tmp_pixmap); |
645 | XFreePixmap (dpy, tmp_pixmap); |
651 | |
646 | |
652 | return ret; |
647 | return ret; |
653 | } |
648 | } |
654 | # endif /* HAVE_PIXBUF */ |
649 | # endif /* HAVE_PIXBUF */ |
655 | |
|
|
656 | # ifndef NO_RESOURCES |
|
|
657 | static int |
|
|
658 | rxvt_define_image (XrmDatabase *database ecb_unused, |
|
|
659 | XrmBindingList bindings ecb_unused, |
|
|
660 | XrmQuarkList quarks, |
|
|
661 | XrmRepresentation *type ecb_unused, |
|
|
662 | XrmValue *value, |
|
|
663 | XPointer closure ecb_unused) |
|
|
664 | { |
|
|
665 | int size; |
|
|
666 | |
|
|
667 | for (size = 0; quarks[size] != NULLQUARK; size++) |
|
|
668 | ; |
|
|
669 | |
|
|
670 | if (size >= 2) |
|
|
671 | { |
|
|
672 | int id = strtol (XrmQuarkToString (quarks[size-2]), 0, 0); |
|
|
673 | if (id >= 1) |
|
|
674 | GET_R->parse_image (id, XrmQuarkToString (quarks[size-1]), (char *)value->addr); |
|
|
675 | } |
|
|
676 | return False; |
|
|
677 | } |
|
|
678 | # endif |
|
|
679 | |
|
|
680 | void |
|
|
681 | rxvt_term::parse_image (int id, const char *type, const char *arg) |
|
|
682 | { |
|
|
683 | if (image_vec.size () < id + 1) |
|
|
684 | image_vec.resize (id + 1); |
|
|
685 | |
|
|
686 | rxvt_image *image = &image_vec[id]; |
|
|
687 | } |
|
|
688 | |
650 | |
689 | rxvt_image::rxvt_image () |
651 | rxvt_image::rxvt_image () |
690 | { |
652 | { |
691 | alpha = 0xffff; |
653 | alpha = 0xffff; |
692 | flags = 0; |
654 | flags = 0; |
… | |
… | |
1142 | |
1104 | |
1143 | root_pixmap = new_root_pixmap; |
1105 | root_pixmap = new_root_pixmap; |
1144 | } |
1106 | } |
1145 | # endif /* ENABLE_TRANSPARENCY */ |
1107 | # endif /* ENABLE_TRANSPARENCY */ |
1146 | |
1108 | |
1147 | bool |
1109 | void |
1148 | rxvt_term::bg_render () |
1110 | rxvt_term::bg_render () |
1149 | { |
1111 | { |
1150 | bg_invalidate (); |
1112 | bg_invalidate (); |
1151 | # if ENABLE_TRANSPARENCY |
1113 | # if ENABLE_TRANSPARENCY |
1152 | if (bg_flags & BG_IS_TRANSPARENT) |
1114 | if (bg_flags & BG_IS_TRANSPARENT) |
… | |
… | |
1156 | bg_flags |= BG_IS_VALID; |
1118 | bg_flags |= BG_IS_VALID; |
1157 | } |
1119 | } |
1158 | # endif |
1120 | # endif |
1159 | |
1121 | |
1160 | # if BG_IMAGE_FROM_FILE |
1122 | # if BG_IMAGE_FROM_FILE |
1161 | for (vector<rxvt_image>::iterator bg_image = image_vec.begin (); bg_image < image_vec.end (); bg_image++) |
1123 | if (fimage.flags & IM_IS_SET) |
1162 | { |
1124 | { |
1163 | if (render_image (*bg_image)) |
1125 | if (render_image (fimage)) |
1164 | bg_flags |= BG_IS_VALID; |
1126 | bg_flags |= BG_IS_VALID; |
1165 | } |
1127 | } |
1166 | # endif |
1128 | # endif |
1167 | |
1129 | |
1168 | if (!(bg_flags & BG_IS_VALID)) |
1130 | if (!(bg_flags & BG_IS_VALID)) |
… | |
… | |
1176 | |
1138 | |
1177 | scr_recolour (false); |
1139 | scr_recolour (false); |
1178 | bg_flags |= BG_NEEDS_REFRESH; |
1140 | bg_flags |= BG_NEEDS_REFRESH; |
1179 | |
1141 | |
1180 | bg_valid_since = ev::now (); |
1142 | bg_valid_since = ev::now (); |
1181 | |
|
|
1182 | return true; |
|
|
1183 | } |
1143 | } |
1184 | |
1144 | |
1185 | void |
1145 | void |
1186 | rxvt_term::bg_init () |
1146 | rxvt_term::bg_init () |
1187 | { |
1147 | { |
1188 | #if BG_IMAGE_FROM_FILE |
1148 | #if BG_IMAGE_FROM_FILE |
1189 | if (rs[Rs_backgroundPixmap]) |
1149 | if (rs[Rs_backgroundPixmap]) |
1190 | { |
1150 | { |
1191 | rxvt_image *image = new_image (); |
|
|
1192 | if (!image->set_file_geometry (rs[Rs_backgroundPixmap])) |
1151 | if (fimage.set_file_geometry (rs[Rs_backgroundPixmap]) |
1193 | image_vec.pop_back (); |
|
|
1194 | } |
|
|
1195 | |
|
|
1196 | # ifndef NO_RESOURCES |
|
|
1197 | find_resources ("image", "Image", XrmEnumAllLevels, rxvt_define_image); |
|
|
1198 | # endif |
|
|
1199 | |
|
|
1200 | vector<rxvt_image>::iterator bg_image = image_vec.begin (); |
|
|
1201 | while (bg_image != image_vec.end ()) |
|
|
1202 | { |
|
|
1203 | if (!(bg_image->flags & IM_IS_SET)) |
|
|
1204 | bg_image = image_vec.erase (bg_image); |
|
|
1205 | else |
|
|
1206 | { |
|
|
1207 | if (bg_image->is_size_sensitive ()) |
|
|
1208 | bg_image->flags |= IM_IS_SIZE_SENSITIVE; |
|
|
1209 | |
|
|
1210 | bg_image++; |
|
|
1211 | } |
|
|
1212 | } |
|
|
1213 | |
|
|
1214 | if (image_vec.size () > 0 |
|
|
1215 | && !bg_window_position_sensitive ()) |
1152 | && !bg_window_position_sensitive ()) |
1216 | update_background (); |
1153 | update_background (); |
|
|
1154 | } |
1217 | #endif |
1155 | #endif |
1218 | } |
1156 | } |
1219 | |
1157 | |
1220 | /* based on code from aterm-0.4.2 */ |
1158 | /* based on code from aterm-0.4.2 */ |
1221 | |
1159 | |