… | |
… | |
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. |
… | |
… | |
97 | // zero_initialised-derived structs |
97 | // zero_initialised-derived structs |
98 | #ifdef HAVE_AFTERIMAGE |
98 | #ifdef HAVE_AFTERIMAGE |
99 | original_asim = NULL; |
99 | original_asim = NULL; |
100 | #endif |
100 | #endif |
101 | #ifdef BG_IMAGE_FROM_FILE |
101 | #ifdef BG_IMAGE_FROM_FILE |
|
|
102 | have_image = false; |
102 | h_scale = v_scale = 0; |
103 | h_scale = v_scale = 0; |
103 | h_align = v_align = 0; |
104 | h_align = v_align = 0; |
104 | #endif |
105 | #endif |
105 | flags = 0; |
106 | flags = 0; |
106 | pixmap = None; |
107 | pixmap = None; |
… | |
… | |
127 | if (flags & isTransparent) |
128 | if (flags & isTransparent) |
128 | return true; |
129 | return true; |
129 | # endif |
130 | # endif |
130 | |
131 | |
131 | # ifdef BG_IMAGE_FROM_FILE |
132 | # ifdef BG_IMAGE_FROM_FILE |
132 | # ifdef HAVE_AFTERIMAGE |
133 | if (have_image) |
133 | if (original_asim) |
|
|
134 | # endif |
|
|
135 | { |
134 | { |
136 | if (h_scale != 0 || v_scale != 0 |
135 | if (h_scale != 0 || v_scale != 0 |
137 | || h_align != 0 || v_align != 0) |
136 | || h_align != 0 || v_align != 0) |
138 | return true; |
137 | return true; |
139 | } |
138 | } |
… | |
… | |
149 | if (flags & isTransparent) |
148 | if (flags & isTransparent) |
150 | return true; |
149 | return true; |
151 | # endif |
150 | # endif |
152 | |
151 | |
153 | # ifdef BG_IMAGE_FROM_FILE |
152 | # ifdef BG_IMAGE_FROM_FILE |
154 | # ifdef HAVE_AFTERIMAGE |
153 | if (have_image) |
155 | if (original_asim) |
|
|
156 | # endif |
|
|
157 | { |
154 | { |
158 | if (h_align == rootAlign || v_align == rootAlign) |
155 | if (h_align == rootAlign || v_align == rootAlign) |
159 | return true; |
156 | return true; |
160 | } |
157 | } |
161 | # endif |
158 | # endif |
… | |
… | |
441 | { |
438 | { |
442 | flags = new_flags; |
439 | flags = new_flags; |
443 | changed++; |
440 | changed++; |
444 | } |
441 | } |
445 | |
442 | |
446 | //fprintf (stderr, "flags = %lX, scale = %ux%u, align=%+d%+d\n", |
443 | //fprintf (stderr, "flags = %lX, scale = %ux%u, align=%+d%+d\n", |
447 | // flags, h_scale, v_scale, h_align, v_align); |
444 | // flags, h_scale, v_scale, h_align, v_align); |
448 | return (changed > 0); |
445 | return (changed > 0); |
449 | } |
446 | } |
450 | |
447 | |
451 | # ifdef HAVE_AFTERIMAGE |
448 | # ifdef HAVE_AFTERIMAGE |
452 | bool |
449 | bool |
453 | bgPixmap_t::render_asim (ASImage *background, ARGB32 background_tint) |
450 | bgPixmap_t::render_image (unsigned long background_flags) |
454 | { |
451 | { |
455 | if (target == NULL) |
452 | if (target == NULL) |
456 | return false; |
453 | return false; |
457 | |
454 | |
458 | target->init_asv (); |
455 | target->init_asv (); |
|
|
456 | |
|
|
457 | ASImage *background = NULL; |
|
|
458 | ARGB32 background_tint = TINT_LEAVE_SAME; |
|
|
459 | |
|
|
460 | # ifdef ENABLE_TRANSPARENCY |
|
|
461 | if (background_flags) |
|
|
462 | background = pixmap2ximage (target->asv, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, 100); |
|
|
463 | |
|
|
464 | if (!(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
|
|
465 | { |
|
|
466 | ShadingInfo as_shade; |
|
|
467 | as_shade.shading = (shade == 0) ? 100 : shade; |
|
|
468 | |
|
|
469 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
|
|
470 | if (flags & tintSet) |
|
|
471 | tint.get (c); |
|
|
472 | as_shade.tintColor.red = c.r; |
|
|
473 | as_shade.tintColor.green = c.g; |
|
|
474 | as_shade.tintColor.blue = c.b; |
|
|
475 | |
|
|
476 | background_tint = shading2tint32 (&as_shade); |
|
|
477 | } |
|
|
478 | |
|
|
479 | if (!(background_flags & transpPmapBlured) && (flags & blurNeeded) && background != NULL) |
|
|
480 | { |
|
|
481 | ASImage *tmp = blur_asimage_gauss (target->asv, background, h_blurRadius, v_blurRadius, 0xFFFFFFFF, |
|
|
482 | (original_asim == NULL || tint == TINT_LEAVE_SAME) ? ASA_XImage : ASA_ASImage, |
|
|
483 | 100, ASIMAGE_QUALITY_DEFAULT); |
|
|
484 | if (tmp) |
|
|
485 | { |
|
|
486 | destroy_asimage (&background); |
|
|
487 | background = tmp; |
|
|
488 | } |
|
|
489 | } |
|
|
490 | # endif |
459 | |
491 | |
460 | ASImage *result = 0; |
492 | ASImage *result = 0; |
461 | |
493 | |
462 | int target_width = target->szHint.width; |
494 | int target_width = target->szHint.width; |
463 | int target_height = target->szHint.height; |
495 | int target_height = target->szHint.height; |
… | |
… | |
473 | |
505 | |
474 | if (original_asim) |
506 | if (original_asim) |
475 | { |
507 | { |
476 | if (h_align == rootAlign || v_align == rootAlign) |
508 | if (h_align == rootAlign || v_align == rootAlign) |
477 | { |
509 | { |
478 | target->get_window_origin(x, y); |
510 | target->get_window_origin (x, y); |
479 | x = -x; |
511 | x = -x; |
480 | y = -y; |
512 | y = -y; |
481 | } |
513 | } |
482 | |
514 | |
483 | if (h_align != rootAlign) |
515 | if (h_align != rootAlign) |
… | |
… | |
554 | } |
586 | } |
555 | else |
587 | else |
556 | { |
588 | { |
557 | /* if blending background and image - pixmap has to be sized same as target window */ |
589 | /* if blending background and image - pixmap has to be sized same as target window */ |
558 | ASImageLayer *layers = create_image_layers (2); |
590 | ASImageLayer *layers = create_image_layers (2); |
559 | ASImage *merged_im = NULL; |
|
|
560 | |
591 | |
561 | layers[0].im = background; |
592 | layers[0].im = background; |
562 | layers[0].clip_width = target_width; |
593 | layers[0].clip_width = target_width; |
563 | layers[0].clip_height = target_height; |
594 | layers[0].clip_height = target_height; |
564 | layers[0].tint = background_tint; |
595 | layers[0].tint = background_tint; |
… | |
… | |
636 | pixmap = XCreatePixmap (target->dpy, target->vt, new_pmap_width, new_pmap_height, target->depth); |
667 | pixmap = XCreatePixmap (target->dpy, target->vt, new_pmap_width, new_pmap_height, target->depth); |
637 | pmap_width = new_pmap_width; |
668 | pmap_width = new_pmap_width; |
638 | pmap_height = new_pmap_height; |
669 | pmap_height = new_pmap_height; |
639 | pmap_depth = target->depth; |
670 | pmap_depth = target->depth; |
640 | } |
671 | } |
641 | /* fill with background color ( if result's not completely overlapping it)*/ |
672 | /* fill with background color (if result's not completely overlapping it) */ |
642 | gcv.foreground = target->pix_colors[Color_bg]; |
673 | gcv.foreground = target->pix_colors[Color_bg]; |
643 | gc = XCreateGC (target->dpy, target->vt, GCForeground, &gcv); |
674 | gc = XCreateGC (target->dpy, target->vt, GCForeground, &gcv); |
644 | |
675 | |
645 | int src_x = 0, src_y = 0, dst_x = 0, dst_y = 0; |
676 | int src_x = 0, src_y = 0, dst_x = 0, dst_y = 0; |
646 | int dst_width = result->width, dst_height = result->height; |
677 | int dst_width = result->width, dst_height = result->height; |
… | |
… | |
664 | |
695 | |
665 | XFreeGC (target->dpy, gc); |
696 | XFreeGC (target->dpy, gc); |
666 | TIMING_TEST_PRINT_RESULT (asim); |
697 | TIMING_TEST_PRINT_RESULT (asim); |
667 | } |
698 | } |
668 | |
699 | |
|
|
700 | if (background) |
|
|
701 | destroy_asimage (&background); |
|
|
702 | |
669 | return true; |
703 | return true; |
670 | } |
704 | } |
671 | # endif /* HAVE_AFTERIMAGE */ |
705 | # endif /* HAVE_AFTERIMAGE */ |
672 | |
706 | |
673 | bool |
707 | bool |
… | |
… | |
675 | { |
709 | { |
676 | assert (file); |
710 | assert (file); |
677 | |
711 | |
678 | if (*file) |
712 | if (*file) |
679 | { |
713 | { |
|
|
714 | if (const char *p = strchr (file, ';')) |
|
|
715 | { |
|
|
716 | size_t len = p - file; |
|
|
717 | char *f = rxvt_temp_buf<char> (len + 1); |
|
|
718 | memcpy (f, file, len); |
|
|
719 | f[len] = '\0'; |
|
|
720 | file = f; |
|
|
721 | } |
|
|
722 | |
680 | # ifdef HAVE_AFTERIMAGE |
723 | # ifdef HAVE_AFTERIMAGE |
681 | if (!target->asimman) |
724 | if (!target->asimman) |
682 | target->asimman = create_generic_imageman (target->rs[Rs_path]); |
725 | 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); |
726 | original_asim = get_asimage (target->asimman, file, 0xFFFFFFFF, 100); |
695 | |
727 | if (original_asim) |
696 | return original_asim; |
728 | have_image = true; |
|
|
729 | return have_image; |
697 | # endif |
730 | # endif |
698 | } |
731 | } |
699 | |
732 | |
700 | return false; |
733 | return false; |
701 | } |
734 | } |
… | |
… | |
770 | flags |= bgPixmap_t::tintNeeded; |
803 | flags |= bgPixmap_t::tintNeeded; |
771 | else if (tint) |
804 | else if (tint) |
772 | { |
805 | { |
773 | if ((c.r > 0x000700 || c.g > 0x000700 || c.b > 0x000700) |
806 | if ((c.r > 0x000700 || c.g > 0x000700 || c.b > 0x000700) |
774 | && (c.r < 0x00f700 || c.g < 0x00f700 || c.b < 0x00f700)) |
807 | && (c.r < 0x00f700 || c.g < 0x00f700 || c.b < 0x00f700)) |
775 | { |
808 | { |
776 | flags |= bgPixmap_t::tintNeeded; |
809 | flags |= bgPixmap_t::tintNeeded; |
777 | } |
810 | } |
778 | } |
811 | } |
779 | |
812 | |
780 | if (flags & bgPixmap_t::tintNeeded) |
813 | if (flags & bgPixmap_t::tintNeeded) |
781 | { |
814 | { |
782 | if (flags & bgPixmap_t::tintWholesome) |
815 | if (flags & bgPixmap_t::tintWholesome) |
… | |
… | |
811 | { |
844 | { |
812 | unsigned long new_flags = compute_tint_shade_flags (NULL, shade); |
845 | unsigned long new_flags = compute_tint_shade_flags (NULL, shade); |
813 | |
846 | |
814 | if (new_flags != (flags & tintFlags)) |
847 | if (new_flags != (flags & tintFlags)) |
815 | { |
848 | { |
816 | flags = (flags&~tintFlags)|new_flags; |
849 | flags = (flags&~tintFlags)|new_flags; |
817 | return true; |
850 | return true; |
818 | } |
851 | } |
819 | |
852 | |
820 | return false; |
853 | return false; |
821 | } |
854 | } |
822 | |
855 | |
… | |
… | |
907 | |
940 | |
908 | attr.background_pixmap = ParentRelative; |
941 | attr.background_pixmap = ParentRelative; |
909 | attr.backing_store = Always; |
942 | attr.backing_store = Always; |
910 | attr.event_mask = ExposureMask; |
943 | attr.event_mask = ExposureMask; |
911 | attr.override_redirect = True; |
944 | attr.override_redirect = True; |
912 | src = XCreateWindow (dpy, root, sx, sy, window_width, window_height, 0, |
945 | src = XCreateWindow (dpy, root, sx, sy, window_width, window_height, 0, |
913 | CopyFromParent, CopyFromParent, CopyFromParent, |
946 | CopyFromParent, CopyFromParent, CopyFromParent, |
914 | CWBackPixmap|CWBackingStore|CWOverrideRedirect|CWEventMask, |
947 | CWBackPixmap|CWBackingStore|CWOverrideRedirect|CWEventMask, |
915 | &attr); |
948 | &attr); |
916 | |
949 | |
917 | if (src != None) |
950 | if (src != None) |
… | |
… | |
941 | XDestroyWindow (dpy, src); |
974 | XDestroyWindow (dpy, src); |
942 | XUngrabServer (dpy); |
975 | XUngrabServer (dpy); |
943 | //fprintf (stderr, "%s:%d: ev_count = %d\n", __FUNCTION__, __LINE__, ev_count); |
976 | //fprintf (stderr, "%s:%d: ev_count = %d\n", __FUNCTION__, __LINE__, ev_count); |
944 | } |
977 | } |
945 | |
978 | |
946 | if (!success) |
979 | if (!success) |
947 | { |
980 | { |
948 | XFreePixmap (dpy, tiled_root_pmap); |
981 | XFreePixmap (dpy, tiled_root_pmap); |
949 | tiled_root_pmap = None; |
982 | tiled_root_pmap = None; |
950 | } |
983 | } |
951 | else |
984 | else |
952 | result |= transpPmapTiled; |
985 | result |= transpPmapTiled; |
953 | } |
986 | } |
954 | else |
987 | else |
955 | { |
988 | { |
956 | /* straightforward pixmap copy */ |
989 | /* straightforward pixmap copy */ |
957 | gcv.tile = root_pixmap; |
990 | gcv.tile = root_pixmap; |
… | |
… | |
1074 | # if DO_TIMING_TEST |
1107 | # if DO_TIMING_TEST |
1075 | XSync (dpy, False); |
1108 | XSync (dpy, False); |
1076 | # endif |
1109 | # endif |
1077 | # endif |
1110 | # endif |
1078 | } |
1111 | } |
1079 | } |
1112 | } |
1080 | } /* server side rendering completed */ |
1113 | } /* server side rendering completed */ |
1081 | |
1114 | |
1082 | if (pixmap) |
1115 | if (pixmap) |
1083 | XFreePixmap (dpy, pixmap); |
1116 | XFreePixmap (dpy, pixmap); |
1084 | |
1117 | |
… | |
… | |
1134 | /* we need to re-generate transparency pixmap in that case ! */ |
1167 | /* we need to re-generate transparency pixmap in that case ! */ |
1135 | background_flags = make_transparency_pixmap (); |
1168 | background_flags = make_transparency_pixmap (); |
1136 | if (background_flags == 0) |
1169 | if (background_flags == 0) |
1137 | return false; |
1170 | return false; |
1138 | else if ((background_flags & transpTransformations) == (flags & transpTransformations) |
1171 | else if ((background_flags & transpTransformations) == (flags & transpTransformations) |
1139 | && pmap_depth == target->depth) |
1172 | && pmap_depth == target->depth) |
1140 | flags = flags & ~isInvalid; |
1173 | flags = flags & ~isInvalid; |
1141 | } |
1174 | } |
1142 | # endif |
1175 | # endif |
1143 | |
1176 | |
|
|
1177 | # ifdef BG_IMAGE_FROM_FILE |
|
|
1178 | if (have_image |
|
|
1179 | || (background_flags & transpTransformations) != (flags & transpTransformations)) |
|
|
1180 | { |
|
|
1181 | if (render_image (background_flags)) |
|
|
1182 | flags = flags & ~isInvalid; |
|
|
1183 | } |
|
|
1184 | # endif |
|
|
1185 | |
1144 | XImage *result = NULL; |
1186 | XImage *result = NULL; |
1145 | # ifdef HAVE_AFTERIMAGE |
|
|
1146 | if (original_asim |
|
|
1147 | || (background_flags & transpTransformations) != (flags & transpTransformations)) |
|
|
1148 | { |
|
|
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)) |
|
|
1186 | flags = flags & ~isInvalid; |
|
|
1187 | if (background) |
|
|
1188 | destroy_asimage (&background); |
|
|
1189 | } |
|
|
1190 | else if (background_flags && pmap_depth != target->depth) |
|
|
1191 | result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); |
|
|
1192 | |
|
|
1193 | # elif !XFT /* our own client-side tinting */ |
|
|
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 | |
1187 | |
1198 | if (background_flags && (flags & isInvalid)) |
1188 | if (background_flags && (flags & isInvalid)) |
1199 | { |
1189 | { |
1200 | result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); |
1190 | result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); |
1201 | |
1191 | |
|
|
1192 | # if !defined(HAVE_AFTERIMAGE) && !XFT |
|
|
1193 | /* our own client-side tinting */ |
|
|
1194 | /* ATTENTION: We ASSUME that XFT will let us do all the tinting necessary server-side. |
|
|
1195 | This may need to be changed in need_client_side_rendering() logic is altered !!! */ |
1202 | if (result != NULL && !(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
1196 | if (result != NULL && !(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
1203 | { |
1197 | { |
1204 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
1198 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
1205 | if (flags & tintSet) |
1199 | if (flags & tintSet) |
1206 | tint.get (c); |
1200 | tint.get (c); |
1207 | ShadeXImage (target, result, shade, c.r, c.g, c.b); |
1201 | ShadeXImage (target, result, shade, c.r, c.g, c.b); |
1208 | } |
1202 | } |
|
|
1203 | # endif |
1209 | } |
1204 | } |
1210 | # endif /* HAVE_AFTERIMAGE */ |
|
|
1211 | |
1205 | |
1212 | if (result) |
1206 | if (result) |
1213 | { |
1207 | { |
1214 | GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL); |
1208 | GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL); |
1215 | |
1209 | |
… | |
… | |
1247 | |
1241 | |
1248 | XFreeGC (target->dpy, gc); |
1242 | XFreeGC (target->dpy, gc); |
1249 | flags = flags & ~isInvalid; |
1243 | flags = flags & ~isInvalid; |
1250 | } |
1244 | } |
1251 | |
1245 | |
1252 | XDestroyImage (result); |
1246 | XDestroyImage (result); |
1253 | } |
1247 | } |
1254 | |
1248 | |
1255 | if (flags & isInvalid) |
1249 | if (flags & isInvalid) |
1256 | { |
1250 | { |
1257 | if (pixmap != None) |
1251 | if (pixmap != None) |