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.197 by sf-exg, Wed Jan 11 13:22:01 2012 UTC vs.
Revision 1.198 by sf-exg, Wed Jan 11 13:51:07 2012 UTC

129 129
130 return false; 130 return false;
131} 131}
132 132
133# ifdef BG_IMAGE_FROM_FILE 133# ifdef BG_IMAGE_FROM_FILE
134static inline bool
135check_set_scale_value (int geom_flags, int flag, unsigned int &scale, unsigned int new_value)
136{
137 if (geom_flags & flag)
138 {
139 if (new_value > 1000)
140 new_value = 1000;
141 if (new_value != scale)
142 {
143 scale = new_value;
144 return true;
145 }
146 }
147 return false;
148}
149
150static inline bool
151check_set_align_value (int geom_flags, int flag, int &align, int new_value)
152{
153 if (geom_flags & flag)
154 {
155 if (new_value < -100)
156 new_value = -100;
157 else if (new_value > 200)
158 new_value = 200;
159 if (new_value != align)
160 {
161 align = new_value;
162 return true;
163 }
164 }
165 return false;
166}
167
168static inline int 134static inline int
169make_align_position (int align, int window_size, int image_size) 135make_align_position (int align, int window_size, int image_size)
170{ 136{
171 int diff = window_size - image_size; 137 int diff = window_size - image_size;
172 int smaller = min (image_size, window_size); 138 int smaller = min (image_size, window_size);
200bool 166bool
201rxvt_term::bg_set_geometry (const char *geom, bool update) 167rxvt_term::bg_set_geometry (const char *geom, bool update)
202{ 168{
203 bool changed = false; 169 bool changed = false;
204 int geom_flags = 0; 170 int geom_flags = 0;
205 int x = 0, y = 0; 171 int x = h_align;
172 int y = v_align;
206 unsigned int w = 0, h = 0; 173 unsigned int w = h_scale;
174 unsigned int h = v_scale;
207 unsigned long new_flags = 0; 175 unsigned long new_flags = 0;
208 176
209 if (geom == NULL) 177 if (geom == NULL)
210 return false; 178 return false;
211 179
320 w = h = defaultScale; 288 w = h = defaultScale;
321 else if (!(geom_flags & HeightValue)) 289 else if (!(geom_flags & HeightValue))
322 h = w; 290 h = w;
323 else if (!(geom_flags & WidthValue)) 291 else if (!(geom_flags & WidthValue))
324 w = h; 292 w = h;
325
326 geom_flags |= WidthValue|HeightValue|XValue|YValue;
327 } 293 }
328 294
329 if (check_set_scale_value (geom_flags, WidthValue, h_scale, w)) changed = true; 295 min_it (w, 1000);
330 if (check_set_scale_value (geom_flags, HeightValue, v_scale, h)) changed = true; 296 min_it (h, 1000);
331 if (check_set_align_value (geom_flags, XValue, h_align, x)) changed = true; 297 clamp_it (x, -100, 200);
332 if (check_set_align_value (geom_flags, YValue, v_align, y)) changed = true; 298 clamp_it (y, -100, 200);
333 299
334 if (new_flags != bg_flags) 300 if (bg_flags != new_flags
301 || h_scale != w
302 || v_scale != h
303 || h_align != x
304 || v_align != y)
335 { 305 {
336 bg_flags = new_flags; 306 bg_flags = new_flags;
307 h_scale = w;
308 v_scale = h;
309 h_align = x;
310 v_align = y;
337 changed = true; 311 changed = true;
338 } 312 }
339 313
340 return changed; 314 return changed;
341} 315}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines