1 | /*----------------------------------------------------------------------* |
1 | /*----------------------------------------------------------------------* |
2 | * File: background.C - former xpm.C |
2 | * File: background.C - former xpm.C |
3 | *----------------------------------------------------------------------* |
3 | *----------------------------------------------------------------------* |
4 | * |
4 | * |
5 | * All portions of code are copyright by their respective author/s. |
5 | * All portions of code are copyright by their respective author/s. |
6 | * Copyright (c) 2005-2006 Marc Lehmann <pcg@goof.com> |
6 | * Copyright (c) 2005-2008 Marc Lehmann <pcg@goof.com> |
7 | * Copyright (c) 2007 Sasha Vasko <sasha@aftercode.net> |
7 | * Copyright (c) 2007 Sasha Vasko <sasha@aftercode.net> |
8 | * |
8 | * |
9 | * This program is free software; you can redistribute it and/or modify |
9 | * This program is free software; you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License as published by |
10 | * it under the terms of the GNU General Public License as published by |
11 | * the Free Software Foundation; either version 2 of the License, or |
11 | * the Free Software Foundation; either version 2 of the License, or |
… | |
… | |
27 | #define DO_TIMING_TEST 0 |
27 | #define DO_TIMING_TEST 0 |
28 | |
28 | |
29 | #if DO_TIMING_TEST |
29 | #if DO_TIMING_TEST |
30 | # include <sys/time.h> |
30 | # include <sys/time.h> |
31 | #define TIMING_TEST_START(id) \ |
31 | #define TIMING_TEST_START(id) \ |
32 | struct timeval timing_test_##id##_stv;\ |
32 | struct timeval timing_test_##id##_stv; \ |
33 | gettimeofday (&timing_test_##id##_stv, NULL); |
33 | gettimeofday (&timing_test_##id##_stv, NULL); |
34 | |
34 | |
35 | #define TIMING_TEST_PRINT_RESULT(id) \ |
35 | #define TIMING_TEST_PRINT_RESULT(id) \ |
36 | do{ struct timeval tv;gettimeofday (&tv, NULL); tv.tv_sec -= (timing_test_##id##_stv).tv_sec;\ |
36 | do { \ |
|
|
37 | struct timeval tv; \ |
|
|
38 | gettimeofday (&tv, NULL); \ |
|
|
39 | tv.tv_sec -= (timing_test_##id##_stv).tv_sec; \ |
37 | fprintf (stderr, "%s: %s: %d: elapsed %ld usec\n", #id, __FILE__, __LINE__,\ |
40 | fprintf (stderr, "%s: %s: %d: elapsed %ld usec\n", #id, __FILE__, __LINE__, \ |
38 | tv.tv_sec * 1000000 + tv.tv_usec - (timing_test_##id##_stv).tv_usec);}while (0) |
41 | tv.tv_sec * 1000000 + tv.tv_usec - (timing_test_##id##_stv).tv_usec); \ |
|
|
42 | } while (0) |
39 | |
43 | |
40 | #else |
44 | #else |
41 | #define TIMING_TEST_START(id) do{}while (0) |
45 | #define TIMING_TEST_START(id) do {} while (0) |
42 | #define TIMING_TEST_PRINT_RESULT(id) do{}while (0) |
46 | #define TIMING_TEST_PRINT_RESULT(id) do {} while (0) |
43 | #endif |
47 | #endif |
44 | |
48 | |
45 | /* |
49 | /* |
46 | * Pixmap geometry string interpretation : |
50 | * Pixmap geometry string interpretation : |
47 | * Each geometry string contains zero or one scale/position |
51 | * Each geometry string contains zero or one scale/position |
48 | * 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 |
49 | * colon-delimited pixmap operations. |
53 | * colon-delimited pixmap operations. |
50 | * The following table shows the valid geometry strings and their |
54 | * The following table shows the valid geometry strings and their |
51 | * affects on the background image : |
55 | * effects on the background image : |
52 | * |
56 | * |
53 | * 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%. |
54 | * W and H are percentages of the terminal window size. |
58 | * W and H are percentages of the terminal window size. |
55 | * X and Y are also percentages; e.g., +50+50 centers |
59 | * X and Y are also percentages; e.g., +50+50 centers |
56 | * the image in the window. |
60 | * the image in the window. |
… | |
… | |
136 | # endif |
140 | # endif |
137 | |
141 | |
138 | return false; |
142 | return false; |
139 | } |
143 | } |
140 | |
144 | |
141 | bool |
145 | bool |
142 | bgPixmap_t::window_position_sensitive () |
146 | bgPixmap_t::window_position_sensitive () |
143 | { |
147 | { |
144 | # ifdef ENABLE_TRANSPARENCY |
148 | # ifdef ENABLE_TRANSPARENCY |
145 | if (flags & isTransparent) |
149 | if (flags & isTransparent) |
146 | return true; |
150 | return true; |
147 | # endif |
151 | # endif |
… | |
… | |
259 | int geom_flags = 0, changed = 0; |
263 | int geom_flags = 0, changed = 0; |
260 | int x = 0, y = 0; |
264 | int x = 0, y = 0; |
261 | unsigned int w = 0, h = 0; |
265 | unsigned int w = 0, h = 0; |
262 | unsigned int n; |
266 | unsigned int n; |
263 | unsigned long new_flags = (flags & (~geometryFlags)); |
267 | unsigned long new_flags = (flags & (~geometryFlags)); |
264 | char *p; |
268 | const char *p; |
265 | # define MAXLEN_GEOM 256 /* could be longer than regular geometry string */ |
269 | # define MAXLEN_GEOM 256 /* could be longer than regular geometry string */ |
266 | |
270 | |
267 | if (geom == NULL) |
271 | if (geom == NULL) |
268 | return false; |
272 | return false; |
269 | |
273 | |
… | |
… | |
437 | { |
441 | { |
438 | flags = new_flags; |
442 | flags = new_flags; |
439 | changed++; |
443 | changed++; |
440 | } |
444 | } |
441 | |
445 | |
442 | //fprintf (stderr, "flags = %lX, scale = %ux%u, align=%+d%+d\n", |
446 | //fprintf (stderr, "flags = %lX, scale = %ux%u, align=%+d%+d\n", |
443 | // flags, h_scale, v_scale, h_align, v_align); |
447 | // flags, h_scale, v_scale, h_align, v_align); |
444 | return (changed > 0); |
448 | return (changed > 0); |
445 | } |
449 | } |
446 | |
450 | |
447 | # ifdef HAVE_AFTERIMAGE |
451 | # ifdef HAVE_AFTERIMAGE |
448 | bool |
452 | bool |
449 | bgPixmap_t::render_asim (ASImage *background, ARGB32 background_tint) |
453 | bgPixmap_t::render_asim (unsigned long background_flags) |
450 | { |
454 | { |
451 | if (target == NULL) |
455 | if (target == NULL) |
452 | return false; |
456 | return false; |
453 | |
457 | |
|
|
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 |
|
|
494 | |
|
|
495 | ASImage *result = 0; |
|
|
496 | |
454 | int target_width = (int)target->szHint.width; |
497 | int target_width = target->szHint.width; |
455 | int target_height = (int)target->szHint.height; |
498 | int target_height = target->szHint.height; |
456 | int new_pmap_width = target_width, new_pmap_height = target_height; |
499 | int new_pmap_width = target_width; |
457 | ASImage *result = NULL; |
500 | int new_pmap_height = target_height; |
458 | |
501 | |
459 | int x = 0; |
502 | int x = 0; |
460 | int y = 0; |
503 | int y = 0; |
461 | int w = h_scale * target_width / 100; |
504 | int w = h_scale * target_width / 100; |
462 | int h = v_scale * target_height / 100; |
505 | int h = v_scale * target_height / 100; |
… | |
… | |
465 | |
508 | |
466 | if (original_asim) |
509 | if (original_asim) |
467 | { |
510 | { |
468 | if (h_align == rootAlign || v_align == rootAlign) |
511 | if (h_align == rootAlign || v_align == rootAlign) |
469 | { |
512 | { |
470 | target->get_window_origin(x, y); |
513 | target->get_window_origin (x, y); |
471 | x = -x; |
514 | x = -x; |
472 | y = -y; |
515 | y = -y; |
473 | } |
516 | } |
474 | |
517 | |
475 | if (h_align != rootAlign) |
518 | if (h_align != rootAlign) |
… | |
… | |
491 | new_pmap_height = background->height; |
534 | new_pmap_height = background->height; |
492 | result = background; |
535 | result = background; |
493 | |
536 | |
494 | if (background_tint != TINT_LEAVE_SAME) |
537 | if (background_tint != TINT_LEAVE_SAME) |
495 | { |
538 | { |
496 | ASImage* tmp = tile_asimage (target->asv, background, 0, 0, |
539 | ASImage *tmp = tile_asimage (target->asv, background, 0, 0, |
497 | target_width, target_height, background_tint, |
540 | target_width, target_height, background_tint, |
498 | ASA_XImage, 100, ASIMAGE_QUALITY_DEFAULT); |
541 | ASA_XImage, 100, ASIMAGE_QUALITY_DEFAULT); |
499 | if (tmp) |
542 | if (tmp) |
500 | result = tmp; |
543 | result = tmp; |
501 | } |
544 | } |
… | |
… | |
529 | if (h_scale == 0 || v_scale == 0) |
572 | if (h_scale == 0 || v_scale == 0) |
530 | { |
573 | { |
531 | ASImage *tmp = tile_asimage (target->asv, result, |
574 | ASImage *tmp = tile_asimage (target->asv, result, |
532 | (h_scale > 0) ? 0 : (int)result->width - x, |
575 | (h_scale > 0) ? 0 : (int)result->width - x, |
533 | (v_scale > 0) ? 0 : (int)result->height - y, |
576 | (v_scale > 0) ? 0 : (int)result->height - y, |
534 | new_pmap_width, |
577 | new_pmap_width, |
535 | new_pmap_height, |
578 | new_pmap_height, |
536 | TINT_LEAVE_SAME, ASA_XImage, |
579 | TINT_LEAVE_SAME, ASA_XImage, |
537 | 100, ASIMAGE_QUALITY_DEFAULT); |
580 | 100, ASIMAGE_QUALITY_DEFAULT); |
538 | if (tmp) |
581 | if (tmp) |
539 | { |
582 | { |
… | |
… | |
546 | } |
589 | } |
547 | else |
590 | else |
548 | { |
591 | { |
549 | /* 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 */ |
550 | ASImageLayer *layers = create_image_layers (2); |
593 | ASImageLayer *layers = create_image_layers (2); |
551 | ASImage *merged_im = NULL; |
|
|
552 | |
594 | |
553 | layers[0].im = background; |
595 | layers[0].im = background; |
554 | layers[0].clip_width = target_width; |
596 | layers[0].clip_width = target_width; |
555 | layers[0].clip_height = target_height; |
597 | layers[0].clip_height = target_height; |
556 | layers[0].tint = background_tint; |
598 | layers[0].tint = background_tint; |
… | |
… | |
628 | 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); |
629 | pmap_width = new_pmap_width; |
671 | pmap_width = new_pmap_width; |
630 | pmap_height = new_pmap_height; |
672 | pmap_height = new_pmap_height; |
631 | pmap_depth = target->depth; |
673 | pmap_depth = target->depth; |
632 | } |
674 | } |
633 | /* fill with background color ( if result's not completely overlapping it)*/ |
675 | /* fill with background color (if result's not completely overlapping it) */ |
634 | gcv.foreground = target->pix_colors[Color_bg]; |
676 | gcv.foreground = target->pix_colors[Color_bg]; |
635 | gc = XCreateGC (target->dpy, target->vt, GCForeground, &gcv); |
677 | gc = XCreateGC (target->dpy, target->vt, GCForeground, &gcv); |
636 | |
678 | |
637 | 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; |
638 | int dst_width = result->width, dst_height = result->height; |
680 | int dst_width = result->width, dst_height = result->height; |
… | |
… | |
656 | |
698 | |
657 | XFreeGC (target->dpy, gc); |
699 | XFreeGC (target->dpy, gc); |
658 | TIMING_TEST_PRINT_RESULT (asim); |
700 | TIMING_TEST_PRINT_RESULT (asim); |
659 | } |
701 | } |
660 | |
702 | |
|
|
703 | if (background) |
|
|
704 | destroy_asimage (&background); |
|
|
705 | |
661 | return true; |
706 | return true; |
662 | } |
707 | } |
663 | # endif /* HAVE_AFTERIMAGE */ |
708 | # endif /* HAVE_AFTERIMAGE */ |
664 | |
709 | |
665 | bool |
710 | bool |
666 | bgPixmap_t::set_file (const char *file) |
711 | bgPixmap_t::set_file (const char *file) |
667 | { |
712 | { |
668 | char *f; |
|
|
669 | |
|
|
670 | assert (file); |
713 | assert (file); |
671 | |
714 | |
672 | if (*file) |
715 | if (*file) |
673 | { |
716 | { |
674 | # ifdef HAVE_AFTERIMAGE |
717 | if (const char *p = strchr (file, ';')) |
675 | if (target->asimman == NULL) |
|
|
676 | target->asimman = create_generic_imageman (target->rs[Rs_path]); |
|
|
677 | |
|
|
678 | if ((f = strchr (file, ';')) == NULL) |
|
|
679 | original_asim = get_asimage (target->asimman, file, 0xFFFFFFFF, 100); |
|
|
680 | else |
|
|
681 | { |
718 | { |
682 | size_t len = f - file; |
719 | size_t len = p - file; |
683 | f = (char *)malloc (len + 1); |
720 | char *f = rxvt_temp_buf<char> (len + 1); |
684 | memcpy (f, file, len); |
721 | memcpy (f, file, len); |
685 | f[len] = '\0'; |
722 | f[len] = '\0'; |
|
|
723 | file = f; |
|
|
724 | } |
|
|
725 | |
|
|
726 | # ifdef HAVE_AFTERIMAGE |
|
|
727 | if (!target->asimman) |
|
|
728 | target->asimman = create_generic_imageman (target->rs[Rs_path]); |
686 | original_asim = get_asimage (target->asimman, f, 0xFFFFFFFF, 100); |
729 | original_asim = get_asimage (target->asimman, file, 0xFFFFFFFF, 100); |
687 | free (f); |
|
|
688 | } |
|
|
689 | |
|
|
690 | return original_asim; |
730 | return original_asim; |
691 | # endif |
731 | # endif |
692 | } |
732 | } |
693 | |
733 | |
694 | return false; |
734 | return false; |
… | |
… | |
764 | flags |= bgPixmap_t::tintNeeded; |
804 | flags |= bgPixmap_t::tintNeeded; |
765 | else if (tint) |
805 | else if (tint) |
766 | { |
806 | { |
767 | if ((c.r > 0x000700 || c.g > 0x000700 || c.b > 0x000700) |
807 | if ((c.r > 0x000700 || c.g > 0x000700 || c.b > 0x000700) |
768 | && (c.r < 0x00f700 || c.g < 0x00f700 || c.b < 0x00f700)) |
808 | && (c.r < 0x00f700 || c.g < 0x00f700 || c.b < 0x00f700)) |
769 | { |
809 | { |
770 | flags |= bgPixmap_t::tintNeeded; |
810 | flags |= bgPixmap_t::tintNeeded; |
771 | } |
811 | } |
772 | } |
812 | } |
773 | |
813 | |
774 | if (flags & bgPixmap_t::tintNeeded) |
814 | if (flags & bgPixmap_t::tintNeeded) |
775 | { |
815 | { |
776 | if (flags & bgPixmap_t::tintWholesome) |
816 | if (flags & bgPixmap_t::tintWholesome) |
… | |
… | |
805 | { |
845 | { |
806 | unsigned long new_flags = compute_tint_shade_flags (NULL, shade); |
846 | unsigned long new_flags = compute_tint_shade_flags (NULL, shade); |
807 | |
847 | |
808 | if (new_flags != (flags & tintFlags)) |
848 | if (new_flags != (flags & tintFlags)) |
809 | { |
849 | { |
810 | flags = (flags&~tintFlags)|new_flags; |
850 | flags = (flags&~tintFlags)|new_flags; |
811 | return true; |
851 | return true; |
812 | } |
852 | } |
813 | |
853 | |
814 | return false; |
854 | return false; |
815 | } |
855 | } |
816 | |
856 | |
… | |
… | |
846 | unsigned long result = 0; |
886 | unsigned long result = 0; |
847 | |
887 | |
848 | if (target == NULL) |
888 | if (target == NULL) |
849 | return 0; |
889 | return 0; |
850 | |
890 | |
851 | /* root dimentions may change from call to call - but Display structure should |
891 | /* root dimensions may change from call to call - but Display structure should |
852 | * be always up-to-date, so let's use it : |
892 | * be always up-to-date, so let's use it : |
853 | */ |
893 | */ |
854 | Window root = target->display->root; |
894 | Window root = target->display->root; |
855 | int screen = target->display->screen; |
895 | int screen = target->display->screen; |
856 | Display *dpy = target->dpy; |
896 | Display *dpy = target->dpy; |
… | |
… | |
901 | |
941 | |
902 | attr.background_pixmap = ParentRelative; |
942 | attr.background_pixmap = ParentRelative; |
903 | attr.backing_store = Always; |
943 | attr.backing_store = Always; |
904 | attr.event_mask = ExposureMask; |
944 | attr.event_mask = ExposureMask; |
905 | attr.override_redirect = True; |
945 | attr.override_redirect = True; |
906 | src = XCreateWindow (dpy, root, sx, sy, window_width, window_height, 0, |
946 | src = XCreateWindow (dpy, root, sx, sy, window_width, window_height, 0, |
907 | CopyFromParent, CopyFromParent, CopyFromParent, |
947 | CopyFromParent, CopyFromParent, CopyFromParent, |
908 | CWBackPixmap|CWBackingStore|CWOverrideRedirect|CWEventMask, |
948 | CWBackPixmap|CWBackingStore|CWOverrideRedirect|CWEventMask, |
909 | &attr); |
949 | &attr); |
910 | |
950 | |
911 | if (src != None) |
951 | if (src != None) |
… | |
… | |
935 | XDestroyWindow (dpy, src); |
975 | XDestroyWindow (dpy, src); |
936 | XUngrabServer (dpy); |
976 | XUngrabServer (dpy); |
937 | //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); |
938 | } |
978 | } |
939 | |
979 | |
940 | if (!success) |
980 | if (!success) |
941 | { |
981 | { |
942 | XFreePixmap (dpy, tiled_root_pmap); |
982 | XFreePixmap (dpy, tiled_root_pmap); |
943 | tiled_root_pmap = None; |
983 | tiled_root_pmap = None; |
944 | } |
984 | } |
945 | else |
985 | else |
946 | result |= transpPmapTiled; |
986 | result |= transpPmapTiled; |
947 | } |
987 | } |
948 | else |
988 | else |
949 | { |
989 | { |
950 | /* strightforward pixmap copy */ |
990 | /* straightforward pixmap copy */ |
951 | gcv.tile = root_pixmap; |
991 | gcv.tile = root_pixmap; |
952 | gcv.fill_style = FillTiled; |
992 | gcv.fill_style = FillTiled; |
953 | |
993 | |
954 | while (sx < 0) sx += (int)root_width; |
994 | while (sx < 0) sx += (int)root_width; |
955 | while (sy < 0) sy += (int)root_height; |
995 | while (sy < 0) sy += (int)root_height; |
… | |
… | |
1068 | # if DO_TIMING_TEST |
1108 | # if DO_TIMING_TEST |
1069 | XSync (dpy, False); |
1109 | XSync (dpy, False); |
1070 | # endif |
1110 | # endif |
1071 | # endif |
1111 | # endif |
1072 | } |
1112 | } |
1073 | } |
1113 | } |
1074 | } /* server side rendering completed */ |
1114 | } /* server side rendering completed */ |
1075 | |
1115 | |
1076 | if (pixmap) |
1116 | if (pixmap) |
1077 | XFreePixmap (dpy, pixmap); |
1117 | XFreePixmap (dpy, pixmap); |
1078 | |
1118 | |
… | |
… | |
1106 | return false; |
1146 | return false; |
1107 | } |
1147 | } |
1108 | # endif /* ENABLE_TRANSPARENCY */ |
1148 | # endif /* ENABLE_TRANSPARENCY */ |
1109 | |
1149 | |
1110 | # ifndef HAVE_AFTERIMAGE |
1150 | # ifndef HAVE_AFTERIMAGE |
1111 | static void ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm); |
1151 | static void ShadeXImage(rxvt_term *term, XImage *srcImage, int shade, int rm, int gm, int bm); |
1112 | # endif |
1152 | # endif |
1113 | |
1153 | |
1114 | bool |
1154 | bool |
1115 | bgPixmap_t::render () |
1155 | bgPixmap_t::render () |
1116 | { |
1156 | { |
… | |
… | |
1119 | if (target == NULL) |
1159 | if (target == NULL) |
1120 | return false; |
1160 | return false; |
1121 | |
1161 | |
1122 | TIMING_TEST_START (tp); |
1162 | TIMING_TEST_START (tp); |
1123 | |
1163 | |
1124 | invalidate(); |
1164 | invalidate (); |
1125 | # ifdef ENABLE_TRANSPARENCY |
1165 | # ifdef ENABLE_TRANSPARENCY |
1126 | if (flags & isTransparent) |
1166 | if (flags & isTransparent) |
1127 | { |
1167 | { |
1128 | /* we need to re-generate transparency pixmap in that case ! */ |
1168 | /* we need to re-generate transparency pixmap in that case ! */ |
1129 | background_flags = make_transparency_pixmap (); |
1169 | background_flags = make_transparency_pixmap (); |
1130 | if (background_flags == 0) |
1170 | if (background_flags == 0) |
1131 | return false; |
1171 | return false; |
1132 | else if ((background_flags & transpTransformations) == (flags & transpTransformations) |
1172 | else if ((background_flags & transpTransformations) == (flags & transpTransformations) |
1133 | && pmap_depth == target->depth) |
1173 | && pmap_depth == target->depth) |
1134 | flags = flags & ~isInvalid; |
1174 | flags = flags & ~isInvalid; |
1135 | } |
1175 | } |
1136 | # endif |
1176 | # endif |
1137 | |
1177 | |
1138 | XImage *result = NULL; |
|
|
1139 | # ifdef HAVE_AFTERIMAGE |
1178 | # ifdef HAVE_AFTERIMAGE |
1140 | if (original_asim |
1179 | if (original_asim |
1141 | || (background_flags & transpTransformations) != (flags & transpTransformations)) |
1180 | || (background_flags & transpTransformations) != (flags & transpTransformations)) |
1142 | { |
1181 | { |
1143 | ASImage *background = NULL; |
|
|
1144 | ARGB32 as_tint = TINT_LEAVE_SAME; |
|
|
1145 | if (background_flags) |
|
|
1146 | background = pixmap2ximage (target->asv, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, 100); |
|
|
1147 | |
|
|
1148 | # ifdef ENABLE_TRANSPARENCY |
|
|
1149 | if (!(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
|
|
1150 | { |
|
|
1151 | ShadingInfo as_shade; |
|
|
1152 | as_shade.shading = (shade == 0) ? 100 : shade; |
|
|
1153 | |
|
|
1154 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
|
|
1155 | if (flags & tintSet) |
|
|
1156 | tint.get (c); |
|
|
1157 | as_shade.tintColor.red = c.r; |
|
|
1158 | as_shade.tintColor.green = c.g; |
|
|
1159 | as_shade.tintColor.blue = c.b; |
|
|
1160 | |
|
|
1161 | as_tint = shading2tint32 (&as_shade); |
|
|
1162 | } |
|
|
1163 | if (!(background_flags & transpPmapBlured) && (flags & blurNeeded) && background != NULL) |
|
|
1164 | { |
|
|
1165 | ASImage* tmp = blur_asimage_gauss (target->asv, background, h_blurRadius, v_blurRadius, 0xFFFFFFFF, |
|
|
1166 | (original_asim == NULL || tint == TINT_LEAVE_SAME)?ASA_XImage:ASA_ASImage, |
|
|
1167 | 100, ASIMAGE_QUALITY_DEFAULT); |
|
|
1168 | if (tmp) |
|
|
1169 | { |
|
|
1170 | destroy_asimage (&background); |
|
|
1171 | background = tmp; |
|
|
1172 | } |
|
|
1173 | } |
|
|
1174 | # endif |
|
|
1175 | |
|
|
1176 | if (render_asim (background, as_tint)) |
1182 | if (render_asim (background_flags)) |
1177 | flags = flags & ~isInvalid; |
1183 | flags = flags & ~isInvalid; |
1178 | if (background) |
|
|
1179 | destroy_asimage (&background); |
|
|
1180 | } |
1184 | } |
1181 | else if (background_flags && pmap_depth != target->depth) |
1185 | # endif |
|
|
1186 | |
|
|
1187 | XImage *result = NULL; |
|
|
1188 | |
|
|
1189 | if (background_flags && (flags & isInvalid)) |
1182 | { |
1190 | { |
1183 | 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); |
1184 | } |
|
|
1185 | |
1192 | |
|
|
1193 | # if !defined(HAVE_AFTERIMAGE) && !XFT |
1186 | # elif !XFT /* our own client-side tinting */ |
1194 | /* our own client-side tinting */ |
1187 | |
|
|
1188 | /* ATTENTION: We ASSUME that XFT will let us do all the tinting neccessary server-side. |
1195 | /* ATTENTION: We ASSUME that XFT will let us do all the tinting necessary server-side. |
1189 | This may need to be changed in need_client_side_rendering() logic is altered !!! */ |
1196 | This may need to be changed in need_client_side_rendering() logic is altered !!! */ |
1190 | |
|
|
1191 | if (background_flags && (flags & isInvalid)) |
|
|
1192 | { |
|
|
1193 | result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); |
|
|
1194 | if (result != NULL && !(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
1197 | if (result != NULL && !(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
1195 | { |
1198 | { |
1196 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
1199 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
1197 | if (flags & tintSet) |
1200 | if (flags & tintSet) |
1198 | tint.get (c); |
1201 | tint.get (c); |
1199 | ShadeXImage (target, result, shade, c.r, c.g, c.b); |
1202 | ShadeXImage (target, result, shade, c.r, c.g, c.b); |
1200 | } |
1203 | } |
|
|
1204 | # endif |
1201 | } |
1205 | } |
1202 | # endif /* HAVE_AFTERIMAGE */ |
|
|
1203 | |
1206 | |
1204 | if (result) |
1207 | if (result) |
1205 | { |
1208 | { |
1206 | GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL); |
1209 | GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL); |
1207 | |
1210 | |
… | |
… | |
1239 | |
1242 | |
1240 | XFreeGC (target->dpy, gc); |
1243 | XFreeGC (target->dpy, gc); |
1241 | flags = flags & ~isInvalid; |
1244 | flags = flags & ~isInvalid; |
1242 | } |
1245 | } |
1243 | |
1246 | |
1244 | XDestroyImage (result); |
1247 | XDestroyImage (result); |
1245 | } |
1248 | } |
1246 | |
1249 | |
1247 | if (flags & isInvalid) |
1250 | if (flags & isInvalid) |
1248 | { |
1251 | { |
1249 | if (pixmap != None) |
1252 | if (pixmap != None) |
… | |
… | |
1273 | # ifdef ENABLE_TRANSPARENCY |
1276 | # ifdef ENABLE_TRANSPARENCY |
1274 | root_depth = DefaultDepthOfScreen (ScreenOfDisplay (target->dpy, target->display->screen)); |
1277 | root_depth = DefaultDepthOfScreen (ScreenOfDisplay (target->dpy, target->display->screen)); |
1275 | # endif |
1278 | # endif |
1276 | return true; |
1279 | return true; |
1277 | } |
1280 | } |
|
|
1281 | |
1278 | return false; |
1282 | return false; |
1279 | } |
1283 | } |
1280 | |
1284 | |
1281 | void |
1285 | void |
1282 | bgPixmap_t::apply () |
1286 | bgPixmap_t::apply () |
1283 | { |
1287 | { |
1284 | if (target) |
1288 | if (target) |
1285 | { |
1289 | { |
1286 | flags &= ~isVtOrigin; |
1290 | flags &= ~isVtOrigin; |
|
|
1291 | |
1287 | if (pixmap != None) |
1292 | if (pixmap != None) |
1288 | { |
1293 | { |
1289 | /* set target's background to pixmap */ |
1294 | /* set target's background to pixmap */ |
1290 | # ifdef ENABLE_TRANSPARENCY |
1295 | # ifdef ENABLE_TRANSPARENCY |
1291 | if (flags & isTransparent) |
1296 | if (flags & isTransparent) |
1292 | { |
1297 | { |
1293 | XSetWindowBackgroundPixmap (target->dpy, target->parent[0], pixmap); |
1298 | XSetWindowBackgroundPixmap (target->dpy, target->parent[0], pixmap); |
1294 | XSetWindowBackgroundPixmap (target->dpy, target->vt, ParentRelative); |
1299 | XSetWindowBackgroundPixmap (target->dpy, target->vt, ParentRelative); |
|
|
1300 | |
1295 | if (target->scrollBar.win) |
1301 | if (target->scrollBar.win) |
1296 | XSetWindowBackgroundPixmap (target->dpy, target->scrollBar.win, ParentRelative); |
1302 | XSetWindowBackgroundPixmap (target->dpy, target->scrollBar.win, ParentRelative); |
1297 | } |
1303 | } |
1298 | else |
1304 | else |
1299 | # endif |
1305 | # endif |
… | |
… | |
1301 | flags |= isVtOrigin; |
1307 | flags |= isVtOrigin; |
1302 | /* force old pixmap dereference in case it was transparent before :*/ |
1308 | /* force old pixmap dereference in case it was transparent before :*/ |
1303 | XSetWindowBackground (target->dpy, target->parent[0], target->pix_colors[Color_border]); |
1309 | XSetWindowBackground (target->dpy, target->parent[0], target->pix_colors[Color_border]); |
1304 | XSetWindowBackgroundPixmap (target->dpy, target->vt, pixmap); |
1310 | XSetWindowBackgroundPixmap (target->dpy, target->vt, pixmap); |
1305 | /* do we also need to set scrollbar's background here ? */ |
1311 | /* do we also need to set scrollbar's background here ? */ |
|
|
1312 | |
1306 | if (target->scrollBar.win) |
1313 | if (target->scrollBar.win) |
1307 | XSetWindowBackground (target->dpy, target->scrollBar.win, target->pix_colors[Color_border]); |
1314 | XSetWindowBackground (target->dpy, target->scrollBar.win, target->pix_colors[Color_border]); |
1308 | } |
1315 | } |
1309 | } |
1316 | } |
1310 | else |
1317 | else |
1311 | { |
1318 | { |
1312 | /* set target background to a pixel */ |
1319 | /* set target background to a pixel */ |
1313 | XSetWindowBackground (target->dpy, target->parent[0], target->pix_colors[Color_border]); |
1320 | XSetWindowBackground (target->dpy, target->parent[0], target->pix_colors[Color_border]); |
1314 | XSetWindowBackground (target->dpy, target->vt, target->pix_colors[Color_bg]); |
1321 | XSetWindowBackground (target->dpy, target->vt, target->pix_colors[Color_bg]); |
1315 | /* do we also need to set scrollbar's background here ? */ |
1322 | /* do we also need to set scrollbar's background here ? */ |
1316 | if (target->scrollBar.win) |
1323 | if (target->scrollBar.win) |
1317 | XSetWindowBackground (target->dpy, target->scrollBar.win, target->pix_colors[Color_border]); |
1324 | XSetWindowBackground (target->dpy, target->scrollBar.win, target->pix_colors[Color_border]); |
1318 | } |
1325 | } |
|
|
1326 | |
1319 | /* don't want Expose on the parent or vt. It is better to use |
1327 | /* don't want Expose on the parent or vt. It is better to use |
1320 | scr_touch or we get a great deal of flicker otherwise: */ |
1328 | scr_touch or we get a great deal of flicker otherwise: */ |
1321 | XClearWindow (target->dpy, target->parent[0]); |
1329 | XClearWindow (target->dpy, target->parent[0]); |
1322 | |
1330 | |
1323 | if (target->scrollBar.win) |
1331 | if (target->scrollBar.state && target->scrollBar.win) |
1324 | { |
1332 | { |
1325 | target->scrollBar.setIdle (); |
1333 | target->scrollBar.state = STATE_IDLE; |
1326 | target->scrollbar_show (0); |
1334 | target->scrollBar.show (0); |
1327 | } |
1335 | } |
1328 | |
1336 | |
1329 | target->want_refresh = 1; |
1337 | target->want_refresh = 1; |
1330 | flags |= hasChanged; |
1338 | flags |= hasChanged; |
1331 | } |
1339 | } |
… | |
… | |
1337 | /* taken from aterm-0.4.2 */ |
1345 | /* taken from aterm-0.4.2 */ |
1338 | |
1346 | |
1339 | typedef uint32_t RUINT32T; |
1347 | typedef uint32_t RUINT32T; |
1340 | |
1348 | |
1341 | static void |
1349 | static void |
1342 | ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm) |
1350 | ShadeXImage(rxvt_term *term, XImage *srcImage, int shade, int rm, int gm, int bm) |
1343 | { |
1351 | { |
1344 | int sh_r, sh_g, sh_b; |
1352 | int sh_r, sh_g, sh_b; |
1345 | RUINT32T mask_r, mask_g, mask_b; |
1353 | RUINT32T mask_r, mask_g, mask_b; |
1346 | RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; |
1354 | RUINT32T *lookup, *lookup_r, *lookup_g, *lookup_b; |
1347 | unsigned int lower_lim_r, lower_lim_g, lower_lim_b; |
1355 | unsigned int lower_lim_r, lower_lim_g, lower_lim_b; |