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 | |
… | |
… | |
130 | return true; |
130 | return true; |
131 | # endif |
131 | # endif |
132 | # ifdef ENABLE_TRANSPARENCY |
132 | # ifdef ENABLE_TRANSPARENCY |
133 | if (flags & isTransparent) |
133 | if (flags & isTransparent) |
134 | { |
134 | { |
|
|
135 | # ifdef HAVE_AFTERIMAGE // can't blur without libAI anyways |
135 | if (((flags & blurNeeded) && !(flags & blurServerSide)) |
136 | if ((flags & blurNeeded) && !(flags & blurServerSide)) |
|
|
137 | return true; |
|
|
138 | # endif |
136 | || ((flags & tintNeeded) && !(flags & tintServerSide))) |
139 | if ((flags & tintNeeded) && !(flags & tintServerSide)) |
137 | return true; |
140 | return true; |
138 | } |
141 | } |
139 | # endif |
142 | # endif |
140 | return false; |
143 | return false; |
141 | } |
144 | } |
142 | |
145 | |
… | |
… | |
315 | else if (!(flags & geometrySet)) |
318 | else if (!(flags & geometrySet)) |
316 | { /* default geometry - scaled and centered */ |
319 | { /* default geometry - scaled and centered */ |
317 | x = y = defaultAlign; |
320 | x = y = defaultAlign; |
318 | w = h = defaultScale; |
321 | w = h = defaultScale; |
319 | } |
322 | } |
320 | |
323 | |
321 | if (!(flags & geometrySet)) |
324 | if (!(flags & geometrySet)) |
322 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
325 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
323 | |
326 | |
324 | if (ops) |
327 | if (ops) |
325 | { |
328 | { |
… | |
… | |
446 | { |
449 | { |
447 | result = original_asim; |
450 | result = original_asim; |
448 | if ((w > 0 && w != original_asim->width) |
451 | if ((w > 0 && w != original_asim->width) |
449 | || (h > 0 && h != original_asim->height)) |
452 | || (h > 0 && h != original_asim->height)) |
450 | { |
453 | { |
451 | result = scale_asimage (target->asv, original_asim, |
454 | result = scale_asimage (target->asv, original_asim, |
452 | w > 0 ? w : original_asim->width, |
455 | w > 0 ? w : original_asim->width, |
453 | h > 0 ? h : original_asim->height, |
456 | h > 0 ? h : original_asim->height, |
454 | background ? ASA_ASImage : ASA_XImage, |
457 | background ? ASA_ASImage : ASA_XImage, |
455 | 100, ASIMAGE_QUALITY_DEFAULT); |
458 | 100, ASIMAGE_QUALITY_DEFAULT); |
456 | } |
459 | } |
457 | if (background == NULL) |
460 | if (background == NULL) |
… | |
… | |
462 | new_pmap_height = result->height; |
465 | new_pmap_height = result->height; |
463 | /* we also need to tile our image in one or both directions */ |
466 | /* we also need to tile our image in one or both directions */ |
464 | if (h_scale == 0 || v_scale == 0) |
467 | if (h_scale == 0 || v_scale == 0) |
465 | { |
468 | { |
466 | ASImage *tmp = tile_asimage (target->asv, result, |
469 | ASImage *tmp = tile_asimage (target->asv, result, |
467 | (h_scale > 0) ? 0 : (int)result->width - x, |
470 | (h_scale > 0) ? 0 : (int)result->width - x, |
468 | (v_scale > 0) ? 0 : (int)result->height - y, |
471 | (v_scale > 0) ? 0 : (int)result->height - y, |
469 | result->width, result->height, |
472 | result->width, result->height, |
470 | TINT_LEAVE_SAME, ASA_XImage, |
473 | TINT_LEAVE_SAME, ASA_XImage, |
471 | 100, ASIMAGE_QUALITY_DEFAULT); |
474 | 100, ASIMAGE_QUALITY_DEFAULT); |
472 | if (tmp) |
475 | if (tmp) |
473 | { |
476 | { |
… | |
… | |
575 | } |
578 | } |
576 | |
579 | |
577 | /* put result on pixmap */ |
580 | /* put result on pixmap */ |
578 | if (dst_x < new_pmap_width && dst_y < new_pmap_height) |
581 | 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); |
582 | asimage2drawable (target->asv, pixmap, result, gc, src_x, src_y, dst_x, dst_y, dst_width, dst_height, True); |
580 | |
583 | |
581 | if (result != background && result != original_asim) |
584 | if (result != background && result != original_asim) |
582 | destroy_asimage (&result); |
585 | destroy_asimage (&result); |
583 | |
586 | |
584 | XFreeGC (target->dpy, gc); |
587 | XFreeGC (target->dpy, gc); |
585 | TIMING_TEST_PRINT_RESULT (asim); |
588 | TIMING_TEST_PRINT_RESULT (asim); |
… | |
… | |
611 | f[len] = '\0'; |
614 | f[len] = '\0'; |
612 | original_asim = get_asimage (target->asimman, f, 0xFFFFFFFF, 100); |
615 | original_asim = get_asimage (target->asimman, f, 0xFFFFFFFF, 100); |
613 | free (f); |
616 | free (f); |
614 | } |
617 | } |
615 | return (original_asim != NULL); |
618 | return (original_asim != NULL); |
616 | # endif |
619 | # endif |
617 | } |
620 | } |
618 | return false; |
621 | return false; |
619 | } |
622 | } |
620 | |
623 | |
621 | # endif /* BG_IMAGE_FROM_FILE */ |
624 | # endif /* BG_IMAGE_FROM_FILE */ |
622 | |
625 | |
623 | # ifdef ENABLE_TRANSPARENCY |
626 | # ifdef ENABLE_TRANSPARENCY |
624 | bool |
627 | bool |
625 | bgPixmap_t::set_transparent () |
628 | bgPixmap_t::set_transparent () |
626 | { |
629 | { |
627 | if (!(flags & isTransparent)) |
630 | if (!(flags & isTransparent)) |
628 | { |
631 | { |
629 | flags |= isTransparent; |
632 | flags |= isTransparent; |
… | |
… | |
654 | if (v_blurRadius != vr) |
657 | if (v_blurRadius != vr) |
655 | { |
658 | { |
656 | ++changed; |
659 | ++changed; |
657 | v_blurRadius = vr; |
660 | v_blurRadius = vr; |
658 | } |
661 | } |
659 | |
662 | |
660 | if (v_blurRadius == 0 && h_blurRadius == 0) |
663 | if (v_blurRadius == 0 && h_blurRadius == 0) |
661 | flags &= ~blurNeeded; |
664 | flags &= ~blurNeeded; |
662 | else |
665 | else |
663 | flags |= blurNeeded; |
666 | flags |= blurNeeded; |
664 | |
667 | |
… | |
… | |
668 | static inline unsigned long |
671 | static inline unsigned long |
669 | compute_tint_shade_flags (rxvt_color *tint, int shade) |
672 | compute_tint_shade_flags (rxvt_color *tint, int shade) |
670 | { |
673 | { |
671 | unsigned long flags = 0; |
674 | unsigned long flags = 0; |
672 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
675 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
|
|
676 | bool has_shade = (shade > 0 && shade < 100) || (shade > 100 && shade < 200); |
673 | |
677 | |
674 | if (tint) |
678 | if (tint) |
675 | { |
679 | { |
676 | tint->get (c); |
680 | tint->get (c); |
677 | # define IS_COMPONENT_WHOLESOME(cmp) ((cmp) <= 0x000700 || (cmp) >= 0x00f700) |
681 | # define IS_COMPONENT_WHOLESOME(cmp) ((cmp) <= 0x000700 || (cmp) >= 0x00f700) |
678 | if (IS_COMPONENT_WHOLESOME (c.r) |
682 | if (!has_shade && IS_COMPONENT_WHOLESOME (c.r) |
679 | && IS_COMPONENT_WHOLESOME (c.g) |
683 | && IS_COMPONENT_WHOLESOME (c.g) |
680 | && IS_COMPONENT_WHOLESOME (c.b)) |
684 | && IS_COMPONENT_WHOLESOME (c.b)) |
681 | flags |= bgPixmap_t::tintWholesome; |
685 | flags |= bgPixmap_t::tintWholesome; |
682 | # undef IS_COMPONENT_WHOLESOME |
686 | # undef IS_COMPONENT_WHOLESOME |
683 | } |
687 | } |
684 | |
688 | |
685 | if ((shade > 0 && shade < 100) || (shade > 100 && shade < 200)) |
689 | if (has_shade) |
686 | flags |= bgPixmap_t::tintNeeded; |
690 | flags |= bgPixmap_t::tintNeeded; |
687 | else if (tint) |
691 | else if (tint) |
688 | { |
692 | { |
689 | if ((c.r > 0x000700 || c.g > 0x000700 || c.b > 0x000700) |
693 | if ((c.r > 0x000700 || c.g > 0x000700 || c.b > 0x000700) |
690 | && (c.r < 0x00f700 || c.g < 0x00f700 || c.b < 0x00f700)) |
694 | && (c.r < 0x00f700 || c.g < 0x00f700 || c.b < 0x00f700)) |
691 | { |
695 | { |
692 | flags |= bgPixmap_t::tintNeeded; |
696 | flags |= bgPixmap_t::tintNeeded; |
693 | } |
697 | } |
694 | } |
698 | } |
695 | |
699 | |
696 | if (flags & bgPixmap_t::tintNeeded) |
700 | if (flags & bgPixmap_t::tintNeeded) |
697 | { |
701 | { |
698 | if (flags & bgPixmap_t::tintWholesome) |
702 | if (flags & bgPixmap_t::tintWholesome) |
699 | flags |= bgPixmap_t::tintServerSide; |
703 | flags |= bgPixmap_t::tintServerSide; |
|
|
704 | else |
|
|
705 | { |
700 | #if XFT |
706 | #if XFT |
701 | flags |= bgPixmap_t::tintServerSide; |
707 | flags |= bgPixmap_t::tintServerSide; |
702 | #endif |
708 | #endif |
|
|
709 | } |
703 | } |
710 | } |
704 | |
711 | |
705 | return flags; |
712 | return flags; |
706 | } |
713 | } |
707 | |
714 | |
… | |
… | |
734 | bool |
741 | bool |
735 | bgPixmap_t::set_shade (const char *shade_str) |
742 | bgPixmap_t::set_shade (const char *shade_str) |
736 | { |
743 | { |
737 | int new_shade = (shade_str) ? atoi (shade_str) : 0; |
744 | int new_shade = (shade_str) ? atoi (shade_str) : 0; |
738 | |
745 | |
|
|
746 | if (new_shade < 0 && new_shade > -100) |
|
|
747 | new_shade = 200 - (100 + new_shade); |
739 | if (new_shade == 100) |
748 | else if (new_shade == 100) |
740 | new_shade = 0; |
749 | new_shade = 0; |
741 | |
750 | |
742 | if (new_shade != shade) |
751 | if (new_shade != shade) |
743 | { |
752 | { |
744 | unsigned long new_flags = compute_tint_shade_flags ((flags & tintSet) ? &tint : NULL, new_shade); |
753 | unsigned long new_flags = compute_tint_shade_flags ((flags & tintSet) ? &tint : NULL, new_shade); |
745 | shade = new_shade; |
754 | shade = new_shade; |
746 | flags = (flags & ~tintFlags) | new_flags; |
755 | flags = (flags & (~tintFlags | tintSet)) | new_flags; |
747 | return true; |
756 | return true; |
748 | } |
757 | } |
749 | return false; |
758 | return false; |
750 | } |
759 | } |
751 | |
760 | |
752 | /* make_transparency_pixmap() |
761 | /* make_transparency_pixmap() |
753 | * Builds a pixmap sized the same as terminal window, with depth same as the root window |
762 | * 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 |
763 | * that pixmap contains tiled portion of the root pixmap that is supposed to be covered by |
755 | * our window. |
764 | * our window. |
756 | */ |
765 | */ |
757 | unsigned long |
766 | unsigned long |
758 | bgPixmap_t::make_transparency_pixmap () |
767 | bgPixmap_t::make_transparency_pixmap () |
759 | { |
768 | { |
… | |
… | |
858 | else |
867 | else |
859 | {/* strightforward pixmap copy */ |
868 | {/* strightforward pixmap copy */ |
860 | gcv.tile = root_pixmap; |
869 | gcv.tile = root_pixmap; |
861 | gcv.fill_style = FillTiled; |
870 | gcv.fill_style = FillTiled; |
862 | |
871 | |
863 | while (sx < 0) sx += (int)window_width; |
872 | while (sx < 0) sx += (int)root_width; |
864 | while (sy < 0) sy += (int)window_height; |
873 | while (sy < 0) sy += (int)root_height; |
865 | |
874 | |
866 | gcv.ts_x_origin = -sx; |
875 | gcv.ts_x_origin = -sx; |
867 | gcv.ts_y_origin = -sy; |
876 | gcv.ts_y_origin = -sy; |
868 | gc = XCreateGC (dpy, root, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv); |
877 | gc = XCreateGC (dpy, root, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv); |
869 | |
878 | |
… | |
… | |
875 | } |
884 | } |
876 | TIMING_TEST_PRINT_RESULT (tp); |
885 | TIMING_TEST_PRINT_RESULT (tp); |
877 | |
886 | |
878 | if (tiled_root_pmap != None) |
887 | if (tiled_root_pmap != None) |
879 | { |
888 | { |
880 | if (!need_client_side_rendering ()) |
889 | if (!need_client_side_rendering ()) |
881 | { |
890 | { |
882 | if ((flags & tintNeeded)) |
891 | if ((flags & tintNeeded)) |
883 | { |
892 | { |
884 | if (flags & tintWholesome) |
893 | if (flags & tintWholesome) |
885 | { |
894 | { |
886 | /* In this case we can tint image server-side getting significant |
895 | /* In this case we can tint image server-side getting significant |
887 | * performance improvements, as we eliminate XImage transfer |
896 | * performance improvements, as we eliminate XImage transfer |
… | |
… | |
928 | pf.direct.greenMask = 0xff; |
937 | pf.direct.greenMask = 0xff; |
929 | pf.direct.blueMask = 0xff; |
938 | pf.direct.blueMask = 0xff; |
930 | pf.direct.alphaMask = 0xff; |
939 | pf.direct.alphaMask = 0xff; |
931 | |
940 | |
932 | XRenderPictFormat *solid_format = XRenderFindFormat (dpy, |
941 | XRenderPictFormat *solid_format = XRenderFindFormat (dpy, |
933 | (PictFormatType| |
942 | (PictFormatType| |
934 | PictFormatDepth| |
943 | PictFormatDepth| |
935 | PictFormatRedMask| |
944 | PictFormatRedMask| |
936 | PictFormatGreenMask| |
945 | PictFormatGreenMask| |
937 | PictFormatBlueMask| |
946 | PictFormatBlueMask| |
938 | PictFormatAlphaMask), |
947 | PictFormatAlphaMask), |
939 | &pf, |
948 | &pf, |
940 | 0); |
949 | 0); |
941 | XRenderPictFormat *root_format = XRenderFindVisualFormat (dpy, DefaultVisualOfScreen (ScreenOfDisplay (dpy, target->display->screen))); |
950 | XRenderPictFormat *root_format = XRenderFindVisualFormat (dpy, DefaultVisualOfScreen (ScreenOfDisplay (dpy, target->display->screen))); |
942 | XRenderPictureAttributes pa ; |
951 | XRenderPictureAttributes pa ; |
943 | |
952 | |
944 | back_pic = XRenderCreatePicture (dpy, tiled_root_pmap, root_format, 0, &pa); |
953 | back_pic = XRenderCreatePicture (dpy, tiled_root_pmap, root_format, 0, &pa); |
945 | |
954 | |
… | |
… | |
947 | |
956 | |
948 | Pixmap overlay_pmap = XCreatePixmap (dpy, root, 1, 1, 32); |
957 | Pixmap overlay_pmap = XCreatePixmap (dpy, root, 1, 1, 32); |
949 | Picture overlay_pic = XRenderCreatePicture (dpy, overlay_pmap, solid_format, CPRepeat, &pa); |
958 | Picture overlay_pic = XRenderCreatePicture (dpy, overlay_pmap, solid_format, CPRepeat, &pa); |
950 | XFreePixmap (dpy, overlay_pmap); |
959 | XFreePixmap (dpy, overlay_pmap); |
951 | |
960 | |
952 | pa.component_alpha = True; |
961 | pa.component_alpha = True; |
953 | Pixmap mask_pmap = XCreatePixmap (dpy, root, 1, 1, 32); |
962 | Pixmap mask_pmap = XCreatePixmap (dpy, root, 1, 1, 32); |
954 | Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat|CPComponentAlpha, &pa); |
963 | Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat|CPComponentAlpha, &pa); |
955 | XFreePixmap (dpy, mask_pmap); |
964 | XFreePixmap (dpy, mask_pmap); |
956 | |
965 | |
957 | if (mask_pic && overlay_pic && back_pic) |
966 | if (mask_pic && overlay_pic && back_pic) |
… | |
… | |
959 | XRenderColor mask_c; |
968 | XRenderColor mask_c; |
960 | |
969 | |
961 | memset (&mask_c, (shade > 100) ? 0xFF : 0x0, sizeof (mask_c)); |
970 | memset (&mask_c, (shade > 100) ? 0xFF : 0x0, sizeof (mask_c)); |
962 | mask_c.alpha = 0xffff; |
971 | mask_c.alpha = 0xffff; |
963 | XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); |
972 | XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); |
964 | memset (&mask_c, 0x0, sizeof (mask_c)); |
973 | |
965 | mask_c.alpha = 0; |
974 | mask_c.alpha = 0; |
966 | |
975 | mask_c.red = 0xffff - c.r; |
967 | if (c.r == c.b && c.b == c.g) /* pure shading */ |
976 | mask_c.green = 0xffff - c.g; |
968 | { |
977 | 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); |
978 | 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); |
979 | 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; |
980 | result |= transpPmapTinted; |
988 | } |
981 | } |
989 | XRenderFreePicture (dpy, mask_pic); |
982 | XRenderFreePicture (dpy, mask_pic); |
990 | XRenderFreePicture (dpy, overlay_pic); |
983 | XRenderFreePicture (dpy, overlay_pic); |
991 | XRenderFreePicture (dpy, back_pic); |
984 | XRenderFreePicture (dpy, back_pic); |
992 | # if DO_TIMING_TEST |
985 | # if DO_TIMING_TEST |
993 | XSync (dpy, False); |
986 | XSync (dpy, False); |
994 | # endif |
987 | # endif |
995 | # endif |
988 | # endif |
996 | } |
989 | } |
997 | } |
990 | } |
998 | } /* server side rendering completed */ |
991 | } /* server side rendering completed */ |
999 | |
992 | |
… | |
… | |
1003 | pixmap = tiled_root_pmap; |
996 | pixmap = tiled_root_pmap; |
1004 | pmap_width = window_width; |
997 | pmap_width = window_width; |
1005 | pmap_height = window_height; |
998 | pmap_height = window_height; |
1006 | pmap_depth = root_depth; |
999 | pmap_depth = root_depth; |
1007 | } |
1000 | } |
1008 | |
1001 | |
1009 | if (gc) |
1002 | if (gc) |
1010 | XFreeGC (dpy, gc); |
1003 | XFreeGC (dpy, gc); |
1011 | |
1004 | |
1012 | TIMING_TEST_PRINT_RESULT (tp); |
1005 | TIMING_TEST_PRINT_RESULT (tp); |
1013 | |
1006 | |
1014 | return result; |
1007 | return result; |
1015 | } |
1008 | } |
1016 | |
1009 | |
1017 | bool |
1010 | bool |
1018 | bgPixmap_t::set_root_pixmap () |
1011 | bgPixmap_t::set_root_pixmap () |
1019 | { |
1012 | { |
1020 | Pixmap new_root_pixmap = None; |
1013 | Pixmap new_root_pixmap = None; |
1021 | |
1014 | |
1022 | new_root_pixmap = target->get_pixmap_property (XA_XROOTPMAP_ID); |
1015 | new_root_pixmap = target->get_pixmap_property (XA_XROOTPMAP_ID); |
1023 | if (new_root_pixmap == None) |
1016 | if (new_root_pixmap == None) |
1024 | new_root_pixmap = target->get_pixmap_property (XA_ESETROOT_PMAP_ID); |
1017 | new_root_pixmap = target->get_pixmap_property (XA_ESETROOT_PMAP_ID); |
1025 | |
1018 | |
1026 | if (new_root_pixmap != root_pixmap) |
1019 | if (new_root_pixmap != root_pixmap) |
… | |
… | |
1042 | { |
1035 | { |
1043 | unsigned long background_flags = 0; |
1036 | unsigned long background_flags = 0; |
1044 | |
1037 | |
1045 | if (target == NULL) |
1038 | if (target == NULL) |
1046 | return false; |
1039 | return false; |
|
|
1040 | |
|
|
1041 | TIMING_TEST_START (tp); |
1047 | |
1042 | |
1048 | invalidate(); |
1043 | invalidate(); |
1049 | # ifdef ENABLE_TRANSPARENCY |
1044 | # ifdef ENABLE_TRANSPARENCY |
1050 | if (flags & isTransparent) |
1045 | if (flags & isTransparent) |
1051 | { |
1046 | { |
… | |
… | |
1104 | } |
1099 | } |
1105 | else if (background_flags && pmap_depth != target->depth) |
1100 | else if (background_flags && pmap_depth != target->depth) |
1106 | { |
1101 | { |
1107 | result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); |
1102 | result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); |
1108 | } |
1103 | } |
|
|
1104 | |
1109 | # else /* our own client-side tinting */ |
1105 | # elif !XFT /* our own client-side tinting */ |
|
|
1106 | |
|
|
1107 | /* ATTENTION: We ASSUME that XFT will let us do all the tinting neccessary server-side. |
|
|
1108 | This may need to be changed in need_client_side_rendering() logic is altered !!! */ |
|
|
1109 | |
1110 | if (background_flags && (flags & isInvalid)) |
1110 | if (background_flags && (flags & isInvalid)) |
1111 | { |
1111 | { |
1112 | result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); |
1112 | result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); |
1113 | if (result != NULL && !(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
1113 | if (result != NULL && !(background_flags & transpPmapTinted) && (flags & tintNeeded)) |
1114 | { |
1114 | { |
… | |
… | |
1165 | } |
1165 | } |
1166 | } |
1166 | } |
1167 | |
1167 | |
1168 | apply (); |
1168 | apply (); |
1169 | |
1169 | |
|
|
1170 | TIMING_TEST_PRINT_RESULT (tp); |
|
|
1171 | |
1170 | return true; |
1172 | return true; |
1171 | } |
1173 | } |
1172 | |
1174 | |
1173 | bool |
1175 | bool |
1174 | bgPixmap_t::set_target (rxvt_term *new_target) |
1176 | bgPixmap_t::set_target (rxvt_term *new_target) |
1175 | { |
1177 | { |
1176 | if (new_target) |
1178 | if (new_target) |
1177 | if (target != new_target) |
1179 | if (target != new_target) |
1178 | { |
1180 | { |
… | |
… | |
1225 | # if HAVE_SCROLLBARS |
1227 | # if HAVE_SCROLLBARS |
1226 | if (target->scrollBar.win) |
1228 | if (target->scrollBar.win) |
1227 | XSetWindowBackground (target->dpy, target->scrollBar.win, target->pix_colors[Color_border]); |
1229 | XSetWindowBackground (target->dpy, target->scrollBar.win, target->pix_colors[Color_border]); |
1228 | # endif |
1230 | # endif |
1229 | } |
1231 | } |
1230 | |
1232 | /* don't want Expose on the parent or vt. It is better to use |
1231 | /* don't want Expose on the parent */ |
1233 | scr_touch or we get a great deal of flicker otherwise: */ |
1232 | XClearArea (target->dpy, target->parent[0], 0, 0, 0, 0, False); |
1234 | 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 | |
1235 | |
1236 | # if HAVE_SCROLLBARS |
1236 | # if HAVE_SCROLLBARS |
1237 | if (target->scrollBar.win) |
1237 | if (target->scrollBar.win) |
1238 | { |
1238 | { |
1239 | target->scrollBar.setIdle (); |
1239 | target->scrollBar.setIdle (); |
1240 | target->scrollbar_show (0); |
1240 | target->scrollbar_show (0); |
1241 | } |
1241 | } |
1242 | # endif |
1242 | # endif |
|
|
1243 | |
|
|
1244 | target->want_refresh = 1; |
|
|
1245 | flags |= hasChanged; |
1243 | } |
1246 | } |
1244 | } |
1247 | } |
1245 | |
1248 | |
1246 | #endif /* HAVE_BG_PIXMAP */ |
1249 | #endif /* HAVE_BG_PIXMAP */ |
1247 | |
1250 | |
1248 | #if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) |
1251 | #if defined(ENABLE_TRANSPARENCY) && !defined(HAVE_AFTERIMAGE) && !XFT |
1249 | /* taken from aterm-0.4.2 */ |
1252 | /* taken from aterm-0.4.2 */ |
1250 | |
1253 | |
1251 | typedef uint32_t RUINT32T; |
1254 | typedef uint32_t RUINT32T; |
1252 | |
1255 | |
1253 | static void |
1256 | static void |