… | |
… | |
50 | * Pixmap geometry string interpretation : |
50 | * Pixmap geometry string interpretation : |
51 | * Each geometry string contains zero or one scale/position |
51 | * Each geometry string contains zero or one scale/position |
52 | * adjustment and may optionally be followed by a colon and one or more |
52 | * adjustment and may optionally be followed by a colon and one or more |
53 | * colon-delimited pixmap operations. |
53 | * colon-delimited pixmap operations. |
54 | * The following table shows the valid geometry strings and their |
54 | * The following table shows the valid geometry strings and their |
55 | * affects on the background image : |
55 | * effects on the background image : |
56 | * |
56 | * |
57 | * WxH+X+Y Set scaling to W% by H%, and position to X% by Y%. |
57 | * WxH+X+Y Set scaling to W% by H%, and position to X% by Y%. |
58 | * W and H are percentages of the terminal window size. |
58 | * W and H are percentages of the terminal window size. |
59 | * X and Y are also percentages; e.g., +50+50 centers |
59 | * X and Y are also percentages; e.g., +50+50 centers |
60 | * the image in the window. |
60 | * the image in the window. |
… | |
… | |
441 | { |
441 | { |
442 | flags = new_flags; |
442 | flags = new_flags; |
443 | changed++; |
443 | changed++; |
444 | } |
444 | } |
445 | |
445 | |
446 | //fprintf (stderr, "flags = %lX, scale = %ux%u, align=%+d%+d\n", |
446 | //fprintf (stderr, "flags = %lX, scale = %ux%u, align=%+d%+d\n", |
447 | // flags, h_scale, v_scale, h_align, v_align); |
447 | // flags, h_scale, v_scale, h_align, v_align); |
448 | return (changed > 0); |
448 | return (changed > 0); |
449 | } |
449 | } |
450 | |
450 | |
451 | # ifdef HAVE_AFTERIMAGE |
451 | # ifdef HAVE_AFTERIMAGE |
452 | bool |
452 | bool |
453 | bgPixmap_t::render_asim (ASImage *background, ARGB32 background_tint) |
453 | bgPixmap_t::render_asim (unsigned long background_flags) |
454 | { |
454 | { |
455 | if (target == NULL) |
455 | if (target == NULL) |
456 | return false; |
456 | return false; |
457 | |
457 | |
458 | target->init_asv (); |
458 | target->init_asv (); |
|
|
459 | |
|
|
460 | ASImage *background = NULL; |
|
|
461 | ARGB32 background_tint = TINT_LEAVE_SAME; |
|
|
462 | |
|
|
463 | # ifdef ENABLE_TRANSPARENCY |
|
|
464 | if (background_flags) |
|
|
465 | background = pixmap2ximage (target->asv, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, 100); |
|
|
466 | |
|
|
467 | if (!(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
|
|
468 | { |
|
|
469 | ShadingInfo as_shade; |
|
|
470 | as_shade.shading = (shade == 0) ? 100 : shade; |
|
|
471 | |
|
|
472 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
|
|
473 | if (flags & tintSet) |
|
|
474 | tint.get (c); |
|
|
475 | as_shade.tintColor.red = c.r; |
|
|
476 | as_shade.tintColor.green = c.g; |
|
|
477 | as_shade.tintColor.blue = c.b; |
|
|
478 | |
|
|
479 | background_tint = shading2tint32 (&as_shade); |
|
|
480 | } |
|
|
481 | |
|
|
482 | if (!(background_flags & transpPmapBlured) && (flags & blurNeeded) && background != NULL) |
|
|
483 | { |
|
|
484 | ASImage *tmp = blur_asimage_gauss (target->asv, background, h_blurRadius, v_blurRadius, 0xFFFFFFFF, |
|
|
485 | (original_asim == NULL || tint == TINT_LEAVE_SAME) ? ASA_XImage : ASA_ASImage, |
|
|
486 | 100, ASIMAGE_QUALITY_DEFAULT); |
|
|
487 | if (tmp) |
|
|
488 | { |
|
|
489 | destroy_asimage (&background); |
|
|
490 | background = tmp; |
|
|
491 | } |
|
|
492 | } |
|
|
493 | # endif |
459 | |
494 | |
460 | ASImage *result = 0; |
495 | ASImage *result = 0; |
461 | |
496 | |
462 | int target_width = target->szHint.width; |
497 | int target_width = target->szHint.width; |
463 | int target_height = target->szHint.height; |
498 | int target_height = target->szHint.height; |
… | |
… | |
473 | |
508 | |
474 | if (original_asim) |
509 | if (original_asim) |
475 | { |
510 | { |
476 | if (h_align == rootAlign || v_align == rootAlign) |
511 | if (h_align == rootAlign || v_align == rootAlign) |
477 | { |
512 | { |
478 | target->get_window_origin(x, y); |
513 | target->get_window_origin (x, y); |
479 | x = -x; |
514 | x = -x; |
480 | y = -y; |
515 | y = -y; |
481 | } |
516 | } |
482 | |
517 | |
483 | if (h_align != rootAlign) |
518 | if (h_align != rootAlign) |
… | |
… | |
554 | } |
589 | } |
555 | else |
590 | else |
556 | { |
591 | { |
557 | /* if blending background and image - pixmap has to be sized same as target window */ |
592 | /* if blending background and image - pixmap has to be sized same as target window */ |
558 | ASImageLayer *layers = create_image_layers (2); |
593 | ASImageLayer *layers = create_image_layers (2); |
559 | ASImage *merged_im = NULL; |
|
|
560 | |
594 | |
561 | layers[0].im = background; |
595 | layers[0].im = background; |
562 | layers[0].clip_width = target_width; |
596 | layers[0].clip_width = target_width; |
563 | layers[0].clip_height = target_height; |
597 | layers[0].clip_height = target_height; |
564 | layers[0].tint = background_tint; |
598 | layers[0].tint = background_tint; |
… | |
… | |
636 | pixmap = XCreatePixmap (target->dpy, target->vt, new_pmap_width, new_pmap_height, target->depth); |
670 | pixmap = XCreatePixmap (target->dpy, target->vt, new_pmap_width, new_pmap_height, target->depth); |
637 | pmap_width = new_pmap_width; |
671 | pmap_width = new_pmap_width; |
638 | pmap_height = new_pmap_height; |
672 | pmap_height = new_pmap_height; |
639 | pmap_depth = target->depth; |
673 | pmap_depth = target->depth; |
640 | } |
674 | } |
641 | /* fill with background color ( if result's not completely overlapping it)*/ |
675 | /* fill with background color (if result's not completely overlapping it) */ |
642 | gcv.foreground = target->pix_colors[Color_bg]; |
676 | gcv.foreground = target->pix_colors[Color_bg]; |
643 | gc = XCreateGC (target->dpy, target->vt, GCForeground, &gcv); |
677 | gc = XCreateGC (target->dpy, target->vt, GCForeground, &gcv); |
644 | |
678 | |
645 | int src_x = 0, src_y = 0, dst_x = 0, dst_y = 0; |
679 | int src_x = 0, src_y = 0, dst_x = 0, dst_y = 0; |
646 | int dst_width = result->width, dst_height = result->height; |
680 | int dst_width = result->width, dst_height = result->height; |
… | |
… | |
664 | |
698 | |
665 | XFreeGC (target->dpy, gc); |
699 | XFreeGC (target->dpy, gc); |
666 | TIMING_TEST_PRINT_RESULT (asim); |
700 | TIMING_TEST_PRINT_RESULT (asim); |
667 | } |
701 | } |
668 | |
702 | |
|
|
703 | if (background) |
|
|
704 | destroy_asimage (&background); |
|
|
705 | |
669 | return true; |
706 | return true; |
670 | } |
707 | } |
671 | # endif /* HAVE_AFTERIMAGE */ |
708 | # endif /* HAVE_AFTERIMAGE */ |
672 | |
709 | |
673 | bool |
710 | bool |
… | |
… | |
675 | { |
712 | { |
676 | assert (file); |
713 | assert (file); |
677 | |
714 | |
678 | if (*file) |
715 | if (*file) |
679 | { |
716 | { |
|
|
717 | if (const char *p = strchr (file, ';')) |
|
|
718 | { |
|
|
719 | size_t len = p - file; |
|
|
720 | char *f = rxvt_temp_buf<char> (len + 1); |
|
|
721 | memcpy (f, file, len); |
|
|
722 | f[len] = '\0'; |
|
|
723 | file = f; |
|
|
724 | } |
|
|
725 | |
680 | # ifdef HAVE_AFTERIMAGE |
726 | # ifdef HAVE_AFTERIMAGE |
681 | if (!target->asimman) |
727 | if (!target->asimman) |
682 | target->asimman = create_generic_imageman (target->rs[Rs_path]); |
728 | target->asimman = create_generic_imageman (target->rs[Rs_path]); |
683 | |
|
|
684 | if (const char *p = strchr (file, ';')) |
|
|
685 | { |
|
|
686 | size_t len = p - file; |
|
|
687 | char *f = (char *)malloc (len + 1); |
|
|
688 | memcpy (f, file, len); |
|
|
689 | f[len] = '\0'; |
|
|
690 | original_asim = get_asimage (target->asimman, f, 0xFFFFFFFF, 100); |
|
|
691 | free (f); |
|
|
692 | } |
|
|
693 | else |
|
|
694 | original_asim = get_asimage (target->asimman, file, 0xFFFFFFFF, 100); |
729 | original_asim = get_asimage (target->asimman, file, 0xFFFFFFFF, 100); |
695 | |
|
|
696 | return original_asim; |
730 | return original_asim; |
697 | # endif |
731 | # endif |
698 | } |
732 | } |
699 | |
733 | |
700 | return false; |
734 | return false; |
… | |
… | |
770 | flags |= bgPixmap_t::tintNeeded; |
804 | flags |= bgPixmap_t::tintNeeded; |
771 | else if (tint) |
805 | else if (tint) |
772 | { |
806 | { |
773 | if ((c.r > 0x000700 || c.g > 0x000700 || c.b > 0x000700) |
807 | if ((c.r > 0x000700 || c.g > 0x000700 || c.b > 0x000700) |
774 | && (c.r < 0x00f700 || c.g < 0x00f700 || c.b < 0x00f700)) |
808 | && (c.r < 0x00f700 || c.g < 0x00f700 || c.b < 0x00f700)) |
775 | { |
809 | { |
776 | flags |= bgPixmap_t::tintNeeded; |
810 | flags |= bgPixmap_t::tintNeeded; |
777 | } |
811 | } |
778 | } |
812 | } |
779 | |
813 | |
780 | if (flags & bgPixmap_t::tintNeeded) |
814 | if (flags & bgPixmap_t::tintNeeded) |
781 | { |
815 | { |
782 | if (flags & bgPixmap_t::tintWholesome) |
816 | if (flags & bgPixmap_t::tintWholesome) |
… | |
… | |
811 | { |
845 | { |
812 | unsigned long new_flags = compute_tint_shade_flags (NULL, shade); |
846 | unsigned long new_flags = compute_tint_shade_flags (NULL, shade); |
813 | |
847 | |
814 | if (new_flags != (flags & tintFlags)) |
848 | if (new_flags != (flags & tintFlags)) |
815 | { |
849 | { |
816 | flags = (flags&~tintFlags)|new_flags; |
850 | flags = (flags&~tintFlags)|new_flags; |
817 | return true; |
851 | return true; |
818 | } |
852 | } |
819 | |
853 | |
820 | return false; |
854 | return false; |
821 | } |
855 | } |
822 | |
856 | |
… | |
… | |
907 | |
941 | |
908 | attr.background_pixmap = ParentRelative; |
942 | attr.background_pixmap = ParentRelative; |
909 | attr.backing_store = Always; |
943 | attr.backing_store = Always; |
910 | attr.event_mask = ExposureMask; |
944 | attr.event_mask = ExposureMask; |
911 | attr.override_redirect = True; |
945 | attr.override_redirect = True; |
912 | src = XCreateWindow (dpy, root, sx, sy, window_width, window_height, 0, |
946 | src = XCreateWindow (dpy, root, sx, sy, window_width, window_height, 0, |
913 | CopyFromParent, CopyFromParent, CopyFromParent, |
947 | CopyFromParent, CopyFromParent, CopyFromParent, |
914 | CWBackPixmap|CWBackingStore|CWOverrideRedirect|CWEventMask, |
948 | CWBackPixmap|CWBackingStore|CWOverrideRedirect|CWEventMask, |
915 | &attr); |
949 | &attr); |
916 | |
950 | |
917 | if (src != None) |
951 | if (src != None) |
… | |
… | |
941 | XDestroyWindow (dpy, src); |
975 | XDestroyWindow (dpy, src); |
942 | XUngrabServer (dpy); |
976 | XUngrabServer (dpy); |
943 | //fprintf (stderr, "%s:%d: ev_count = %d\n", __FUNCTION__, __LINE__, ev_count); |
977 | //fprintf (stderr, "%s:%d: ev_count = %d\n", __FUNCTION__, __LINE__, ev_count); |
944 | } |
978 | } |
945 | |
979 | |
946 | if (!success) |
980 | if (!success) |
947 | { |
981 | { |
948 | XFreePixmap (dpy, tiled_root_pmap); |
982 | XFreePixmap (dpy, tiled_root_pmap); |
949 | tiled_root_pmap = None; |
983 | tiled_root_pmap = None; |
950 | } |
984 | } |
951 | else |
985 | else |
952 | result |= transpPmapTiled; |
986 | result |= transpPmapTiled; |
953 | } |
987 | } |
954 | else |
988 | else |
955 | { |
989 | { |
956 | /* straightforward pixmap copy */ |
990 | /* straightforward pixmap copy */ |
957 | gcv.tile = root_pixmap; |
991 | gcv.tile = root_pixmap; |
… | |
… | |
1074 | # if DO_TIMING_TEST |
1108 | # if DO_TIMING_TEST |
1075 | XSync (dpy, False); |
1109 | XSync (dpy, False); |
1076 | # endif |
1110 | # endif |
1077 | # endif |
1111 | # endif |
1078 | } |
1112 | } |
1079 | } |
1113 | } |
1080 | } /* server side rendering completed */ |
1114 | } /* server side rendering completed */ |
1081 | |
1115 | |
1082 | if (pixmap) |
1116 | if (pixmap) |
1083 | XFreePixmap (dpy, pixmap); |
1117 | XFreePixmap (dpy, pixmap); |
1084 | |
1118 | |
… | |
… | |
1134 | /* we need to re-generate transparency pixmap in that case ! */ |
1168 | /* we need to re-generate transparency pixmap in that case ! */ |
1135 | background_flags = make_transparency_pixmap (); |
1169 | background_flags = make_transparency_pixmap (); |
1136 | if (background_flags == 0) |
1170 | if (background_flags == 0) |
1137 | return false; |
1171 | return false; |
1138 | else if ((background_flags & transpTransformations) == (flags & transpTransformations) |
1172 | else if ((background_flags & transpTransformations) == (flags & transpTransformations) |
1139 | && pmap_depth == target->depth) |
1173 | && pmap_depth == target->depth) |
1140 | flags = flags & ~isInvalid; |
1174 | flags = flags & ~isInvalid; |
1141 | } |
1175 | } |
1142 | # endif |
1176 | # endif |
1143 | |
1177 | |
1144 | XImage *result = NULL; |
|
|
1145 | # ifdef HAVE_AFTERIMAGE |
1178 | # ifdef HAVE_AFTERIMAGE |
1146 | if (original_asim |
1179 | if (original_asim |
1147 | || (background_flags & transpTransformations) != (flags & transpTransformations)) |
1180 | || (background_flags & transpTransformations) != (flags & transpTransformations)) |
1148 | { |
1181 | { |
1149 | target->init_asv (); |
|
|
1150 | |
|
|
1151 | ASImage *background = NULL; |
|
|
1152 | ARGB32 as_tint = TINT_LEAVE_SAME; |
|
|
1153 | if (background_flags) |
|
|
1154 | background = pixmap2ximage (target->asv, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, 100); |
|
|
1155 | |
|
|
1156 | # ifdef ENABLE_TRANSPARENCY |
|
|
1157 | if (!(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
|
|
1158 | { |
|
|
1159 | ShadingInfo as_shade; |
|
|
1160 | as_shade.shading = (shade == 0) ? 100 : shade; |
|
|
1161 | |
|
|
1162 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
|
|
1163 | if (flags & tintSet) |
|
|
1164 | tint.get (c); |
|
|
1165 | as_shade.tintColor.red = c.r; |
|
|
1166 | as_shade.tintColor.green = c.g; |
|
|
1167 | as_shade.tintColor.blue = c.b; |
|
|
1168 | |
|
|
1169 | as_tint = shading2tint32 (&as_shade); |
|
|
1170 | } |
|
|
1171 | |
|
|
1172 | if (!(background_flags & transpPmapBlured) && (flags & blurNeeded) && background != NULL) |
|
|
1173 | { |
|
|
1174 | ASImage *tmp = blur_asimage_gauss (target->asv, background, h_blurRadius, v_blurRadius, 0xFFFFFFFF, |
|
|
1175 | (original_asim == NULL || tint == TINT_LEAVE_SAME)?ASA_XImage:ASA_ASImage, |
|
|
1176 | 100, ASIMAGE_QUALITY_DEFAULT); |
|
|
1177 | if (tmp) |
|
|
1178 | { |
|
|
1179 | destroy_asimage (&background); |
|
|
1180 | background = tmp; |
|
|
1181 | } |
|
|
1182 | } |
|
|
1183 | # endif |
|
|
1184 | |
|
|
1185 | if (render_asim (background, as_tint)) |
1182 | if (render_asim (background_flags)) |
1186 | flags = flags & ~isInvalid; |
1183 | flags = flags & ~isInvalid; |
1187 | if (background) |
|
|
1188 | destroy_asimage (&background); |
|
|
1189 | } |
1184 | } |
1190 | else if (background_flags && pmap_depth != target->depth) |
1185 | # endif |
1191 | result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); |
|
|
1192 | |
1186 | |
1193 | # elif !XFT /* our own client-side tinting */ |
1187 | XImage *result = NULL; |
1194 | |
|
|
1195 | /* ATTENTION: We ASSUME that XFT will let us do all the tinting necessary server-side. |
|
|
1196 | This may need to be changed in need_client_side_rendering() logic is altered !!! */ |
|
|
1197 | |
1188 | |
1198 | if (background_flags && (flags & isInvalid)) |
1189 | if (background_flags && (flags & isInvalid)) |
1199 | { |
1190 | { |
1200 | result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); |
1191 | result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); |
1201 | |
1192 | |
|
|
1193 | # if !defined(HAVE_AFTERIMAGE) && !XFT |
|
|
1194 | /* our own client-side tinting */ |
|
|
1195 | /* ATTENTION: We ASSUME that XFT will let us do all the tinting necessary server-side. |
|
|
1196 | This may need to be changed in need_client_side_rendering() logic is altered !!! */ |
1202 | if (result != NULL && !(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
1197 | if (result != NULL && !(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
1203 | { |
1198 | { |
1204 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
1199 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
1205 | if (flags & tintSet) |
1200 | if (flags & tintSet) |
1206 | tint.get (c); |
1201 | tint.get (c); |
1207 | ShadeXImage (target, result, shade, c.r, c.g, c.b); |
1202 | ShadeXImage (target, result, shade, c.r, c.g, c.b); |
1208 | } |
1203 | } |
|
|
1204 | # endif |
1209 | } |
1205 | } |
1210 | # endif /* HAVE_AFTERIMAGE */ |
|
|
1211 | |
1206 | |
1212 | if (result) |
1207 | if (result) |
1213 | { |
1208 | { |
1214 | GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL); |
1209 | GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL); |
1215 | |
1210 | |
… | |
… | |
1247 | |
1242 | |
1248 | XFreeGC (target->dpy, gc); |
1243 | XFreeGC (target->dpy, gc); |
1249 | flags = flags & ~isInvalid; |
1244 | flags = flags & ~isInvalid; |
1250 | } |
1245 | } |
1251 | |
1246 | |
1252 | XDestroyImage (result); |
1247 | XDestroyImage (result); |
1253 | } |
1248 | } |
1254 | |
1249 | |
1255 | if (flags & isInvalid) |
1250 | if (flags & isInvalid) |
1256 | { |
1251 | { |
1257 | if (pixmap != None) |
1252 | if (pixmap != None) |