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.143 by sf-exg, Fri Jan 28 00:08:57 2011 UTC vs.
Revision 1.147 by root, Mon Feb 21 07:40:59 2011 UTC

1/*----------------------------------------------------------------------* 1/*----------------------------------------------------------------------*
2 * File: background.C - former xpm.C 2 * File: background.C - former xpm.C
3 *----------------------------------------------------------------------* 3 *----------------------------------------------------------------------*
4 * 4 *
5 * All portions of code are copyright by their respective author/s. 5 * All portions of code are copyright by their respective author/s.
6 * Copyright (c) 2005-2008 Marc Lehmann <pcg@goof.com> 6 * Copyright (c) 2005-2008 Marc Lehmann <schmorp@schmorp.de>
7 * Copyright (c) 2007 Sasha Vasko <sasha@aftercode.net> 7 * Copyright (c) 2007 Sasha Vasko <sasha@aftercode.net>
8 * Copyright (c) 2010 Emanuele Giaquinta <e.giaquinta@glauco.it> 8 * Copyright (c) 2010 Emanuele Giaquinta <e.giaquinta@glauco.it>
9 * 9 *
10 * This program is free software; you can redistribute it and/or modify 10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by 11 * it under the terms of the GNU General Public License as published by
65rxvt_term::bg_destroy () 65rxvt_term::bg_destroy ()
66{ 66{
67#ifdef HAVE_AFTERIMAGE 67#ifdef HAVE_AFTERIMAGE
68 if (original_asim) 68 if (original_asim)
69 safe_asimage_destroy (original_asim); 69 safe_asimage_destroy (original_asim);
70 if (asv)
71 destroy_asvisual (asv, 0);
72 if (asimman)
73 destroy_image_manager (asimman, 0);
70#endif 74#endif
71 75
72#ifdef HAVE_PIXBUF 76#ifdef HAVE_PIXBUF
73 if (pixbuf) 77 if (pixbuf)
74 g_object_unref (pixbuf); 78 g_object_unref (pixbuf);
99 if (bg_flags & BG_IS_TRANSPARENT) 103 if (bg_flags & BG_IS_TRANSPARENT)
100 return true; 104 return true;
101# endif 105# endif
102 106
103# ifdef BG_IMAGE_FROM_FILE 107# ifdef BG_IMAGE_FROM_FILE
104 if (have_image) 108 if (bg_flags & BG_IS_FROM_FILE)
105 { 109 {
106 if (bg_flags & BG_IS_SIZE_SENSITIVE) 110 if (bg_flags & BG_IS_SIZE_SENSITIVE)
107 return true; 111 return true;
108 } 112 }
109# endif 113# endif
118 if (bg_flags & BG_IS_TRANSPARENT) 122 if (bg_flags & BG_IS_TRANSPARENT)
119 return true; 123 return true;
120# endif 124# endif
121 125
122# ifdef BG_IMAGE_FROM_FILE 126# ifdef BG_IMAGE_FROM_FILE
123 if (have_image) 127 if (bg_flags & BG_IS_FROM_FILE)
124 { 128 {
125 if (bg_flags & BG_ROOT_ALIGN) 129 if (bg_flags & BG_ROOT_ALIGN)
126 return true; 130 return true;
127 } 131 }
128# endif 132# endif
868 if (image) 872 if (image)
869 { 873 {
870 if (original_asim) 874 if (original_asim)
871 safe_asimage_destroy (original_asim); 875 safe_asimage_destroy (original_asim);
872 original_asim = image; 876 original_asim = image;
873 bg_flags |= BG_CLIENT_RENDER; 877 bg_flags |= BG_IS_FROM_FILE | BG_CLIENT_RENDER;
874 have_image = true;
875 return true; 878 return true;
876 } 879 }
877# endif 880# endif
878 881
879# ifdef HAVE_PIXBUF 882# ifdef HAVE_PIXBUF
881 if (image) 884 if (image)
882 { 885 {
883 if (pixbuf) 886 if (pixbuf)
884 g_object_unref (pixbuf); 887 g_object_unref (pixbuf);
885 pixbuf = image; 888 pixbuf = image;
886 have_image = true; 889 bg_flags |= BG_IS_FROM_FILE;
887 return true; 890 return true;
888 } 891 }
889# endif 892# endif
890 893
891 return false; 894 return false;
940 bg_flags |= BG_NEEDS_BLUR; 943 bg_flags |= BG_NEEDS_BLUR;
941 944
942 return changed; 945 return changed;
943} 946}
944 947
945static inline unsigned long 948void
946compute_tint_shade_flags (rxvt_color *tint, int shade) 949rxvt_term::set_tint_shade_flags ()
947{ 950{
948 unsigned long flags = 0;
949 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); 951 rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC);
950 bool has_shade = shade != 100; 952 bool has_shade = shade != 100;
951 953
952 if (tint) 954 bg_flags &= ~BG_TINT_FLAGS;
955
956 if (bg_flags & BG_TINT_SET)
953 { 957 {
954 tint->get (c); 958 tint.get (c);
955 if (!has_shade 959 if (!has_shade
956 && (c.r <= 0x00ff || c.r >= 0xff00) 960 && (c.r <= 0x00ff || c.r >= 0xff00)
957 && (c.g <= 0x00ff || c.g >= 0xff00) 961 && (c.g <= 0x00ff || c.g >= 0xff00)
958 && (c.b <= 0x00ff || c.b >= 0xff00)) 962 && (c.b <= 0x00ff || c.b >= 0xff00))
959 flags |= rxvt_term::BG_TINT_BITAND; 963 bg_flags |= BG_TINT_BITAND;
960 } 964 }
961 965
962 if (has_shade || tint) 966 if (has_shade || (bg_flags & BG_TINT_SET))
963 flags |= rxvt_term::BG_NEEDS_TINT; 967 bg_flags |= BG_NEEDS_TINT;
964
965 return flags;
966} 968}
967 969
968bool 970bool
969rxvt_term::bg_set_tint (rxvt_color &new_tint) 971rxvt_term::bg_set_tint (rxvt_color &new_tint)
970{ 972{
971 if (!(bg_flags & BG_TINT_SET) || tint != new_tint) 973 if (!(bg_flags & BG_TINT_SET) || tint != new_tint)
972 { 974 {
973 unsigned long new_flags = compute_tint_shade_flags (&new_tint, shade);
974 tint = new_tint; 975 tint = new_tint;
975 bg_flags = (bg_flags & ~BG_TINT_FLAGS) | new_flags | BG_TINT_SET; 976 bg_flags |= BG_TINT_SET;
977 set_tint_shade_flags ();
976 return true; 978 return true;
977 } 979 }
978 980
979 return false; 981 return false;
980} 982}
988 if (new_shade < 0) 990 if (new_shade < 0)
989 new_shade = 200 - (100 + new_shade); 991 new_shade = 200 - (100 + new_shade);
990 992
991 if (new_shade != shade) 993 if (new_shade != shade)
992 { 994 {
993 unsigned long new_flags = compute_tint_shade_flags ((bg_flags & BG_TINT_SET) ? &tint : NULL, new_shade);
994 shade = new_shade; 995 shade = new_shade;
995 bg_flags = (bg_flags & ~BG_TINT_FLAGS) | new_flags; 996 set_tint_shade_flags ();
996 return true; 997 return true;
997 } 998 }
998 999
999 return false; 1000 return false;
1000} 1001}
1350 bg_flags |= BG_IS_VALID; 1351 bg_flags |= BG_IS_VALID;
1351 } 1352 }
1352# endif 1353# endif
1353 1354
1354# ifdef BG_IMAGE_FROM_FILE 1355# ifdef BG_IMAGE_FROM_FILE
1355 if (have_image 1356 if ((bg_flags & BG_IS_FROM_FILE)
1356 || (tr_flags & BG_EFFECTS_FLAGS)) 1357 || (tr_flags & BG_EFFECTS_FLAGS))
1357 { 1358 {
1358 if (render_image (tr_flags)) 1359 if (render_image (tr_flags))
1359 bg_flags |= BG_IS_VALID; 1360 bg_flags |= BG_IS_VALID;
1360 } 1361 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines