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.48 by sf-exg, Tue Aug 31 14:12:20 2010 UTC vs.
Revision 1.53 by sf-exg, Wed Sep 1 13:18:55 2010 UTC

52 * adjustment and may optionally be followed by a colon and one or more 52 * adjustment and may optionally be followed by a colon and one or more
53 * colon-delimited pixmap operations. 53 * colon-delimited pixmap operations.
54 * The following table shows the valid geometry strings and their 54 * The following table shows the valid geometry strings and their
55 * effects on the background image : 55 * effects on the background image :
56 * 56 *
57 * WxH+X+Y Set scaling to W% by H%, and position to X% by Y%. 57 * WxH+X+Y Set scaling to W% by H%, and position to X% by Y%.
58 * W and H are percentages of the terminal window size. 58 * W and H are percentages of the terminal window size.
59 * X and Y are also percentages; e.g., +50+50 centers 59 * X and Y are also percentages; e.g., +50+50 centers
60 * the image in the window. 60 * the image in the window.
61 * WxH+X Assumes Y == X 61 * WxH+X Assumes Y == X
62 * WxH Assumes Y == X == 50 (centers the image) 62 * WxH Assumes Y == X == 50 (centers the image)
63 * W+X+Y Assumes H == W 63 * W+X+Y Assumes H == W
64 * W+X Assumes H == W and Y == X 64 * W+X Assumes H == W and Y == X
65 * W Assumes H == W and Y == X == 50 65 * W Assumes H == W and Y == X == 50
66 * 66 *
67 * Adjusting position only : 67 * Adjusting position only :
68 * =+X+Y Set position to X% by Y% (absolute). 68 * =+X+Y Set position to X% by Y% (absolute).
69 * =+X Set position to X% by X%. 69 * =+X Set position to X% by X%.
70 * +X+Y Adjust position horizontally X% and vertically Y% 70 * +X+Y Adjust position horizontally X% and vertically Y%
71 * from current position (relative). 71 * from current position (relative).
72 * +X Adjust position horizontally X% and vertically X% 72 * +X Adjust position horizontally X% and vertically X%
73 * from current position. 73 * from current position.
74 * 74 *
75 * Adjusting scale only : 75 * Adjusting scale only :
76 * Wx0 Multiply horizontal scaling factor by W% 76 * Wx0 Multiply horizontal scaling factor by W%
77 * 0xH Multiply vertical scaling factor by H% 77 * 0xH Multiply vertical scaling factor by H%
78 * 0x0 No scaling (show image at normal size). 78 * 0x0 No scaling (show image at normal size).
79 * 79 *
80 * Pixmap Operations : (should be prepended by a colon) 80 * Pixmap Operations : (should be prepended by a colon)
81 * tile Tile image. Scaling/position modifiers above will affect 81 * tile Tile image. Scaling/position modifiers above will affect
82 * the tile size and origin. 82 * the tile size and origin.
83 * propscale When scaling, scale proportionally. That is, maintain the 83 * propscale When scaling, scale proportionally. That is, maintain the
84 * proper aspect ratio for the image. Any portion of the 84 * proper aspect ratio for the image. Any portion of the
85 * background not covered by the image is filled with the 85 * background not covered by the image is filled with the
86 * current background color. 86 * current background color.
87 * hscale Scale horizontally, tile vertically ? 87 * hscale Scale horizontally, tile vertically ?
88 * vscale Tile horizontally, scale vertically ? 88 * vscale Tile horizontally, scale vertically ?
97 // zero_initialised-derived structs 97 // zero_initialised-derived structs
98#ifdef HAVE_AFTERIMAGE 98#ifdef HAVE_AFTERIMAGE
99 original_asim = NULL; 99 original_asim = NULL;
100#endif 100#endif
101#ifdef BG_IMAGE_FROM_FILE 101#ifdef BG_IMAGE_FROM_FILE
102 have_image = false;
102 h_scale = v_scale = 0; 103 h_scale = v_scale = 0;
103 h_align = v_align = 0; 104 h_align = v_align = 0;
104#endif 105#endif
105 flags = 0; 106 flags = 0;
106 pixmap = None; 107 pixmap = None;
127 if (flags & isTransparent) 128 if (flags & isTransparent)
128 return true; 129 return true;
129# endif 130# endif
130 131
131# ifdef BG_IMAGE_FROM_FILE 132# ifdef BG_IMAGE_FROM_FILE
132# ifdef HAVE_AFTERIMAGE 133 if (have_image)
133 if (original_asim)
134# endif
135 { 134 {
136 if (h_scale != 0 || v_scale != 0 135 if (h_scale != 0 || v_scale != 0
137 || h_align != 0 || v_align != 0) 136 || h_align != 0 || v_align != 0)
138 return true; 137 return true;
139 } 138 }
149 if (flags & isTransparent) 148 if (flags & isTransparent)
150 return true; 149 return true;
151# endif 150# endif
152 151
153# ifdef BG_IMAGE_FROM_FILE 152# ifdef BG_IMAGE_FROM_FILE
154# ifdef HAVE_AFTERIMAGE 153 if (have_image)
155 if (original_asim)
156# endif
157 { 154 {
158 if (h_align == rootAlign || v_align == rootAlign) 155 if (h_align == rootAlign || v_align == rootAlign)
159 return true; 156 return true;
160 } 157 }
161# endif 158# endif
448 return (changed > 0); 445 return (changed > 0);
449} 446}
450 447
451# ifdef HAVE_AFTERIMAGE 448# ifdef HAVE_AFTERIMAGE
452bool 449bool
453bgPixmap_t::render_asim (unsigned long background_flags) 450bgPixmap_t::render_image (unsigned long background_flags)
454{ 451{
455 if (target == NULL) 452 if (target == NULL)
456 return false; 453 return false;
457 454
458 target->init_asv (); 455 target->init_asv ();
645 free (layers); 642 free (layers);
646 } 643 }
647 } 644 }
648 TIMING_TEST_PRINT_RESULT (asim); 645 TIMING_TEST_PRINT_RESULT (asim);
649 646
650 if (pixmap) 647 bool ret = false;
651 {
652 if (result == NULL
653 || pmap_width != new_pmap_width
654 || pmap_height != new_pmap_height
655 || pmap_depth != target->depth)
656 {
657 XFreePixmap (target->dpy, pixmap);
658 pixmap = None;
659 }
660 }
661 648
662 if (result) 649 if (result)
663 { 650 {
664 XGCValues gcv; 651 XGCValues gcv;
665 GC gc; 652 GC gc;
653
654 if (pixmap)
655 {
656 if (pmap_width != new_pmap_width
657 || pmap_height != new_pmap_height
658 || pmap_depth != target->depth)
659 {
660 XFreePixmap (target->dpy, pixmap);
661 pixmap = None;
662 }
663 }
666 664
667 /* create Pixmap */ 665 /* create Pixmap */
668 if (pixmap == None) 666 if (pixmap == None)
669 { 667 {
670 pixmap = XCreatePixmap (target->dpy, target->vt, new_pmap_width, new_pmap_height, target->depth); 668 pixmap = XCreatePixmap (target->dpy, target->vt, new_pmap_width, new_pmap_height, target->depth);
696 if (result != background && result != original_asim) 694 if (result != background && result != original_asim)
697 destroy_asimage (&result); 695 destroy_asimage (&result);
698 696
699 XFreeGC (target->dpy, gc); 697 XFreeGC (target->dpy, gc);
700 TIMING_TEST_PRINT_RESULT (asim); 698 TIMING_TEST_PRINT_RESULT (asim);
699
700 ret = true;
701 } 701 }
702 702
703 if (background) 703 if (background)
704 destroy_asimage (&background); 704 destroy_asimage (&background);
705 705
706 return true; 706 return ret;
707} 707}
708# endif /* HAVE_AFTERIMAGE */ 708# endif /* HAVE_AFTERIMAGE */
709 709
710bool 710bool
711bgPixmap_t::set_file (const char *file) 711bgPixmap_t::set_file (const char *file)
725 725
726# ifdef HAVE_AFTERIMAGE 726# ifdef HAVE_AFTERIMAGE
727 if (!target->asimman) 727 if (!target->asimman)
728 target->asimman = create_generic_imageman (target->rs[Rs_path]); 728 target->asimman = create_generic_imageman (target->rs[Rs_path]);
729 original_asim = get_asimage (target->asimman, file, 0xFFFFFFFF, 100); 729 original_asim = get_asimage (target->asimman, file, 0xFFFFFFFF, 100);
730 return original_asim; 730 if (original_asim)
731 have_image = true;
732 return have_image;
731# endif 733# endif
732 } 734 }
733 735
734 return false; 736 return false;
735} 737}
755 int changed = 0; 757 int changed = 0;
756 unsigned int hr, vr; 758 unsigned int hr, vr;
757 int junk; 759 int junk;
758 int geom_flags = XParseGeometry (geom, &junk, &junk, &hr, &vr); 760 int geom_flags = XParseGeometry (geom, &junk, &junk, &hr, &vr);
759 761
760 if (!(geom_flags&WidthValue)) 762 if (!(geom_flags & WidthValue))
761 hr = 1; 763 hr = 1;
762 if (!(geom_flags&HeightValue)) 764 if (!(geom_flags & HeightValue))
763 vr = hr; 765 vr = hr;
764 766
765 if (h_blurRadius != hr) 767 if (h_blurRadius != hr)
766 { 768 {
767 ++changed; 769 ++changed;
777 if (v_blurRadius == 0 && h_blurRadius == 0) 779 if (v_blurRadius == 0 && h_blurRadius == 0)
778 flags &= ~blurNeeded; 780 flags &= ~blurNeeded;
779 else 781 else
780 flags |= blurNeeded; 782 flags |= blurNeeded;
781 783
782 return (changed>0); 784 return (changed > 0);
783} 785}
784 786
785static inline unsigned long 787static inline unsigned long
786compute_tint_shade_flags (rxvt_color *tint, int shade) 788compute_tint_shade_flags (rxvt_color *tint, int shade)
787{ 789{
845{ 847{
846 unsigned long new_flags = compute_tint_shade_flags (NULL, shade); 848 unsigned long new_flags = compute_tint_shade_flags (NULL, shade);
847 849
848 if (new_flags != (flags & tintFlags)) 850 if (new_flags != (flags & tintFlags))
849 { 851 {
850 flags = (flags&~tintFlags)|new_flags; 852 flags = (flags & ~tintFlags) | new_flags;
851 return true; 853 return true;
852 } 854 }
853 855
854 return false; 856 return false;
855} 857}
1173 && pmap_depth == target->depth) 1175 && pmap_depth == target->depth)
1174 flags = flags & ~isInvalid; 1176 flags = flags & ~isInvalid;
1175 } 1177 }
1176# endif 1178# endif
1177 1179
1178# ifdef HAVE_AFTERIMAGE 1180# ifdef BG_IMAGE_FROM_FILE
1179 if (original_asim 1181 if (have_image
1180 || (background_flags & transpTransformations) != (flags & transpTransformations)) 1182 || (background_flags & transpTransformations) != (flags & transpTransformations))
1181 { 1183 {
1182 if (render_asim (background_flags)) 1184 if (render_image (background_flags))
1183 flags = flags & ~isInvalid; 1185 flags = flags & ~isInvalid;
1184 } 1186 }
1185# endif 1187# endif
1186 1188
1187 XImage *result = NULL; 1189 XImage *result = NULL;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines