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.118 by sf-exg, Tue Nov 16 15:49:56 2010 UTC vs.
Revision 1.119 by sf-exg, Thu Nov 18 17:28:12 2010 UTC

66 * 66 *
67 * 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%.
68 * W and H are percentages of the terminal window size. 68 * W and H are percentages of the terminal window size.
69 * X and Y are also percentages; e.g., +50+50 centers 69 * X and Y are also percentages; e.g., +50+50 centers
70 * the image in the window. 70 * the image in the window.
71 * WxH+X Assumes Y == X
72 * WxH Assumes Y == X == 50 (centers the image)
73 * W+X+Y Assumes H == W
74 * W+X Assumes H == W and Y == X
75 * W Assumes H == W and Y == X == 50
76 *
77 * Adjusting position only :
78 * =+X+Y Set position to X% by Y% (absolute).
79 * =+X Set position to X% by X%.
80 * +X+Y Adjust position horizontally X% and vertically Y%
81 * from current position (relative).
82 * +X Adjust position horizontally X% and vertically X%
83 * from current position.
84 *
85 * Adjusting scale only :
86 * Wx0 Multiply horizontal scaling factor by W%
87 * 0xH Multiply vertical scaling factor by H%
88 * 0x0 No scaling (show image at normal size).
89 * 71 *
90 * Pixmap Operations : (should be prepended by a colon) 72 * Pixmap Operations : (should be prepended by a colon)
91 * tile Tile image. Scaling/position modifiers above will affect 73 * tile Tile image. Scaling/position modifiers above will affect
92 * the tile size and origin. 74 * the tile size and origin.
93 * propscale When scaling, scale proportionally. That is, maintain the 75 * propscale When scaling, scale proportionally. That is, maintain the
256 dst_size = target_size - dst_pos; 238 dst_size = target_size - dst_pos;
257 return src_pos; 239 return src_pos;
258} 240}
259 241
260bool 242bool
261bgPixmap_t::set_geometry (const char *geom) 243bgPixmap_t::set_geometry (const char *geom, bool update)
262{ 244{
263 bool changed = false; 245 bool changed = false;
264 int geom_flags = 0; 246 int geom_flags = 0;
265 int x = 0, y = 0; 247 int x = 0, y = 0;
266 unsigned int w = 0, h = 0; 248 unsigned int w = 0, h = 0;
280 262
281 n = (p - geom); 263 n = (p - geom);
282 if (n < MAXLEN_GEOM) 264 if (n < MAXLEN_GEOM)
283 { 265 {
284 char *ops; 266 char *ops;
285 new_flags |= geometrySet;
286 267
287 memcpy (str, geom, n); 268 memcpy (str, geom, n);
288 str[n] = '\0'; 269 str[n] = '\0';
289 if (str[0] == ':') 270 if (str[0] == ':')
290 ops = &str[0]; 271 ops = &str[0];
305 if (ops > str || ops == NULL) 286 if (ops > str || ops == NULL)
306 { 287 {
307 /* we have geometry string - let's handle it prior to applying ops */ 288 /* we have geometry string - let's handle it prior to applying ops */
308 geom_flags = XParseGeometry (str, &x, &y, &w, &h); 289 geom_flags = XParseGeometry (str, &x, &y, &w, &h);
309 290
310 if ((geom_flags & XValue) && !(geom_flags & YValue))
311 {
312 y = x;
313 geom_flags |= YValue;
314 }
315
316 if (flags & geometrySet)
317 {
318 /* new geometry is an adjustment to the old one ! */
319 if ((geom_flags & WidthValue) && (geom_flags & HeightValue))
320 {
321 if (w == 0 && h != 0)
322 {
323 w = h_scale;
324 h = (v_scale * h) / 100;
325 }
326 else if (h == 0 && w != 0)
327 {
328 w = (h_scale * w) / 100;
329 h = v_scale;
330 }
331 }
332 if (geom_flags & XValue)
333 {
334 if (str[0] != '=')
335 {
336 y += v_align;
337 x += h_align;
338 }
339 }
340 }
341 else /* setting up geometry from scratch */ 291 if (!update) /* setting up geometry from scratch */
342 { 292 {
343 if (!(geom_flags & XValue)) 293 if (!(geom_flags & XValue))
344 { 294 {
345 /* use default geometry - centered */ 295 /* use default geometry - centered */
346 x = y = defaultAlign; 296 x = y = defaultAlign;
360 } 310 }
361 else 311 else
362 w = h; 312 w = h;
363 } 313 }
364 } /* done parsing geometry string */ 314 } /* done parsing geometry string */
365 else if (!(flags & geometrySet)) 315 else if (!update)
366 { 316 {
367 /* default geometry - scaled and centered */ 317 /* default geometry - scaled and centered */
368 x = y = defaultAlign; 318 x = y = defaultAlign;
369 w = h = defaultScale; 319 w = h = defaultScale;
370 } 320 }
371 321
372 if (!(flags & geometrySet)) 322 if (!update)
373 geom_flags |= WidthValue|HeightValue|XValue|YValue; 323 geom_flags |= WidthValue|HeightValue|XValue|YValue;
374 324
375 if (ops) 325 if (ops)
376 { 326 {
377 while (*ops) 327 while (*ops)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines