1 | /*----------------------------------------------------------------------* |
1 | /*----------------------------------------------------------------------* |
2 | * File: background.C - former xmp.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) 1997 Carsten Haitzler <raster@zip.com.au> |
6 | * Copyright (c) 1997 Carsten Haitzler <raster@zip.com.au> |
7 | * Copyright (c) 1997,1998 Oezguer Kesim <kesim@math.fu-berlin.de> |
7 | * Copyright (c) 1997,1998 Oezguer Kesim <kesim@math.fu-berlin.de> |
… | |
… | |
31 | |
31 | |
32 | #if DO_TIMING_TEST |
32 | #if DO_TIMING_TEST |
33 | #define TIMING_TEST_START(id) \ |
33 | #define TIMING_TEST_START(id) \ |
34 | struct timeval timing_test_##id##_stv;\ |
34 | struct timeval timing_test_##id##_stv;\ |
35 | gettimeofday (&timing_test_##id##_stv, NULL); |
35 | gettimeofday (&timing_test_##id##_stv, NULL); |
36 | |
36 | |
37 | #define TIMING_TEST_PRINT_RESULT(id) \ |
37 | #define TIMING_TEST_PRINT_RESULT(id) \ |
38 | do{ struct timeval tv;gettimeofday (&tv, NULL); tv.tv_sec -= (timing_test_##id##_stv).tv_sec;\ |
38 | do{ struct timeval tv;gettimeofday (&tv, NULL); tv.tv_sec -= (timing_test_##id##_stv).tv_sec;\ |
39 | fprintf (stderr, "%s: %s: %d: elapsed %ld usec\n", #id, __FILE__, __LINE__,\ |
39 | fprintf (stderr, "%s: %s: %d: elapsed %ld usec\n", #id, __FILE__, __LINE__,\ |
40 | tv.tv_sec * 1000000 + tv.tv_usec - (timing_test_##id##_stv).tv_usec);}while (0) |
40 | tv.tv_sec * 1000000 + tv.tv_usec - (timing_test_##id##_stv).tv_usec);}while (0) |
41 | |
41 | |
… | |
… | |
100 | #endif |
100 | #endif |
101 | flags = 0; |
101 | flags = 0; |
102 | pixmap = None; |
102 | pixmap = None; |
103 | } |
103 | } |
104 | |
104 | |
|
|
105 | bgPixmap_t::~bgPixmap_t() |
|
|
106 | { |
|
|
107 | #ifdef HAVE_AFTERIMAGE |
|
|
108 | if (original_asim) |
|
|
109 | safe_asimage_destroy (original_asim); |
|
|
110 | #endif |
|
|
111 | if (pixmap && target) |
|
|
112 | XFreePixmap (target->dpy, pixmap); |
|
|
113 | } |
105 | |
114 | |
106 | bool |
115 | bool |
107 | bgPixmap_t::window_size_sensitive () |
116 | bgPixmap_t::window_size_sensitive () |
108 | { |
117 | { |
109 | # ifdef BG_IMAGE_FROM_FILE |
118 | # ifdef BG_IMAGE_FROM_FILE |
… | |
… | |
130 | return true; |
139 | return true; |
131 | # endif |
140 | # endif |
132 | # ifdef ENABLE_TRANSPARENCY |
141 | # ifdef ENABLE_TRANSPARENCY |
133 | if (flags & isTransparent) |
142 | if (flags & isTransparent) |
134 | { |
143 | { |
|
|
144 | # ifdef HAVE_AFTERIMAGE // can't blur without libAI anyways |
135 | if (((flags & blurNeeded) && !(flags & blurServerSide)) |
145 | if ((flags & blurNeeded) && !(flags & blurServerSide)) |
|
|
146 | return true; |
|
|
147 | # endif |
136 | || ((flags & tintNeeded) && !(flags & tintServerSide))) |
148 | if ((flags & tintNeeded) && !(flags & tintServerSide)) |
137 | return true; |
149 | return true; |
138 | } |
150 | } |
139 | # endif |
151 | # endif |
140 | return false; |
152 | return false; |
141 | } |
153 | } |
142 | |
154 | |
… | |
… | |
315 | else if (!(flags & geometrySet)) |
327 | else if (!(flags & geometrySet)) |
316 | { /* default geometry - scaled and centered */ |
328 | { /* default geometry - scaled and centered */ |
317 | x = y = defaultAlign; |
329 | x = y = defaultAlign; |
318 | w = h = defaultScale; |
330 | w = h = defaultScale; |
319 | } |
331 | } |
320 | |
332 | |
321 | if (!(flags & geometrySet)) |
333 | if (!(flags & geometrySet)) |
322 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
334 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
323 | |
335 | |
324 | if (ops) |
336 | if (ops) |
325 | { |
337 | { |
… | |
… | |
446 | { |
458 | { |
447 | result = original_asim; |
459 | result = original_asim; |
448 | if ((w > 0 && w != original_asim->width) |
460 | if ((w > 0 && w != original_asim->width) |
449 | || (h > 0 && h != original_asim->height)) |
461 | || (h > 0 && h != original_asim->height)) |
450 | { |
462 | { |
451 | result = scale_asimage (target->asv, original_asim, |
463 | result = scale_asimage (target->asv, original_asim, |
452 | w > 0 ? w : original_asim->width, |
464 | w > 0 ? w : original_asim->width, |
453 | h > 0 ? h : original_asim->height, |
465 | h > 0 ? h : original_asim->height, |
454 | background ? ASA_ASImage : ASA_XImage, |
466 | background ? ASA_ASImage : ASA_XImage, |
455 | 100, ASIMAGE_QUALITY_DEFAULT); |
467 | 100, ASIMAGE_QUALITY_DEFAULT); |
456 | } |
468 | } |
457 | if (background == NULL) |
469 | if (background == NULL) |
… | |
… | |
462 | new_pmap_height = result->height; |
474 | new_pmap_height = result->height; |
463 | /* we also need to tile our image in one or both directions */ |
475 | /* we also need to tile our image in one or both directions */ |
464 | if (h_scale == 0 || v_scale == 0) |
476 | if (h_scale == 0 || v_scale == 0) |
465 | { |
477 | { |
466 | ASImage *tmp = tile_asimage (target->asv, result, |
478 | ASImage *tmp = tile_asimage (target->asv, result, |
467 | (h_scale > 0) ? 0 : (int)result->width - x, |
479 | (h_scale > 0) ? 0 : (int)result->width - x, |
468 | (v_scale > 0) ? 0 : (int)result->height - y, |
480 | (v_scale > 0) ? 0 : (int)result->height - y, |
469 | result->width, result->height, |
481 | result->width, result->height, |
470 | TINT_LEAVE_SAME, ASA_XImage, |
482 | TINT_LEAVE_SAME, ASA_XImage, |
471 | 100, ASIMAGE_QUALITY_DEFAULT); |
483 | 100, ASIMAGE_QUALITY_DEFAULT); |
472 | if (tmp) |
484 | if (tmp) |
473 | { |
485 | { |
… | |
… | |
575 | } |
587 | } |
576 | |
588 | |
577 | /* put result on pixmap */ |
589 | /* put result on pixmap */ |
578 | if (dst_x < new_pmap_width && dst_y < new_pmap_height) |
590 | if (dst_x < new_pmap_width && dst_y < new_pmap_height) |
579 | asimage2drawable (target->asv, pixmap, result, gc, src_x, src_y, dst_x, dst_y, dst_width, dst_height, True); |
591 | asimage2drawable (target->asv, pixmap, result, gc, src_x, src_y, dst_x, dst_y, dst_width, dst_height, True); |
580 | |
592 | |
581 | if (result != background && result != original_asim) |
593 | if (result != background && result != original_asim) |
582 | destroy_asimage (&result); |
594 | destroy_asimage (&result); |
583 | |
595 | |
584 | XFreeGC (target->dpy, gc); |
596 | XFreeGC (target->dpy, gc); |
585 | TIMING_TEST_PRINT_RESULT (asim); |
597 | TIMING_TEST_PRINT_RESULT (asim); |
… | |
… | |
611 | f[len] = '\0'; |
623 | f[len] = '\0'; |
612 | original_asim = get_asimage (target->asimman, f, 0xFFFFFFFF, 100); |
624 | original_asim = get_asimage (target->asimman, f, 0xFFFFFFFF, 100); |
613 | free (f); |
625 | free (f); |
614 | } |
626 | } |
615 | return (original_asim != NULL); |
627 | return (original_asim != NULL); |
616 | # endif |
628 | # endif |
617 | } |
629 | } |
618 | return false; |
630 | return false; |
619 | } |
631 | } |
620 | |
632 | |
621 | # endif /* BG_IMAGE_FROM_FILE */ |
633 | # endif /* BG_IMAGE_FROM_FILE */ |
622 | |
634 | |
623 | # ifdef ENABLE_TRANSPARENCY |
635 | # ifdef ENABLE_TRANSPARENCY |
624 | bool |
636 | bool |
625 | bgPixmap_t::set_transparent () |
637 | bgPixmap_t::set_transparent () |
626 | { |
638 | { |
627 | if (!(flags & isTransparent)) |
639 | if (!(flags & isTransparent)) |
628 | { |
640 | { |
629 | flags |= isTransparent; |
641 | flags |= isTransparent; |
… | |
… | |
654 | if (v_blurRadius != vr) |
666 | if (v_blurRadius != vr) |
655 | { |
667 | { |
656 | ++changed; |
668 | ++changed; |
657 | v_blurRadius = vr; |
669 | v_blurRadius = vr; |
658 | } |
670 | } |
659 | |
671 | |
660 | if (v_blurRadius == 0 && h_blurRadius == 0) |
672 | if (v_blurRadius == 0 && h_blurRadius == 0) |
661 | flags &= ~blurNeeded; |
673 | flags &= ~blurNeeded; |
662 | else |
674 | else |
663 | flags |= blurNeeded; |
675 | flags |= blurNeeded; |
664 | |
676 | |
… | |
… | |
668 | static inline unsigned long |
680 | static inline unsigned long |
669 | compute_tint_shade_flags (rxvt_color *tint, int shade) |
681 | compute_tint_shade_flags (rxvt_color *tint, int shade) |
670 | { |
682 | { |
671 | unsigned long flags = 0; |
683 | unsigned long flags = 0; |
672 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
684 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
|
|
685 | bool has_shade = (shade > 0 && shade < 100) || (shade > 100 && shade < 200); |
673 | |
686 | |
674 | if (tint) |
687 | if (tint) |
675 | { |
688 | { |
676 | tint->get (c); |
689 | tint->get (c); |
677 | # define IS_COMPONENT_WHOLESOME(cmp) ((cmp) <= 0x000700 || (cmp) >= 0x00f700) |
690 | # define IS_COMPONENT_WHOLESOME(cmp) ((cmp) <= 0x000700 || (cmp) >= 0x00f700) |
678 | if (IS_COMPONENT_WHOLESOME (c.r) |
691 | if (!has_shade && IS_COMPONENT_WHOLESOME (c.r) |
679 | && IS_COMPONENT_WHOLESOME (c.g) |
692 | && IS_COMPONENT_WHOLESOME (c.g) |
680 | && IS_COMPONENT_WHOLESOME (c.b)) |
693 | && IS_COMPONENT_WHOLESOME (c.b)) |
681 | flags |= bgPixmap_t::tintWholesome; |
694 | flags |= bgPixmap_t::tintWholesome; |
682 | # undef IS_COMPONENT_WHOLESOME |
695 | # undef IS_COMPONENT_WHOLESOME |
683 | } |
696 | } |
684 | |
697 | |
685 | if ((shade > 0 && shade < 100) || (shade > 100 && shade < 200)) |
698 | if (has_shade) |
686 | flags |= bgPixmap_t::tintNeeded; |
699 | flags |= bgPixmap_t::tintNeeded; |
687 | else if (tint) |
700 | else if (tint) |
688 | { |
701 | { |
689 | if ((c.r > 0x000700 || c.g > 0x000700 || c.b > 0x000700) |
702 | if ((c.r > 0x000700 || c.g > 0x000700 || c.b > 0x000700) |
690 | && (c.r < 0x00f700 || c.g < 0x00f700 || c.b < 0x00f700)) |
703 | && (c.r < 0x00f700 || c.g < 0x00f700 || c.b < 0x00f700)) |
691 | { |
704 | { |
692 | flags |= bgPixmap_t::tintNeeded; |
705 | flags |= bgPixmap_t::tintNeeded; |
693 | } |
706 | } |
694 | } |
707 | } |
695 | |
708 | |
696 | if (flags & bgPixmap_t::tintNeeded) |
709 | if (flags & bgPixmap_t::tintNeeded) |
697 | { |
710 | { |
698 | if (flags & bgPixmap_t::tintWholesome) |
711 | if (flags & bgPixmap_t::tintWholesome) |
699 | flags |= bgPixmap_t::tintServerSide; |
712 | flags |= bgPixmap_t::tintServerSide; |
|
|
713 | else |
|
|
714 | { |
700 | #if XFT |
715 | #if XFT |
701 | flags |= bgPixmap_t::tintServerSide; |
716 | flags |= bgPixmap_t::tintServerSide; |
702 | #endif |
717 | #endif |
|
|
718 | } |
703 | } |
719 | } |
704 | |
720 | |
705 | return flags; |
721 | return flags; |
706 | } |
722 | } |
707 | |
723 | |
… | |
… | |
734 | bool |
750 | bool |
735 | bgPixmap_t::set_shade (const char *shade_str) |
751 | bgPixmap_t::set_shade (const char *shade_str) |
736 | { |
752 | { |
737 | int new_shade = (shade_str) ? atoi (shade_str) : 0; |
753 | int new_shade = (shade_str) ? atoi (shade_str) : 0; |
738 | |
754 | |
|
|
755 | if (new_shade < 0 && new_shade > -100) |
|
|
756 | new_shade = 200 - (100 + new_shade); |
739 | if (new_shade == 100) |
757 | else if (new_shade == 100) |
740 | new_shade = 0; |
758 | new_shade = 0; |
741 | |
759 | |
742 | if (new_shade != shade) |
760 | if (new_shade != shade) |
743 | { |
761 | { |
744 | unsigned long new_flags = compute_tint_shade_flags ((flags & tintSet) ? &tint : NULL, new_shade); |
762 | unsigned long new_flags = compute_tint_shade_flags ((flags & tintSet) ? &tint : NULL, new_shade); |
745 | shade = new_shade; |
763 | shade = new_shade; |
746 | flags = (flags & ~tintFlags) | new_flags; |
764 | flags = (flags & (~tintFlags | tintSet)) | new_flags; |
747 | return true; |
765 | return true; |
748 | } |
766 | } |
749 | return false; |
767 | return false; |
750 | } |
768 | } |
751 | |
769 | |
752 | /* make_transparency_pixmap() |
770 | /* make_transparency_pixmap() |
753 | * Builds a pixmap sized the same as terminal window, with depth same as the root window |
771 | * Builds a pixmap sized the same as terminal window, with depth same as the root window |
754 | * that pixmap contains tiled portion of the root pixmap that is supposed to be covered by |
772 | * that pixmap contains tiled portion of the root pixmap that is supposed to be covered by |
755 | * our window. |
773 | * our window. |
756 | */ |
774 | */ |
757 | unsigned long |
775 | unsigned long |
758 | bgPixmap_t::make_transparency_pixmap () |
776 | bgPixmap_t::make_transparency_pixmap () |
759 | { |
777 | { |
… | |
… | |
858 | else |
876 | else |
859 | {/* strightforward pixmap copy */ |
877 | {/* strightforward pixmap copy */ |
860 | gcv.tile = root_pixmap; |
878 | gcv.tile = root_pixmap; |
861 | gcv.fill_style = FillTiled; |
879 | gcv.fill_style = FillTiled; |
862 | |
880 | |
863 | while (sx < 0) sx += (int)window_width; |
881 | while (sx < 0) sx += (int)root_width; |
864 | while (sy < 0) sy += (int)window_height; |
882 | while (sy < 0) sy += (int)root_height; |
865 | |
883 | |
866 | gcv.ts_x_origin = -sx; |
884 | gcv.ts_x_origin = -sx; |
867 | gcv.ts_y_origin = -sy; |
885 | gcv.ts_y_origin = -sy; |
868 | gc = XCreateGC (dpy, root, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv); |
886 | gc = XCreateGC (dpy, root, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv); |
869 | |
887 | |
… | |
… | |
875 | } |
893 | } |
876 | TIMING_TEST_PRINT_RESULT (tp); |
894 | TIMING_TEST_PRINT_RESULT (tp); |
877 | |
895 | |
878 | if (tiled_root_pmap != None) |
896 | if (tiled_root_pmap != None) |
879 | { |
897 | { |
880 | if (!need_client_side_rendering ()) |
898 | if (!need_client_side_rendering ()) |
881 | { |
899 | { |
882 | if ((flags & tintNeeded)) |
900 | if ((flags & tintNeeded)) |
883 | { |
901 | { |
884 | if (flags & tintWholesome) |
902 | if (flags & tintWholesome) |
885 | { |
903 | { |
886 | /* In this case we can tint image server-side getting significant |
904 | /* In this case we can tint image server-side getting significant |
887 | * performance improvements, as we eliminate XImage transfer |
905 | * performance improvements, as we eliminate XImage transfer |
… | |
… | |
928 | pf.direct.greenMask = 0xff; |
946 | pf.direct.greenMask = 0xff; |
929 | pf.direct.blueMask = 0xff; |
947 | pf.direct.blueMask = 0xff; |
930 | pf.direct.alphaMask = 0xff; |
948 | pf.direct.alphaMask = 0xff; |
931 | |
949 | |
932 | XRenderPictFormat *solid_format = XRenderFindFormat (dpy, |
950 | XRenderPictFormat *solid_format = XRenderFindFormat (dpy, |
933 | (PictFormatType| |
951 | (PictFormatType| |
934 | PictFormatDepth| |
952 | PictFormatDepth| |
935 | PictFormatRedMask| |
953 | PictFormatRedMask| |
936 | PictFormatGreenMask| |
954 | PictFormatGreenMask| |
937 | PictFormatBlueMask| |
955 | PictFormatBlueMask| |
938 | PictFormatAlphaMask), |
956 | PictFormatAlphaMask), |
939 | &pf, |
957 | &pf, |
940 | 0); |
958 | 0); |
941 | XRenderPictFormat *root_format = XRenderFindVisualFormat (dpy, DefaultVisualOfScreen (ScreenOfDisplay (dpy, target->display->screen))); |
959 | XRenderPictFormat *root_format = XRenderFindVisualFormat (dpy, DefaultVisualOfScreen (ScreenOfDisplay (dpy, target->display->screen))); |
942 | XRenderPictureAttributes pa ; |
960 | XRenderPictureAttributes pa ; |
943 | |
961 | |
944 | back_pic = XRenderCreatePicture (dpy, tiled_root_pmap, root_format, 0, &pa); |
962 | back_pic = XRenderCreatePicture (dpy, tiled_root_pmap, root_format, 0, &pa); |
945 | |
963 | |
… | |
… | |
947 | |
965 | |
948 | Pixmap overlay_pmap = XCreatePixmap (dpy, root, 1, 1, 32); |
966 | Pixmap overlay_pmap = XCreatePixmap (dpy, root, 1, 1, 32); |
949 | Picture overlay_pic = XRenderCreatePicture (dpy, overlay_pmap, solid_format, CPRepeat, &pa); |
967 | Picture overlay_pic = XRenderCreatePicture (dpy, overlay_pmap, solid_format, CPRepeat, &pa); |
950 | XFreePixmap (dpy, overlay_pmap); |
968 | XFreePixmap (dpy, overlay_pmap); |
951 | |
969 | |
952 | pa.component_alpha = True; |
970 | pa.component_alpha = True; |
953 | Pixmap mask_pmap = XCreatePixmap (dpy, root, 1, 1, 32); |
971 | Pixmap mask_pmap = XCreatePixmap (dpy, root, 1, 1, 32); |
954 | Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat|CPComponentAlpha, &pa); |
972 | Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat|CPComponentAlpha, &pa); |
955 | XFreePixmap (dpy, mask_pmap); |
973 | XFreePixmap (dpy, mask_pmap); |
956 | |
974 | |
957 | if (mask_pic && overlay_pic && back_pic) |
975 | if (mask_pic && overlay_pic && back_pic) |
… | |
… | |
959 | XRenderColor mask_c; |
977 | XRenderColor mask_c; |
960 | |
978 | |
961 | memset (&mask_c, (shade > 100) ? 0xFF : 0x0, sizeof (mask_c)); |
979 | memset (&mask_c, (shade > 100) ? 0xFF : 0x0, sizeof (mask_c)); |
962 | mask_c.alpha = 0xffff; |
980 | mask_c.alpha = 0xffff; |
963 | XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); |
981 | XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); |
964 | memset (&mask_c, 0x0, sizeof (mask_c)); |
982 | |
965 | mask_c.alpha = 0; |
983 | mask_c.alpha = 0; |
966 | |
984 | mask_c.red = 0xffff - c.r; |
967 | if (c.r == c.b && c.b == c.g) /* pure shading */ |
985 | mask_c.green = 0xffff - c.g; |
968 | { |
986 | mask_c.blue = 0xffff - c.b; |
969 | mask_c.red = mask_c.green = mask_c.blue = 0xffff - c.r; |
|
|
970 | XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1); |
987 | XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1); |
971 | XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, window_width, window_height); |
988 | XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, window_width, window_height); |
972 | } |
|
|
973 | else |
|
|
974 | { |
|
|
975 | mask_c.red = 0xffff - c.r; |
|
|
976 | XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1); |
|
|
977 | XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, window_width, window_height); |
|
|
978 | mask_c.red = 0; |
|
|
979 | mask_c.green = 0xffff - c.g; |
|
|
980 | XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1); |
|
|
981 | XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, window_width, window_height); |
|
|
982 | mask_c.green = 0; |
|
|
983 | mask_c.blue = 0xffff - c.b; |
|
|
984 | XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1); |
|
|
985 | XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, window_width, window_height); |
|
|
986 | } |
|
|
987 | result |= transpPmapTinted; |
989 | result |= transpPmapTinted; |
988 | } |
990 | } |
989 | XRenderFreePicture (dpy, mask_pic); |
991 | XRenderFreePicture (dpy, mask_pic); |
990 | XRenderFreePicture (dpy, overlay_pic); |
992 | XRenderFreePicture (dpy, overlay_pic); |
991 | XRenderFreePicture (dpy, back_pic); |
993 | XRenderFreePicture (dpy, back_pic); |
992 | # if DO_TIMING_TEST |
994 | # if DO_TIMING_TEST |
993 | XSync (dpy, False); |
995 | XSync (dpy, False); |
994 | # endif |
996 | # endif |
995 | # endif |
997 | # endif |
996 | } |
998 | } |
997 | } |
999 | } |
998 | } /* server side rendering completed */ |
1000 | } /* server side rendering completed */ |
999 | |
1001 | |
… | |
… | |
1003 | pixmap = tiled_root_pmap; |
1005 | pixmap = tiled_root_pmap; |
1004 | pmap_width = window_width; |
1006 | pmap_width = window_width; |
1005 | pmap_height = window_height; |
1007 | pmap_height = window_height; |
1006 | pmap_depth = root_depth; |
1008 | pmap_depth = root_depth; |
1007 | } |
1009 | } |
1008 | |
1010 | |
1009 | if (gc) |
1011 | if (gc) |
1010 | XFreeGC (dpy, gc); |
1012 | XFreeGC (dpy, gc); |
1011 | |
1013 | |
1012 | TIMING_TEST_PRINT_RESULT (tp); |
1014 | TIMING_TEST_PRINT_RESULT (tp); |
1013 | |
1015 | |
1014 | return result; |
1016 | return result; |
1015 | } |
1017 | } |
1016 | |
1018 | |
1017 | bool |
1019 | bool |
1018 | bgPixmap_t::set_root_pixmap () |
1020 | bgPixmap_t::set_root_pixmap () |
1019 | { |
1021 | { |
1020 | Pixmap new_root_pixmap = None; |
1022 | Pixmap new_root_pixmap = None; |
1021 | |
1023 | |
1022 | new_root_pixmap = target->get_pixmap_property (XA_XROOTPMAP_ID); |
1024 | new_root_pixmap = target->get_pixmap_property (XA_XROOTPMAP_ID); |
1023 | if (new_root_pixmap == None) |
1025 | if (new_root_pixmap == None) |
1024 | new_root_pixmap = target->get_pixmap_property (XA_ESETROOT_PMAP_ID); |
1026 | new_root_pixmap = target->get_pixmap_property (XA_ESETROOT_PMAP_ID); |
1025 | |
1027 | |
1026 | if (new_root_pixmap != root_pixmap) |
1028 | if (new_root_pixmap != root_pixmap) |
… | |
… | |
1042 | { |
1044 | { |
1043 | unsigned long background_flags = 0; |
1045 | unsigned long background_flags = 0; |
1044 | |
1046 | |
1045 | if (target == NULL) |
1047 | if (target == NULL) |
1046 | return false; |
1048 | return false; |
|
|
1049 | |
|
|
1050 | TIMING_TEST_START (tp); |
1047 | |
1051 | |
1048 | invalidate(); |
1052 | invalidate(); |
1049 | # ifdef ENABLE_TRANSPARENCY |
1053 | # ifdef ENABLE_TRANSPARENCY |
1050 | if (flags & isTransparent) |
1054 | if (flags & isTransparent) |
1051 | { |
1055 | { |
… | |
… | |
1104 | } |
1108 | } |
1105 | else if (background_flags && pmap_depth != target->depth) |
1109 | else if (background_flags && pmap_depth != target->depth) |
1106 | { |
1110 | { |
1107 | result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); |
1111 | result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); |
1108 | } |
1112 | } |
|
|
1113 | |
1109 | # else /* our own client-side tinting */ |
1114 | # elif !XFT /* our own client-side tinting */ |
|
|
1115 | |
|
|
1116 | /* ATTENTION: We ASSUME that XFT will let us do all the tinting neccessary server-side. |
|
|
1117 | This may need to be changed in need_client_side_rendering() logic is altered !!! */ |
|
|
1118 | |
1110 | if (background_flags && (flags & isInvalid)) |
1119 | if (background_flags && (flags & isInvalid)) |
1111 | { |
1120 | { |
1112 | result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); |
1121 | result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); |
1113 | if (result != NULL && !(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
1122 | if (result != NULL && !(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
1114 | { |
1123 | { |
… | |
… | |
1165 | } |
1174 | } |
1166 | } |
1175 | } |
1167 | |
1176 | |
1168 | apply (); |
1177 | apply (); |
1169 | |
1178 | |
|
|
1179 | TIMING_TEST_PRINT_RESULT (tp); |
|
|
1180 | |
1170 | return true; |
1181 | return true; |
1171 | } |
1182 | } |
1172 | |
1183 | |
1173 | bool |
1184 | bool |
1174 | bgPixmap_t::set_target (rxvt_term *new_target) |
1185 | bgPixmap_t::set_target (rxvt_term *new_target) |
1175 | { |
1186 | { |
1176 | if (new_target) |
1187 | if (new_target) |
1177 | if (target != new_target) |
1188 | if (target != new_target) |
1178 | { |
1189 | { |
… | |
… | |
1225 | # if HAVE_SCROLLBARS |
1236 | # if HAVE_SCROLLBARS |
1226 | if (target->scrollBar.win) |
1237 | if (target->scrollBar.win) |
1227 | XSetWindowBackground (target->dpy, target->scrollBar.win, target->pix_colors[Color_border]); |
1238 | XSetWindowBackground (target->dpy, target->scrollBar.win, target->pix_colors[Color_border]); |
1228 | # endif |
1239 | # endif |
1229 | } |
1240 | } |
1230 | |
1241 | /* don't want Expose on the parent or vt. It is better to use |
1231 | /* don't want Expose on the parent */ |
1242 | scr_touch or we get a great deal of flicker otherwise: */ |
1232 | XClearArea (target->dpy, target->parent[0], 0, 0, 0, 0, False); |
1243 | XClearWindow (target->dpy, target->parent[0]); |
1233 | /* do want Expose on the vt, so we get refreshed properly */ |
|
|
1234 | XClearArea (target->dpy, target->vt, 0, 0, 0, 0, True); |
|
|
1235 | |
1244 | |
1236 | # if HAVE_SCROLLBARS |
1245 | # if HAVE_SCROLLBARS |
1237 | if (target->scrollBar.win) |
1246 | if (target->scrollBar.win) |
1238 | { |
1247 | { |
1239 | target->scrollBar.setIdle (); |
1248 | target->scrollBar.setIdle (); |
1240 | target->scrollbar_show (0); |
1249 | target->scrollbar_show (0); |
1241 | } |
1250 | } |
1242 | # endif |
1251 | # endif |
|
|
1252 | |
|
|
1253 | target->want_refresh = 1; |
|
|
1254 | flags |= hasChanged; |
1243 | } |
1255 | } |
1244 | } |
1256 | } |
1245 | |
1257 | |
1246 | #endif /* HAVE_BG_PIXMAP */ |
1258 | #endif /* HAVE_BG_PIXMAP */ |
1247 | |
1259 | |
1248 | #if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) |
1260 | #if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) && !XFT |
1249 | /* taken from aterm-0.4.2 */ |
1261 | /* taken from aterm-0.4.2 */ |
1250 | |
1262 | |
1251 | typedef uint32_t RUINT32T; |
1263 | typedef uint32_t RUINT32T; |
1252 | |
1264 | |
1253 | static void |
1265 | static void |