… | |
… | |
46 | * W and H are percentages of the terminal window size. |
46 | * W and H are percentages of the terminal window size. |
47 | * X and Y are also percentages; e.g., +50+50 centers |
47 | * X and Y are also percentages; e.g., +50+50 centers |
48 | * the image in the window. |
48 | * the image in the window. |
49 | * |
49 | * |
50 | * Pixmap Operations : (should be prepended by a colon) |
50 | * Pixmap Operations : (should be prepended by a colon) |
51 | * tile Tile image. Scaling/position modifiers above will affect |
|
|
52 | * the tile size and origin. |
|
|
53 | * propscale When scaling, scale proportionally. That is, maintain the |
|
|
54 | * proper aspect ratio for the image. Any portion of the |
|
|
55 | * background not covered by the image is filled with the |
|
|
56 | * current background color. |
|
|
57 | * hscale Scale horizontally, tile vertically ? |
|
|
58 | * vscale Tile horizontally, scale vertically ? |
|
|
59 | * scale Scale both up and down |
|
|
60 | * auto Same as 100x100+50+50 |
|
|
61 | */ |
51 | */ |
62 | |
52 | |
63 | #ifdef HAVE_BG_PIXMAP |
53 | #ifdef HAVE_BG_PIXMAP |
64 | void |
54 | void |
65 | rxvt_term::bg_destroy () |
55 | rxvt_term::bg_destroy () |
… | |
… | |
258 | { |
248 | { |
259 | char **arr = rxvt_strsplit (':', ops + 1); |
249 | char **arr = rxvt_strsplit (':', ops + 1); |
260 | |
250 | |
261 | for (int i = 0; arr[i]; i++) |
251 | for (int i = 0; arr[i]; i++) |
262 | { |
252 | { |
|
|
253 | if (!strcasecmp (arr[i], "style=tiled")) |
|
|
254 | { |
|
|
255 | new_flags = BG_TILE; |
|
|
256 | w = h = noScale; |
|
|
257 | x = y = 0; |
|
|
258 | geom_flags = WidthValue|HeightValue|XValue|YValue; |
|
|
259 | } |
|
|
260 | else if (!strcasecmp (arr[i], "style=aspect-stretched")) |
|
|
261 | { |
|
|
262 | new_flags = BG_PROP_SCALE; |
|
|
263 | x = y = centerAlign; |
|
|
264 | geom_flags = XValue|YValue; |
|
|
265 | } |
|
|
266 | else if (!strcasecmp (arr[i], "style=stretched")) |
|
|
267 | { |
|
|
268 | new_flags = 0; |
|
|
269 | w = h = windowScale; |
|
|
270 | geom_flags = WidthValue|HeightValue; |
|
|
271 | } |
|
|
272 | else if (!strcasecmp (arr[i], "style=centered")) |
|
|
273 | { |
|
|
274 | new_flags = 0; |
|
|
275 | w = h = noScale; |
|
|
276 | x = y = centerAlign; |
|
|
277 | geom_flags = WidthValue|HeightValue|XValue|YValue; |
|
|
278 | } |
|
|
279 | else if (!strcasecmp (arr[i], "style=root-tiled")) |
|
|
280 | { |
|
|
281 | new_flags = BG_TILE|BG_ROOT_ALIGN; |
|
|
282 | w = h = noScale; |
|
|
283 | geom_flags = WidthValue|HeightValue; |
|
|
284 | } |
|
|
285 | else if (!strcasecmp (arr[i], "op=tile")) |
|
|
286 | new_flags |= BG_TILE; |
|
|
287 | else if (!strcasecmp (arr[i], "op=pscale")) |
|
|
288 | new_flags |= BG_PROP_SCALE; |
|
|
289 | else if (!strcasecmp (arr[i], "op=root")) |
|
|
290 | new_flags |= BG_ROOT_ALIGN; |
|
|
291 | |
|
|
292 | // deprecated |
263 | if (!strcasecmp (arr[i], "tile")) |
293 | else if (!strcasecmp (arr[i], "tile")) |
264 | { |
294 | { |
|
|
295 | new_flags |= BG_TILE; |
265 | w = h = noScale; |
296 | w = h = noScale; |
266 | geom_flags |= WidthValue|HeightValue; |
297 | geom_flags |= WidthValue|HeightValue; |
267 | } |
298 | } |
268 | else if (!strcasecmp (arr[i], "propscale")) |
299 | else if (!strcasecmp (arr[i], "propscale")) |
269 | { |
300 | { |
270 | new_flags |= BG_PROP_SCALE; |
301 | new_flags |= BG_PROP_SCALE; |
271 | } |
302 | } |
272 | else if (!strcasecmp (arr[i], "hscale")) |
303 | else if (!strcasecmp (arr[i], "hscale")) |
273 | { |
304 | { |
|
|
305 | new_flags |= BG_TILE; |
274 | if (w == 0) w = windowScale; |
306 | w = windowScale; |
275 | |
|
|
276 | h = noScale; |
307 | h = noScale; |
277 | geom_flags |= WidthValue|HeightValue; |
308 | geom_flags |= WidthValue|HeightValue; |
278 | } |
309 | } |
279 | else if (!strcasecmp (arr[i], "vscale")) |
310 | else if (!strcasecmp (arr[i], "vscale")) |
280 | { |
311 | { |
|
|
312 | new_flags |= BG_TILE; |
281 | if (h == 0) h = windowScale; |
313 | h = windowScale; |
282 | |
|
|
283 | w = noScale; |
314 | w = noScale; |
284 | geom_flags |= WidthValue|HeightValue; |
315 | geom_flags |= WidthValue|HeightValue; |
285 | } |
316 | } |
286 | else if (!strcasecmp (arr[i], "scale")) |
317 | else if (!strcasecmp (arr[i], "scale")) |
287 | { |
318 | { |
288 | if (h == 0) h = windowScale; |
|
|
289 | if (w == 0) w = windowScale; |
319 | w = h = windowScale; |
290 | |
|
|
291 | geom_flags |= WidthValue|HeightValue; |
320 | geom_flags |= WidthValue|HeightValue; |
292 | } |
321 | } |
293 | else if (!strcasecmp (arr[i], "auto")) |
322 | else if (!strcasecmp (arr[i], "auto")) |
294 | { |
323 | { |
295 | w = h = windowScale; |
324 | w = h = windowScale; |
296 | x = y = centerAlign; |
325 | x = y = centerAlign; |
297 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
326 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
298 | } |
327 | } |
299 | else if (!strcasecmp (arr[i], "root")) |
328 | else if (!strcasecmp (arr[i], "root")) |
300 | { |
329 | { |
301 | new_flags |= BG_ROOT_ALIGN; |
330 | new_flags |= BG_TILE|BG_ROOT_ALIGN; |
302 | w = h = noScale; |
331 | w = h = noScale; |
303 | geom_flags |= WidthValue|HeightValue; |
332 | geom_flags |= WidthValue|HeightValue; |
304 | } |
333 | } |
305 | } /* done parsing ops */ |
334 | } /* done parsing ops */ |
306 | |
335 | |
… | |
… | |
353 | x = make_align_position (h_align, target_width, w); |
382 | x = make_align_position (h_align, target_width, w); |
354 | y = make_align_position (v_align, target_height, h); |
383 | y = make_align_position (v_align, target_height, h); |
355 | } |
384 | } |
356 | |
385 | |
357 | bg_flags &= ~BG_IS_SIZE_SENSITIVE; |
386 | bg_flags &= ~BG_IS_SIZE_SENSITIVE; |
|
|
387 | if (!(bg_flags & BG_TILE) |
358 | if ((bg_flags & BG_PROP_SCALE) || h_scale || v_scale |
388 | || (bg_flags & BG_PROP_SCALE) || h_scale || v_scale |
359 | || (!(bg_flags & BG_ROOT_ALIGN) && (h_align || v_align)) |
389 | || (!(bg_flags & BG_ROOT_ALIGN) && (h_align || v_align)) |
360 | || w > target_width || h > target_height) |
390 | || w > target_width || h > target_height) |
361 | bg_flags |= BG_IS_SIZE_SENSITIVE; |
391 | bg_flags |= BG_IS_SIZE_SENSITIVE; |
362 | } |
392 | } |
363 | |
393 | |
… | |
… | |
455 | 100, ASIMAGE_QUALITY_DEFAULT); |
485 | 100, ASIMAGE_QUALITY_DEFAULT); |
456 | } |
486 | } |
457 | |
487 | |
458 | if (background == NULL) |
488 | if (background == NULL) |
459 | { |
489 | { |
460 | if (h_scale == 0 || v_scale == 0) |
490 | if (bg_flags & BG_TILE) |
461 | { |
491 | { |
462 | /* if tiling - pixmap has to be sized exactly as the image, |
492 | /* if tiling - pixmap has to be sized exactly as the image, |
463 | but there is no need to make it bigger than the window! */ |
493 | but there is no need to make it bigger than the window! */ |
464 | new_pmap_width = min (result->width, target_width); |
494 | new_pmap_width = min (result->width, target_width); |
465 | new_pmap_height = min (result->height, target_height); |
495 | new_pmap_height = min (result->height, target_height); |
… | |
… | |
490 | layers[0].clip_width = target_width; |
520 | layers[0].clip_width = target_width; |
491 | layers[0].clip_height = target_height; |
521 | layers[0].clip_height = target_height; |
492 | layers[0].tint = background_tint; |
522 | layers[0].tint = background_tint; |
493 | layers[1].im = result; |
523 | layers[1].im = result; |
494 | |
524 | |
495 | if (h_scale == 0 || v_scale == 0) |
525 | if (bg_flags & BG_TILE) |
496 | { |
526 | { |
497 | /* tile horizontally */ |
527 | /* tile horizontally */ |
498 | while (x > 0) x -= (int)result->width; |
528 | while (x > 0) x -= (int)result->width; |
499 | layers[1].dst_x = x; |
529 | layers[1].dst_x = x; |
500 | layers[1].clip_width = result->width+target_width; |
530 | layers[1].clip_width = result->width+target_width; |
… | |
… | |
504 | /* clip horizontally */ |
534 | /* clip horizontally */ |
505 | layers[1].dst_x = x; |
535 | layers[1].dst_x = x; |
506 | layers[1].clip_width = result->width; |
536 | layers[1].clip_width = result->width; |
507 | } |
537 | } |
508 | |
538 | |
509 | if (h_scale == 0 || v_scale == 0) |
539 | if (bg_flags & BG_TILE) |
510 | { |
540 | { |
511 | while (y > 0) y -= (int)result->height; |
541 | while (y > 0) y -= (int)result->height; |
512 | layers[1].dst_y = y; |
542 | layers[1].dst_y = y; |
513 | layers[1].clip_height = result->height + target_height; |
543 | layers[1].clip_height = result->height + target_height; |
514 | } |
544 | } |
… | |
… | |
564 | |
594 | |
565 | int src_x = 0, src_y = 0, dst_x = 0, dst_y = 0; |
595 | int src_x = 0, src_y = 0, dst_x = 0, dst_y = 0; |
566 | int dst_width = result->width, dst_height = result->height; |
596 | int dst_width = result->width, dst_height = result->height; |
567 | if (background == NULL) |
597 | if (background == NULL) |
568 | { |
598 | { |
569 | if (!(h_scale == 0 || v_scale == 0)) |
599 | if (!(bg_flags & BG_TILE)) |
570 | { |
600 | { |
571 | src_x = make_clip_rectangle (x, result->width , new_pmap_width , dst_x, dst_width ); |
601 | src_x = make_clip_rectangle (x, result->width , new_pmap_width , dst_x, dst_width ); |
572 | src_y = make_clip_rectangle (y, result->height, new_pmap_height, dst_y, dst_height); |
602 | src_y = make_clip_rectangle (y, result->height, new_pmap_height, dst_y, dst_height); |
573 | } |
603 | } |
574 | |
604 | |
… | |
… | |
742 | root_pmap = bg_pixmap; |
772 | root_pmap = bg_pixmap; |
743 | bg_pixmap = None; |
773 | bg_pixmap = None; |
744 | } |
774 | } |
745 | else |
775 | else |
746 | { |
776 | { |
747 | if (h_scale == 0 || v_scale == 0) |
777 | if (bg_flags & BG_TILE) |
748 | { |
778 | { |
749 | new_pmap_width = min (image_width, target_width); |
779 | new_pmap_width = min (image_width, target_width); |
750 | new_pmap_height = min (image_height, target_height); |
780 | new_pmap_height = min (image_height, target_height); |
751 | } |
781 | } |
752 | } |
782 | } |
… | |
… | |
765 | gcv.foreground = pix_colors[Color_bg]; |
795 | gcv.foreground = pix_colors[Color_bg]; |
766 | gc = XCreateGC (dpy, vt, GCForeground, &gcv); |
796 | gc = XCreateGC (dpy, vt, GCForeground, &gcv); |
767 | |
797 | |
768 | if (gc) |
798 | if (gc) |
769 | { |
799 | { |
770 | if (h_scale == 0 || v_scale == 0) |
800 | if (bg_flags & BG_TILE) |
771 | { |
801 | { |
772 | Pixmap tile = XCreatePixmap (dpy, vt, image_width, image_height, depth); |
802 | Pixmap tile = XCreatePixmap (dpy, vt, image_width, image_height, depth); |
773 | pixbuf_to_pixmap (result, tile, gc, |
803 | pixbuf_to_pixmap (result, tile, gc, |
774 | 0, 0, |
804 | 0, 0, |
775 | 0, 0, |
805 | 0, 0, |