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.113 by sf-exg, Sat Nov 6 17:51:11 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 {
666 if (result) 589 if (result)
667 { 590 {
668 XGCValues gcv; 591 XGCValues gcv;
669 GC gc; 592 GC gc;
670 593
671 if (pixmap)
672 {
673 if (pmap_width != new_pmap_width
674 || pmap_height != new_pmap_height
675 || pmap_depth != target->depth)
676 {
677 XFreePixmap (target->dpy, pixmap);
678 pixmap = None;
679 }
680 }
681
682 /* create Pixmap */ 594 /* create Pixmap */
683 if (pixmap == None) 595 if (pixmap == None
596 || pmap_width != new_pmap_width
597 || pmap_height != new_pmap_height
598 || pmap_depth != target->depth)
684 { 599 {
600 if (pixmap)
601 XFreePixmap (target->dpy, pixmap);
685 pixmap = XCreatePixmap (target->dpy, target->vt, new_pmap_width, new_pmap_height, target->depth); 602 pixmap = XCreatePixmap (target->dpy, target->vt, new_pmap_width, new_pmap_height, target->depth);
686 pmap_width = new_pmap_width; 603 pmap_width = new_pmap_width;
687 pmap_height = new_pmap_height; 604 pmap_height = new_pmap_height;
688 pmap_depth = target->depth; 605 pmap_depth = target->depth;
689 } 606 }
797 new_pmap_width = min (image_width, target_width); 714 new_pmap_width = min (image_width, target_width);
798 new_pmap_height = min (image_height, target_height); 715 new_pmap_height = min (image_height, target_height);
799 } 716 }
800 } 717 }
801 718
802 if (pixmap)
803 {
804 if (pmap_width != new_pmap_width
805 || pmap_height != new_pmap_height
806 || pmap_depth != target->depth)
807 {
808 XFreePixmap (target->dpy, pixmap);
809 pixmap = None;
810 }
811 }
812
813 if (pixmap == None) 719 if (pixmap == None
720 || pmap_width != new_pmap_width
721 || pmap_height != new_pmap_height
722 || pmap_depth != target->depth)
814 { 723 {
724 if (pixmap)
725 XFreePixmap (target->dpy, pixmap);
815 pixmap = XCreatePixmap (target->dpy, target->vt, new_pmap_width, new_pmap_height, target->depth); 726 pixmap = XCreatePixmap (target->dpy, target->vt, new_pmap_width, new_pmap_height, target->depth);
816 pmap_width = new_pmap_width; 727 pmap_width = new_pmap_width;
817 pmap_height = new_pmap_height; 728 pmap_height = new_pmap_height;
818 pmap_depth = target->depth; 729 pmap_depth = target->depth;
819 } 730 }
1239 1150
1240 if (mask_pic && overlay_pic && back_pic) 1151 if (mask_pic && overlay_pic && back_pic)
1241 { 1152 {
1242 XRenderColor mask_c; 1153 XRenderColor mask_c;
1243 1154
1244 memset (&mask_c, (shade > 100) ? 0xFF : 0x0, sizeof (mask_c)); 1155 mask_c.red = mask_c.green = mask_c.blue = shade > 100 ? 0xffff : 0;
1245 mask_c.alpha = 0xffff; 1156 mask_c.alpha = 0xffff;
1246 XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); 1157 XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1);
1247 1158
1248 mask_c.alpha = 0; 1159 mask_c.alpha = 0;
1249 mask_c.red = 0xffff - c.r; 1160 mask_c.red = 0xffff - c.r;
1367 if (gc) 1278 if (gc)
1368 { 1279 {
1369 XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height); 1280 XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height);
1370 result |= transpPmapTiled; 1281 result |= transpPmapTiled;
1371 XFreeGC (dpy, gc); 1282 XFreeGC (dpy, gc);
1372 }
1373 1283
1374 if (tiled_root_pmap != None)
1375 {
1376 if (!need_client_side_rendering ()) 1284 if (!need_client_side_rendering ())
1377 { 1285 {
1378 if ((flags & blurNeeded) 1286 if ((flags & blurNeeded)
1379 && (flags & HAS_RENDER_CONV)) 1287 && (flags & HAS_RENDER_CONV))
1380 { 1288 {
1395 pixmap = tiled_root_pmap; 1303 pixmap = tiled_root_pmap;
1396 pmap_width = window_width; 1304 pmap_width = window_width;
1397 pmap_height = window_height; 1305 pmap_height = window_height;
1398 pmap_depth = target->depth; 1306 pmap_depth = target->depth;
1399 } 1307 }
1308 else
1309 XFreePixmap (dpy, tiled_root_pmap);
1400 1310
1401 if (recoded_root_pmap != root_pixmap) 1311 if (recoded_root_pmap != root_pixmap)
1402 XFreePixmap (dpy, recoded_root_pmap); 1312 XFreePixmap (dpy, recoded_root_pmap);
1403 1313
1404 return result; 1314 return result;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines