ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/background.C
(Generate patch)

Comparing rxvt-unicode/src/background.C (file contents):
Revision 1.232 by root, Mon Jun 4 15:18:52 2012 UTC vs.
Revision 1.233 by sf-exg, Wed Jun 6 22:00:20 2012 UTC

59 59
60void 60void
61rxvt_term::bg_destroy () 61rxvt_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
657static int
658rxvt_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
680void
681rxvt_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
689rxvt_image::rxvt_image () 651rxvt_image::rxvt_image ()
690{ 652{
691 alpha = 0xffff; 653 alpha = 0xffff;
692 flags = 0; 654 flags = 0;
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))
1186rxvt_term::bg_init () 1148rxvt_term::bg_init ()
1187{ 1149{
1188#if BG_IMAGE_FROM_FILE 1150#if BG_IMAGE_FROM_FILE
1189 if (rs[Rs_backgroundPixmap]) 1151 if (rs[Rs_backgroundPixmap])
1190 { 1152 {
1191 rxvt_image *image = new_image ();
1192 if (!image->set_file_geometry (rs[Rs_backgroundPixmap])) 1153 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 ()) 1154 && !bg_window_position_sensitive ())
1216 update_background (); 1155 update_background ();
1156 }
1217#endif 1157#endif
1218} 1158}
1219 1159
1220/* based on code from aterm-0.4.2 */ 1160/* based on code from aterm-0.4.2 */
1221 1161

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines