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.116 by sf-exg, Thu Nov 11 11:58:10 2010 UTC vs.
Revision 1.120 by sf-exg, Thu Nov 18 17:29:25 2010 UTC

28 28
29#if XRENDER 29#if XRENDER
30# include <X11/extensions/Xrender.h> 30# include <X11/extensions/Xrender.h>
31#endif 31#endif
32 32
33#ifndef FilterConvolution
34#define FilterConvolution "convolution"
35#endif
36
33#define DO_TIMING_TEST 0 37#define DO_TIMING_TEST 0
34 38
35#if DO_TIMING_TEST 39#if DO_TIMING_TEST
36# include <sys/time.h> 40# include <sys/time.h>
37#define TIMING_TEST_START(id) \ 41#define TIMING_TEST_START(id) \
62 * 66 *
63 * WxH+X+Y Set scaling to W% by H%, and position to X% by Y%. 67 * WxH+X+Y Set scaling to W% by H%, and position to X% by Y%.
64 * W and H are percentages of the terminal window size. 68 * W and H are percentages of the terminal window size.
65 * X and Y are also percentages; e.g., +50+50 centers 69 * X and Y are also percentages; e.g., +50+50 centers
66 * the image in the window. 70 * the image in the window.
67 * WxH+X Assumes Y == X
68 * WxH Assumes Y == X == 50 (centers the image)
69 * W+X+Y Assumes H == W
70 * W+X Assumes H == W and Y == X
71 * W Assumes H == W and Y == X == 50
72 *
73 * Adjusting position only :
74 * =+X+Y Set position to X% by Y% (absolute).
75 * =+X Set position to X% by X%.
76 * +X+Y Adjust position horizontally X% and vertically Y%
77 * from current position (relative).
78 * +X Adjust position horizontally X% and vertically X%
79 * from current position.
80 *
81 * Adjusting scale only :
82 * Wx0 Multiply horizontal scaling factor by W%
83 * 0xH Multiply vertical scaling factor by H%
84 * 0x0 No scaling (show image at normal size).
85 * 71 *
86 * Pixmap Operations : (should be prepended by a colon) 72 * Pixmap Operations : (should be prepended by a colon)
87 * tile Tile image. Scaling/position modifiers above will affect 73 * tile Tile image. Scaling/position modifiers above will affect
88 * the tile size and origin. 74 * the tile size and origin.
89 * propscale When scaling, scale proportionally. That is, maintain the 75 * propscale When scaling, scale proportionally. That is, maintain the
172 return true; 158 return true;
173 } 159 }
174# endif 160# endif
175 161
176 return false; 162 return false;
177}; 163}
178 164
179bool bgPixmap_t::need_client_side_rendering () 165bool bgPixmap_t::need_client_side_rendering ()
180{ 166{
181# ifdef HAVE_AFTERIMAGE 167# ifdef HAVE_AFTERIMAGE
182 if (original_asim) 168 if (original_asim)
252 dst_size = target_size - dst_pos; 238 dst_size = target_size - dst_pos;
253 return src_pos; 239 return src_pos;
254} 240}
255 241
256bool 242bool
257bgPixmap_t::set_geometry (const char *geom) 243bgPixmap_t::set_geometry (const char *geom, bool update)
258{ 244{
259 bool changed = false; 245 bool changed = false;
260 int geom_flags = 0; 246 int geom_flags = 0;
261 int x = 0, y = 0; 247 int x = 0, y = 0;
262 unsigned int w = 0, h = 0; 248 unsigned int w = 0, h = 0;
263 unsigned int n; 249 unsigned int n;
264 unsigned long new_flags = (flags & (~geometryFlags)); 250 unsigned long new_flags = (flags & (~geometryFlags));
265 const char *p; 251 const char *ops;
266# define MAXLEN_GEOM 256 /* could be longer than regular geometry string */ 252# define MAXLEN_GEOM 256 /* could be longer than regular geometry string */
267 253
268 if (geom == NULL) 254 if (geom == NULL)
269 return false; 255 return false;
270 256
271 char str[MAXLEN_GEOM]; 257 char str[MAXLEN_GEOM];
272 258
273 while (isspace(*geom)) ++geom;
274 if ((p = strchr (geom, ';')) == NULL)
275 p = strchr (geom, '\0'); 259 ops = strchr (geom, ':');
276 260 if (ops == NULL)
261 n = strlen (geom);
262 else
277 n = (p - geom); 263 n = ops - geom;
264
278 if (n < MAXLEN_GEOM) 265 if (n < MAXLEN_GEOM)
279 { 266 {
280 char *ops;
281 new_flags |= geometrySet;
282
283 memcpy (str, geom, n); 267 memcpy (str, geom, n);
284 str[n] = '\0'; 268 str[n] = '\0';
269 rxvt_strtrim (str);
270
285 if (str[0] == ':') 271 if (str[0])
286 ops = &str[0];
287 else if (str[0] != 'x' && str[0] != 'X' && isalpha(str[0]))
288 ops = &str[0];
289 else
290 {
291 char *tmp;
292 ops = strchr (str, ':');
293 if (ops != NULL)
294 {
295 for (tmp = ops-1; tmp >= str && isspace(*tmp); --tmp);
296 *(++tmp) = '\0';
297 if (ops == tmp) ++ops;
298 }
299 }
300
301 if (ops > str || ops == NULL)
302 { 272 {
303 /* we have geometry string - let's handle it prior to applying ops */ 273 /* we have geometry string - let's handle it prior to applying ops */
304 geom_flags = XParseGeometry (str, &x, &y, &w, &h); 274 geom_flags = XParseGeometry (str, &x, &y, &w, &h);
305
306 if ((geom_flags & XValue) && !(geom_flags & YValue))
307 {
308 y = x;
309 geom_flags |= YValue;
310 }
311
312 if (flags & geometrySet)
313 {
314 /* new geometry is an adjustment to the old one ! */
315 if ((geom_flags & WidthValue) && (geom_flags & HeightValue))
316 {
317 if (w == 0 && h != 0)
318 {
319 w = h_scale;
320 h = (v_scale * h) / 100;
321 }
322 else if (h == 0 && w != 0)
323 {
324 w = (h_scale * w) / 100;
325 h = v_scale;
326 }
327 }
328 if (geom_flags & XValue)
329 {
330 if (str[0] != '=')
331 {
332 y += v_align;
333 x += h_align;
334 }
335 }
336 }
337 else /* setting up geometry from scratch */
338 {
339 if (!(geom_flags & XValue))
340 {
341 /* use default geometry - centered */
342 x = y = defaultAlign;
343 }
344 else if (!(geom_flags & YValue))
345 y = x;
346
347 if ((geom_flags & (WidthValue|HeightValue)) == 0)
348 {
349 /* use default geometry - scaled */
350 w = h = defaultScale;
351 }
352 else if (geom_flags & WidthValue)
353 {
354 if (!(geom_flags & HeightValue))
355 h = w;
356 }
357 else
358 w = h;
359 }
360 } /* done parsing geometry string */ 275 } /* done parsing geometry string */
361 else if (!(flags & geometrySet)) 276
277 if (!update)
362 { 278 {
363 /* default geometry - scaled and centered */ 279 if (!(geom_flags & XValue))
364 x = y = defaultAlign; 280 x = y = defaultAlign;
281 else if (!(geom_flags & YValue))
282 y = x;
283
284 if (!(geom_flags & (WidthValue|HeightValue)))
365 w = h = defaultScale; 285 w = h = defaultScale;
366 } 286 else if (!(geom_flags & HeightValue))
287 h = w;
288 else if (!(geom_flags & WidthValue))
289 w = h;
367 290
368 if (!(flags & geometrySet))
369 geom_flags |= WidthValue|HeightValue|XValue|YValue; 291 geom_flags |= WidthValue|HeightValue|XValue|YValue;
292 }
370 293
371 if (ops) 294 if (ops)
372 { 295 {
373 while (*ops) 296 while (*ops)
374 { 297 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines