… | |
… | |
274 | h = w; |
274 | h = w; |
275 | else if (!(geom_flags & WidthValue)) |
275 | else if (!(geom_flags & WidthValue)) |
276 | w = h; |
276 | w = h; |
277 | } |
277 | } |
278 | |
278 | |
279 | min_it (w, 1000); |
|
|
280 | min_it (h, 1000); |
|
|
281 | clamp_it (x, -100, 200); |
279 | clamp_it (x, -100, 200); |
282 | clamp_it (y, -100, 200); |
280 | clamp_it (y, -100, 200); |
283 | |
281 | |
284 | if (flags != new_flags |
282 | if (flags != new_flags |
285 | || h_scale != w |
283 | || h_scale != w |
… | |
… | |
310 | { |
308 | { |
311 | int image_width = image.width (); |
309 | int image_width = image.width (); |
312 | int image_height = image.height (); |
310 | int image_height = image.height (); |
313 | int target_width = szHint.width; |
311 | int target_width = szHint.width; |
314 | int target_height = szHint.height; |
312 | int target_height = szHint.height; |
|
|
313 | int h_scale = min (image.h_scale, 32767 * 100 / target_width); |
|
|
314 | int v_scale = min (image.v_scale, 32767 * 100 / target_height); |
315 | |
315 | |
316 | w = image.h_scale * target_width / 100; |
316 | w = h_scale * target_width / 100; |
317 | h = image.v_scale * target_height / 100; |
317 | h = v_scale * target_height / 100; |
318 | |
318 | |
319 | if (image.flags & IM_KEEP_ASPECT) |
319 | if (image.flags & IM_KEEP_ASPECT) |
320 | { |
320 | { |
321 | float scale = (float)w / image_width; |
321 | float scale = (float)w / image_width; |
322 | min_it (scale, (float)h / image_height); |
322 | min_it (scale, (float)h / image_height); |
… | |
… | |
452 | XDestroyImage (ximage); |
452 | XDestroyImage (ximage); |
453 | return true; |
453 | return true; |
454 | } |
454 | } |
455 | |
455 | |
456 | bool |
456 | bool |
457 | rxvt_term::render_image (rxvt_image &image, bool transparent) |
457 | rxvt_term::render_image (rxvt_image &image) |
458 | { |
458 | { |
459 | GdkPixbuf *pixbuf = image.pixbuf; |
459 | GdkPixbuf *pixbuf = image.pixbuf; |
460 | if (!pixbuf) |
460 | if (!pixbuf) |
461 | return false; |
461 | return false; |
462 | |
462 | |
463 | if (transparent |
463 | bool need_blend = bg_flags & BG_IS_VALID; |
|
|
464 | |
|
|
465 | if (need_blend |
464 | && !(bg_flags & BG_HAS_RENDER)) |
466 | && !(bg_flags & BG_HAS_RENDER)) |
465 | return false; |
467 | return false; |
466 | |
468 | |
467 | GdkPixbuf *result; |
469 | GdkPixbuf *result; |
468 | |
470 | |
… | |
… | |
503 | |
505 | |
504 | bool ret = false; |
506 | bool ret = false; |
505 | |
507 | |
506 | XGCValues gcv; |
508 | XGCValues gcv; |
507 | GC gc; |
509 | GC gc; |
508 | Pixmap root_pmap; |
510 | Pixmap tmp_pixmap; |
509 | |
511 | |
510 | image_width = gdk_pixbuf_get_width (result); |
512 | image_width = gdk_pixbuf_get_width (result); |
511 | image_height = gdk_pixbuf_get_height (result); |
513 | image_height = gdk_pixbuf_get_height (result); |
512 | |
514 | |
513 | if (transparent) |
515 | if (need_blend) |
514 | { |
516 | { |
515 | root_pmap = bg_pixmap; |
517 | tmp_pixmap = bg_pixmap; |
516 | bg_pixmap = None; |
518 | bg_pixmap = None; |
517 | } |
519 | } |
518 | else |
520 | else |
519 | { |
521 | { |
520 | if (image.flags & IM_TILE) |
522 | if (image.flags & IM_TILE) |
… | |
… | |
576 | dst_x, dst_y, |
578 | dst_x, dst_y, |
577 | dst_width, dst_height); |
579 | dst_width, dst_height); |
578 | } |
580 | } |
579 | |
581 | |
580 | #if XRENDER |
582 | #if XRENDER |
581 | if (transparent) |
583 | if (need_blend) |
582 | { |
584 | { |
583 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
585 | XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); |
584 | |
586 | |
585 | Picture src = XRenderCreatePicture (dpy, root_pmap, format, 0, 0); |
587 | Picture src = XRenderCreatePicture (dpy, tmp_pixmap, format, 0, 0); |
586 | |
588 | |
587 | Picture dst = XRenderCreatePicture (dpy, bg_pixmap, format, 0, 0); |
589 | Picture dst = XRenderCreatePicture (dpy, bg_pixmap, format, 0, 0); |
588 | |
590 | |
589 | Picture mask = create_xrender_mask (dpy, vt, False, False); |
591 | Picture mask = create_xrender_mask (dpy, vt, False, False); |
590 | |
592 | |
… | |
… | |
610 | } |
612 | } |
611 | |
613 | |
612 | if (result != pixbuf) |
614 | if (result != pixbuf) |
613 | g_object_unref (result); |
615 | g_object_unref (result); |
614 | |
616 | |
615 | if (transparent) |
617 | if (need_blend) |
616 | XFreePixmap (dpy, root_pmap); |
618 | XFreePixmap (dpy, tmp_pixmap); |
617 | |
619 | |
618 | return ret; |
620 | return ret; |
619 | } |
621 | } |
620 | # endif /* HAVE_PIXBUF */ |
622 | # endif /* HAVE_PIXBUF */ |
621 | |
623 | |
… | |
… | |
642 | if (image) |
644 | if (image) |
643 | { |
645 | { |
644 | if (pixbuf) |
646 | if (pixbuf) |
645 | g_object_unref (pixbuf); |
647 | g_object_unref (pixbuf); |
646 | pixbuf = image; |
648 | pixbuf = image; |
647 | flags |= IM_IS_SET; |
|
|
648 | ret = true; |
649 | ret = true; |
649 | } |
650 | } |
650 | # endif |
651 | # endif |
651 | |
652 | |
652 | if (ret) |
653 | if (ret) |
653 | { |
654 | { |
|
|
655 | flags = IM_IS_SET | IM_IS_SIZE_SENSITIVE; |
|
|
656 | h_scale = v_scale = defaultScale; |
|
|
657 | h_align = v_align = defaultAlign; |
|
|
658 | |
654 | if (p) |
659 | if (p) |
655 | set_geometry (p + 1); |
660 | set_geometry (p + 1); |
656 | else |
|
|
657 | set_default_geometry (); |
|
|
658 | } |
661 | } |
659 | |
662 | |
660 | return ret; |
663 | return ret; |
661 | } |
664 | } |
662 | |
665 | |
… | |
… | |
1064 | # endif /* ENABLE_TRANSPARENCY */ |
1067 | # endif /* ENABLE_TRANSPARENCY */ |
1065 | |
1068 | |
1066 | bool |
1069 | bool |
1067 | rxvt_term::bg_render () |
1070 | rxvt_term::bg_render () |
1068 | { |
1071 | { |
1069 | bool transparent = false; |
|
|
1070 | |
|
|
1071 | bg_invalidate (); |
1072 | bg_invalidate (); |
1072 | # ifdef ENABLE_TRANSPARENCY |
1073 | # ifdef ENABLE_TRANSPARENCY |
1073 | if (bg_flags & BG_IS_TRANSPARENT) |
1074 | if (bg_flags & BG_IS_TRANSPARENT) |
1074 | { |
1075 | { |
1075 | /* we need to re-generate transparency pixmap in that case ! */ |
1076 | /* we need to re-generate transparency pixmap in that case ! */ |
1076 | transparent = make_transparency_pixmap (); |
1077 | if (make_transparency_pixmap ()) |
1077 | if (transparent) |
|
|
1078 | bg_flags |= BG_IS_VALID; |
1078 | bg_flags |= BG_IS_VALID; |
1079 | } |
1079 | } |
1080 | # endif |
1080 | # endif |
1081 | |
1081 | |
1082 | # ifdef BG_IMAGE_FROM_FILE |
1082 | # ifdef BG_IMAGE_FROM_FILE |
1083 | if (bg_image.flags & IM_IS_SET) |
1083 | if (bg_image.flags & IM_IS_SET) |
1084 | { |
1084 | { |
1085 | if (render_image (bg_image, transparent)) |
1085 | if (render_image (bg_image)) |
1086 | bg_flags |= BG_IS_VALID; |
1086 | bg_flags |= BG_IS_VALID; |
1087 | } |
1087 | } |
1088 | # endif |
1088 | # endif |
1089 | |
1089 | |
1090 | if (!(bg_flags & BG_IS_VALID)) |
1090 | if (!(bg_flags & BG_IS_VALID)) |