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.214 by sf-exg, Thu May 17 10:18:32 2012 UTC vs.
Revision 1.221 by sf-exg, Fri May 25 09:27:35 2012 UTC

58# endif 58# endif
59 59
60void 60void
61rxvt_term::bg_destroy () 61rxvt_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
67bool 72bool
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;
145 150
146 min_it (dst_size, target_size - dst_pos); 151 min_it (dst_size, target_size - dst_pos);
147 return src_pos; 152 return src_pos;
148} 153}
149 154
155static void
156parse_style (const char *style, int &x, int &y, unsigned int &w, unsigned int &h, uint8_t &flags)
157{
158 if (!strcasecmp (style, "tiled"))
159 {
160 flags = IM_TILE;
161 w = h = noScale;
162 x = y = 0;
163 }
164 else if (!strcasecmp (style, "aspect-stretched"))
165 {
166 flags = IM_KEEP_ASPECT;
167 w = h = windowScale;
168 x = y = centerAlign;
169 }
170 else if (!strcasecmp (style, "stretched"))
171 {
172 flags = 0;
173 w = h = windowScale;
174 x = y = centerAlign;
175 }
176 else if (!strcasecmp (style, "centered"))
177 {
178 flags = 0;
179 w = h = noScale;
180 x = y = centerAlign;
181 }
182 else if (!strcasecmp (style, "root-tiled"))
183 {
184 flags = IM_TILE|IM_ROOT_ALIGN;
185 w = h = noScale;
186 x = y = 0;
187 }
188}
189
150bool 190bool
151rxvt_image::set_geometry (const char *geom, bool update) 191rxvt_image::set_geometry (const char *geom, bool update)
152{ 192{
153 bool changed = false; 193 bool changed = false;
154 int geom_flags = 0; 194 int geom_flags = 0;
155 int x = h_align; 195 int x = h_align;
156 int y = v_align; 196 int y = v_align;
157 unsigned int w = h_scale; 197 unsigned int w = h_scale;
158 unsigned int h = v_scale; 198 unsigned int h = v_scale;
159 unsigned long new_flags = 0; 199 uint8_t new_flags = 0;
160 200
161 if (geom == NULL) 201 if (geom == NULL)
162 return false; 202 return false;
163 203
164 if (geom[0]) 204 if (geom[0])
165 { 205 {
166 char **arr = rxvt_strsplit (':', geom); 206 char **arr = rxvt_strsplit (':', geom);
167 207
168 for (int i = 0; arr[i]; i++) 208 for (int i = 0; arr[i]; i++)
169 { 209 {
170 if (!strcasecmp (arr[i], "style=tiled")) 210 if (!strncasecmp (arr[i], "style=", 6))
171 { 211 {
172 new_flags = IM_TILE; 212 parse_style (arr[i] + 6, x, y, w, h, new_flags);
173 w = h = noScale;
174 x = y = 0;
175 geom_flags = WidthValue|HeightValue|XValue|YValue; 213 geom_flags = WidthValue|HeightValue|XValue|YValue;
176 }
177 else if (!strcasecmp (arr[i], "style=aspect-stretched"))
178 {
179 new_flags = IM_KEEP_ASPECT;
180 w = h = windowScale;
181 x = y = centerAlign;
182 geom_flags = WidthValue|HeightValue|XValue|YValue;
183 }
184 else if (!strcasecmp (arr[i], "style=stretched"))
185 {
186 new_flags = 0;
187 w = h = windowScale;
188 geom_flags = WidthValue|HeightValue;
189 }
190 else if (!strcasecmp (arr[i], "style=centered"))
191 {
192 new_flags = 0;
193 w = h = noScale;
194 x = y = centerAlign;
195 geom_flags = WidthValue|HeightValue|XValue|YValue;
196 }
197 else if (!strcasecmp (arr[i], "style=root-tiled"))
198 {
199 new_flags = IM_TILE|IM_ROOT_ALIGN;
200 w = h = noScale;
201 geom_flags = WidthValue|HeightValue;
202 } 214 }
203 else if (!strcasecmp (arr[i], "op=tile")) 215 else if (!strcasecmp (arr[i], "op=tile"))
204 new_flags |= IM_TILE; 216 new_flags |= IM_TILE;
205 else if (!strcasecmp (arr[i], "op=keep-aspect")) 217 else if (!strcasecmp (arr[i], "op=keep-aspect"))
206 new_flags |= IM_KEEP_ASPECT; 218 new_flags |= IM_KEEP_ASPECT;
274 h = w; 286 h = w;
275 else if (!(geom_flags & WidthValue)) 287 else if (!(geom_flags & WidthValue))
276 w = h; 288 w = h;
277 } 289 }
278 290
279 min_it (w, 1000);
280 min_it (h, 1000);
281 clamp_it (x, -100, 200); 291 clamp_it (x, -100, 200);
282 clamp_it (y, -100, 200); 292 clamp_it (y, -100, 200);
283 293
284 if (flags != new_flags 294 if (flags != new_flags
285 || h_scale != w 295 || h_scale != w
310{ 320{
311 int image_width = image.width (); 321 int image_width = image.width ();
312 int image_height = image.height (); 322 int image_height = image.height ();
313 int target_width = szHint.width; 323 int target_width = szHint.width;
314 int target_height = szHint.height; 324 int target_height = szHint.height;
325 int h_scale = min (image.h_scale, 32767 * 100 / target_width);
326 int v_scale = min (image.v_scale, 32767 * 100 / target_height);
315 327
316 w = image.h_scale * target_width / 100; 328 w = h_scale * target_width / 100;
317 h = image.v_scale * target_height / 100; 329 h = v_scale * target_height / 100;
318 330
319 if (image.flags & IM_KEEP_ASPECT) 331 if (image.flags & IM_KEEP_ASPECT)
320 { 332 {
321 float scale = (float)w / image_width; 333 float scale = (float)w / image_width;
322 min_it (scale, (float)h / image_height); 334 min_it (scale, (float)h / image_height);
341 353
342# ifdef HAVE_PIXBUF 354# ifdef HAVE_PIXBUF
343bool 355bool
344rxvt_term::pixbuf_to_pixmap (GdkPixbuf *pixbuf, Pixmap pixmap, GC gc, 356rxvt_term::pixbuf_to_pixmap (GdkPixbuf *pixbuf, Pixmap pixmap, GC gc,
345 int src_x, int src_y, int dst_x, int dst_y, 357 int src_x, int src_y, int dst_x, int dst_y,
346 unsigned int width, unsigned int height) 358 unsigned int width, unsigned int height, bool argb)
347{ 359{
348 XImage *ximage; 360 XImage *ximage;
349 char *line; 361 char *line;
350 int width_r, width_g, width_b, width_a; 362 int width_r, width_g, width_b, width_a;
351 int sh_r, sh_g, sh_b, sh_a; 363 int sh_r, sh_g, sh_b, sh_a;
352 uint32_t alpha_mask; 364 uint32_t red_mask, green_mask, blue_mask, alpha_mask;
353 int rowstride; 365 int rowstride;
354 int channels; 366 int channels;
355 unsigned char *row; 367 unsigned char *row;
356 368
357 if (visual->c_class != TrueColor) 369 if (visual->c_class != TrueColor)
358 return false; 370 return false;
359 371
372 if (argb)
373 {
374 red_mask = 0xff << 16;
375 green_mask = 0xff << 8;
376 blue_mask = 0xff;
377 alpha_mask = 0xff << 24;
378 }
379 else
380 {
381 red_mask = visual->red_mask;
382 green_mask = visual->green_mask;
383 blue_mask = visual->blue_mask;
360#if XRENDER 384#if XRENDER
361 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); 385 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual);
362 if (format) 386 if (format)
363 alpha_mask = (uint32_t)format->direct.alphaMask << format->direct.alpha; 387 alpha_mask = (uint32_t)format->direct.alphaMask << format->direct.alpha;
364 else 388 else
365#endif 389#endif
366 alpha_mask = 0; 390 alpha_mask = 0;
391 }
367 392
368 width_r = ecb_popcount32 (visual->red_mask); 393 width_r = ecb_popcount32 (red_mask);
369 width_g = ecb_popcount32 (visual->green_mask); 394 width_g = ecb_popcount32 (green_mask);
370 width_b = ecb_popcount32 (visual->blue_mask); 395 width_b = ecb_popcount32 (blue_mask);
371 width_a = ecb_popcount32 (alpha_mask); 396 width_a = ecb_popcount32 (alpha_mask);
372 397
373 if (width_r > 8 || width_g > 8 || width_b > 8 || width_a > 8) 398 if (width_r > 8 || width_g > 8 || width_b > 8 || width_a > 8)
374 return false; 399 return false;
375 400
376 sh_r = ecb_ctz32 (visual->red_mask); 401 sh_r = ecb_ctz32 (red_mask);
377 sh_g = ecb_ctz32 (visual->green_mask); 402 sh_g = ecb_ctz32 (green_mask);
378 sh_b = ecb_ctz32 (visual->blue_mask); 403 sh_b = ecb_ctz32 (blue_mask);
379 sh_a = ecb_ctz32 (alpha_mask); 404 sh_a = ecb_ctz32 (alpha_mask);
380 405
381 if (width > 32767 || height > 32767) 406 if (width > 32767 || height > 32767)
382 return false; 407 return false;
383 408
384 ximage = XCreateImage (dpy, visual, depth, ZPixmap, 0, 0, 409 ximage = XCreateImage (dpy, visual, argb ? 32 : depth, ZPixmap, 0, 0,
385 width, height, 32, 0); 410 width, height, 32, 0);
386 if (!ximage) 411 if (!ximage)
387 return false; 412 return false;
388 413
389 if (height > INT_MAX / ximage->bytes_per_line 414 if (height > INT_MAX / ximage->bytes_per_line
452 XDestroyImage (ximage); 477 XDestroyImage (ximage);
453 return true; 478 return true;
454} 479}
455 480
456bool 481bool
457rxvt_term::render_image (rxvt_image &image, bool transparent) 482rxvt_term::render_image (rxvt_image &image)
458{ 483{
459 GdkPixbuf *pixbuf = image.pixbuf; 484 GdkPixbuf *pixbuf = image.pixbuf;
460 if (!pixbuf) 485 if (!pixbuf)
461 return false; 486 return false;
462 487
463 if (transparent 488 bool need_blend = bg_flags & BG_IS_VALID;
489
490 if (need_blend
464 && !(bg_flags & BG_HAS_RENDER)) 491 && !(bg_flags & BG_HAS_RENDER))
465 return false; 492 return false;
466 493
467 GdkPixbuf *result; 494 GdkPixbuf *result;
468 495
503 530
504 bool ret = false; 531 bool ret = false;
505 532
506 XGCValues gcv; 533 XGCValues gcv;
507 GC gc; 534 GC gc;
508 Pixmap root_pmap; 535 Pixmap tmp_pixmap;
509 536
510 image_width = gdk_pixbuf_get_width (result); 537 image_width = gdk_pixbuf_get_width (result);
511 image_height = gdk_pixbuf_get_height (result); 538 image_height = gdk_pixbuf_get_height (result);
512 539
513 if (transparent) 540 if (need_blend)
514 { 541 tmp_pixmap = XCreatePixmap (dpy, vt, new_pmap_width, new_pmap_height, 32);
515 root_pmap = bg_pixmap;
516 bg_pixmap = None;
517 }
518 else 542 else
519 { 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.
520 if (image.flags & IM_TILE) 547 if ((image.flags & IM_TILE)
548 && image_vec.size () == 1)
521 { 549 {
522 new_pmap_width = min (image_width, target_width); 550 new_pmap_width = min (image_width, target_width);
523 new_pmap_height = min (image_height, target_height); 551 new_pmap_height = min (image_height, target_height);
524 } 552 }
525 }
526 553
527 if (bg_pixmap == None 554 if (bg_pixmap == None
528 || bg_pmap_width != new_pmap_width 555 || bg_pmap_width != new_pmap_width
529 || bg_pmap_height != new_pmap_height) 556 || bg_pmap_height != new_pmap_height)
530 { 557 {
531 if (bg_pixmap) 558 if (bg_pixmap)
532 XFreePixmap (dpy, bg_pixmap); 559 XFreePixmap (dpy, bg_pixmap);
533 bg_pixmap = XCreatePixmap (dpy, vt, new_pmap_width, new_pmap_height, depth); 560 bg_pixmap = XCreatePixmap (dpy, vt, new_pmap_width, new_pmap_height, depth);
534 bg_pmap_width = new_pmap_width; 561 bg_pmap_width = new_pmap_width;
535 bg_pmap_height = new_pmap_height; 562 bg_pmap_height = new_pmap_height;
563 }
564
565 tmp_pixmap = bg_pixmap;
536 } 566 }
537 567
538 gcv.foreground = pix_colors[Color_bg]; 568 gcv.foreground = pix_colors[Color_bg];
539 gc = XCreateGC (dpy, vt, GCForeground, &gcv); 569 gc = XCreateGC (dpy, tmp_pixmap, GCForeground, &gcv);
540 570
541 if (gc) 571 if (gc)
542 { 572 {
543 if (image.flags & IM_TILE) 573 if (image.flags & IM_TILE)
544 { 574 {
545 Pixmap tile = XCreatePixmap (dpy, vt, image_width, image_height, depth); 575 Pixmap tile = XCreatePixmap (dpy, vt, image_width, image_height, need_blend ? 32 : depth);
546 pixbuf_to_pixmap (result, tile, gc, 576 pixbuf_to_pixmap (result, tile, gc,
547 0, 0, 577 0, 0,
548 0, 0, 578 0, 0,
549 image_width, image_height); 579 image_width, image_height, need_blend);
550 580
551 gcv.tile = tile; 581 gcv.tile = tile;
552 gcv.fill_style = FillTiled; 582 gcv.fill_style = FillTiled;
553 gcv.ts_x_origin = x; 583 gcv.ts_x_origin = x;
554 gcv.ts_y_origin = y; 584 gcv.ts_y_origin = y;
555 XChangeGC (dpy, gc, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv); 585 XChangeGC (dpy, gc, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv);
556 586
557 XFillRectangle (dpy, bg_pixmap, gc, 0, 0, new_pmap_width, new_pmap_height); 587 XFillRectangle (dpy, tmp_pixmap, gc, 0, 0, new_pmap_width, new_pmap_height);
558 XFreePixmap (dpy, tile); 588 XFreePixmap (dpy, tile);
559 } 589 }
560 else 590 else
561 { 591 {
562 int src_x, src_y, dst_x, dst_y; 592 int src_x, src_y, dst_x, dst_y;
566 src_y = make_clip_rectangle (y, image_height, new_pmap_height, dst_y, dst_height); 596 src_y = make_clip_rectangle (y, image_height, new_pmap_height, dst_y, dst_height);
567 597
568 if (dst_x > 0 || dst_y > 0 598 if (dst_x > 0 || dst_y > 0
569 || dst_x + dst_width < new_pmap_width 599 || dst_x + dst_width < new_pmap_width
570 || dst_y + dst_height < new_pmap_height) 600 || dst_y + dst_height < new_pmap_height)
571 XFillRectangle (dpy, bg_pixmap, gc, 0, 0, new_pmap_width, new_pmap_height); 601 XFillRectangle (dpy, tmp_pixmap, gc, 0, 0, new_pmap_width, new_pmap_height);
572 602
573 if (dst_x < new_pmap_width && dst_y < new_pmap_height) 603 if (dst_x < new_pmap_width && dst_y < new_pmap_height)
574 pixbuf_to_pixmap (result, bg_pixmap, gc, 604 pixbuf_to_pixmap (result, tmp_pixmap, gc,
575 src_x, src_y, 605 src_x, src_y,
576 dst_x, dst_y, 606 dst_x, dst_y,
577 dst_width, dst_height); 607 dst_width, dst_height, need_blend);
578 } 608 }
579 609
580#if XRENDER 610#if XRENDER
581 if (transparent) 611 if (need_blend)
582 { 612 {
613 XRenderPictFormat *argb_format = XRenderFindStandardFormat (dpy, PictStandardARGB32);
583 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); 614 XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual);
584 615
585 Picture src = XRenderCreatePicture (dpy, root_pmap, format, 0, 0); 616 Picture src = XRenderCreatePicture (dpy, tmp_pixmap, argb_format, 0, 0);
586 617
587 Picture dst = XRenderCreatePicture (dpy, bg_pixmap, format, 0, 0); 618 Picture dst = XRenderCreatePicture (dpy, bg_pixmap, format, 0, 0);
588 619
589 Picture mask = create_xrender_mask (dpy, vt, False, False); 620 Picture mask = create_xrender_mask (dpy, vt, False, False);
590 621
591 XRenderColor mask_c; 622 XRenderColor mask_c;
592 623
593 mask_c.alpha = 0x8000; 624 mask_c.alpha = gdk_pixbuf_get_has_alpha (image.pixbuf) ? 0xffff : image.alpha;
594 mask_c.red = 625 mask_c.red =
595 mask_c.green = 626 mask_c.green =
596 mask_c.blue = 0; 627 mask_c.blue = 0;
597 XRenderFillRectangle (dpy, PictOpSrc, mask, &mask_c, 0, 0, 1, 1); 628 XRenderFillRectangle (dpy, PictOpSrc, mask, &mask_c, 0, 0, 1, 1);
598 629
610 } 641 }
611 642
612 if (result != pixbuf) 643 if (result != pixbuf)
613 g_object_unref (result); 644 g_object_unref (result);
614 645
615 if (transparent) 646 if (need_blend)
616 XFreePixmap (dpy, root_pmap); 647 XFreePixmap (dpy, tmp_pixmap);
617 648
618 return ret; 649 return ret;
619} 650}
620# endif /* HAVE_PIXBUF */ 651# endif /* HAVE_PIXBUF */
621 652
653# ifndef NO_RESOURCES
654static int
655rxvt_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
676void
677rxvt_term::parse_image (int id, const char *type, const char *arg)
678{
679 rxvt_image *image;
680
681 for (image = image_vec.begin (); image < image_vec.end (); image++)
682 if (image->id == id)
683 break;
684
685 if (image == image_vec.end ())
686 {
687 image = new_image ();
688 image->id = id;
689 }
690}
691# endif
692
693rxvt_image::rxvt_image ()
694{
695 id =
696 alpha =
697 flags =
698 h_scale =
699 v_scale =
700 h_align =
701 v_align = 0;
702
703# ifdef HAVE_PIXBUF
704 pixbuf = 0;
705# endif
706}
707
622bool 708bool
623rxvt_image::set_file (const char *file) 709rxvt_image::set_file_geometry (const char *file)
624{ 710{
625 if (!file || !*file) 711 if (!file || !*file)
626 return false; 712 return false;
627 713
628 bool ret = false;
629 const char *p = strchr (file, ';'); 714 const char *p = strchr (file, ';');
630 715
631 if (p) 716 if (p)
632 { 717 {
633 size_t len = p - file; 718 size_t len = p - file;
635 memcpy (f, file, len); 720 memcpy (f, file, len);
636 f[len] = '\0'; 721 f[len] = '\0';
637 file = f; 722 file = f;
638 } 723 }
639 724
725 bool ret = set_file (file);
726 alpha = 0x8000;
727 if (ret && p)
728 set_geometry (p + 1);
729 return ret;
730}
731
732bool
733rxvt_image::set_file (const char *file)
734{
735 bool ret = false;
736
640# ifdef HAVE_PIXBUF 737# ifdef HAVE_PIXBUF
641 GdkPixbuf *image = gdk_pixbuf_new_from_file (file, NULL); 738 GdkPixbuf *image = gdk_pixbuf_new_from_file (file, NULL);
642 if (image) 739 if (image)
643 { 740 {
644 if (pixbuf) 741 if (pixbuf)
645 g_object_unref (pixbuf); 742 g_object_unref (pixbuf);
646 pixbuf = image; 743 pixbuf = image;
647 flags |= IM_IS_SET;
648 ret = true; 744 ret = true;
649 } 745 }
650# endif 746# endif
651 747
652 if (ret) 748 if (ret)
653 { 749 {
654 if (p) 750 alpha = 0xffff;
655 set_geometry (p + 1); 751 flags = IM_IS_SET | IM_IS_SIZE_SENSITIVE;
656 else 752 h_scale = v_scale = defaultScale;
657 set_default_geometry (); 753 h_align = v_align = defaultAlign;
658 } 754 }
659 755
660 return ret; 756 return ret;
661} 757}
662 758
1064# endif /* ENABLE_TRANSPARENCY */ 1160# endif /* ENABLE_TRANSPARENCY */
1065 1161
1066bool 1162bool
1067rxvt_term::bg_render () 1163rxvt_term::bg_render ()
1068{ 1164{
1069 bool transparent = false;
1070
1071 bg_invalidate (); 1165 bg_invalidate ();
1072# ifdef ENABLE_TRANSPARENCY 1166# ifdef ENABLE_TRANSPARENCY
1073 if (bg_flags & BG_IS_TRANSPARENT) 1167 if (bg_flags & BG_IS_TRANSPARENT)
1074 { 1168 {
1075 /* we need to re-generate transparency pixmap in that case ! */ 1169 /* we need to re-generate transparency pixmap in that case ! */
1076 transparent = make_transparency_pixmap (); 1170 if (make_transparency_pixmap ())
1077 if (transparent)
1078 bg_flags |= BG_IS_VALID; 1171 bg_flags |= BG_IS_VALID;
1079 } 1172 }
1080# endif 1173# endif
1081 1174
1082# ifdef BG_IMAGE_FROM_FILE 1175# ifdef BG_IMAGE_FROM_FILE
1083 if (bg_image.flags & IM_IS_SET) 1176 for (vector<rxvt_image>::iterator bg_image = image_vec.begin (); bg_image < image_vec.end (); bg_image++)
1084 { 1177 {
1085 if (render_image (bg_image, transparent)) 1178 if (render_image (*bg_image))
1086 bg_flags |= BG_IS_VALID; 1179 bg_flags |= BG_IS_VALID;
1087 } 1180 }
1088# endif 1181# endif
1089 1182
1090 if (!(bg_flags & BG_IS_VALID)) 1183 if (!(bg_flags & BG_IS_VALID))
1123 if (!strcmp (filters->filter[i], FilterConvolution)) 1216 if (!strcmp (filters->filter[i], FilterConvolution))
1124 bg_flags |= BG_HAS_RENDER_CONV; 1217 bg_flags |= BG_HAS_RENDER_CONV;
1125 1218
1126 XFree (filters); 1219 XFree (filters);
1127 } 1220 }
1221#endif
1222
1223#ifdef BG_IMAGE_FROM_FILE
1224 if (rs[Rs_backgroundPixmap])
1225 {
1226 rxvt_image *image = new_image ();
1227 if (!image->set_file_geometry (rs[Rs_backgroundPixmap]))
1228 image_vec.pop_back ();
1229 }
1230
1231# ifndef NO_RESOURCES
1232 find_resources ("image", "Image", XrmEnumAllLevels, rxvt_define_image);
1233 vector<rxvt_image>::iterator bg_image = image_vec.begin ();
1234 while (bg_image != image_vec.end ())
1235 {
1236 if (!(bg_image->flags & IM_IS_SET))
1237 bg_image = image_vec.erase (bg_image);
1238 else
1239 bg_image++;
1240 }
1241# endif
1242
1243 if (image_vec.size () > 0
1244 && !bg_window_position_sensitive ())
1245 update_background ();
1128#endif 1246#endif
1129} 1247}
1130 1248
1131#endif /* HAVE_BG_PIXMAP */ 1249#endif /* HAVE_BG_PIXMAP */
1132 1250

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines