… | |
… | |
23 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
23 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
24 | *---------------------------------------------------------------------*/ |
24 | *---------------------------------------------------------------------*/ |
25 | |
25 | |
26 | #include "../config.h" /* NECESSARY */ |
26 | #include "../config.h" /* NECESSARY */ |
27 | #include "rxvt.h" /* NECESSARY */ |
27 | #include "rxvt.h" /* NECESSARY */ |
|
|
28 | |
|
|
29 | #define DO_TIMING_TEST 0 |
|
|
30 | |
|
|
31 | #if DO_TIMING_TEST |
|
|
32 | #define TIMING_TEST_START(id) \ |
|
|
33 | struct timeval timing_test_##id##_stv;\ |
|
|
34 | gettimeofday (&timing_test_##id##_stv, NULL); |
|
|
35 | |
|
|
36 | #define TIMING_TEST_PRINT_RESULT(id) \ |
|
|
37 | do{ struct timeval tv;gettimeofday (&tv, NULL); tv.tv_sec -= (timing_test_##id##_stv).tv_sec;\ |
|
|
38 | fprintf (stderr, "%s: %s: %d: elapsed %ld usec\n", #id, __FILE__, __LINE__,\ |
|
|
39 | tv.tv_sec * 1000000 + tv.tv_usec - (timing_test_##id##_stv).tv_usec);}while (0) |
|
|
40 | |
|
|
41 | #else |
|
|
42 | #define TIMING_TEST_START(id) do{}while (0) |
|
|
43 | #define TIMING_TEST_PRINT_RESULT(id) do{}while (0) |
|
|
44 | #endif |
28 | |
45 | |
29 | /* |
46 | /* |
30 | * Pixmap geometry string interpretation : |
47 | * Pixmap geometry string interpretation : |
31 | * Each geometry string contains zero or one scale/position |
48 | * Each geometry string contains zero or one scale/position |
32 | * adjustment and may optionally be followed by a colon and one or more |
49 | * adjustment and may optionally be followed by a colon and one or more |
… | |
… | |
77 | # ifdef XPM_BACKGROUND |
94 | # ifdef XPM_BACKGROUND |
78 | # ifdef HAVE_AFTERIMAGE |
95 | # ifdef HAVE_AFTERIMAGE |
79 | if (original_asim != NULL) |
96 | if (original_asim != NULL) |
80 | # endif |
97 | # endif |
81 | { |
98 | { |
82 | if (h_scale != 0 || v_scale != 0) |
99 | if (h_scale != 0 || v_scale != 0 |
|
|
100 | || h_align != 0 || v_align != 0) |
83 | return true; |
101 | return true; |
84 | } |
102 | } |
85 | # endif |
103 | # endif |
86 | # ifdef ENABLE_TRANSPARENCY |
104 | # ifdef ENABLE_TRANSPARENCY |
87 | if (flags & isTransparent) |
105 | if (flags & isTransparent) |
… | |
… | |
97 | return true; |
115 | return true; |
98 | # endif |
116 | # endif |
99 | # ifdef ENABLE_TRANSPARENCY |
117 | # ifdef ENABLE_TRANSPARENCY |
100 | if (flags & isTransparent) |
118 | if (flags & isTransparent) |
101 | { |
119 | { |
102 | if ((flags & blurNeeded) |
120 | if (((flags & blurNeeded) && !(flags & blurServerSide)) |
103 | || ((flags & tintNeeded) && !(flags & tintServerSide))) |
121 | || ((flags & tintNeeded) && !(flags & tintServerSide))) |
104 | return true; |
122 | return true; |
105 | } |
123 | } |
106 | # endif |
124 | # endif |
107 | return false; |
125 | return false; |
… | |
… | |
376 | int x = 0; |
394 | int x = 0; |
377 | int y = 0; |
395 | int y = 0; |
378 | int w = h_scale * target_width / 100; |
396 | int w = h_scale * target_width / 100; |
379 | int h = v_scale * target_height / 100; |
397 | int h = v_scale * target_height / 100; |
380 | |
398 | |
|
|
399 | TIMING_TEST_START (asim); |
|
|
400 | |
381 | if (original_asim) |
401 | if (original_asim) |
382 | { |
402 | { |
383 | x = make_align_position (h_align, target_width, w > 0 ? w : (int)original_asim->width); |
403 | x = make_align_position (h_align, target_width, w > 0 ? w : (int)original_asim->width); |
384 | y = make_align_position (v_align, target_height, h > 0 ? h : (int)original_asim->height); |
404 | y = make_align_position (v_align, target_height, h > 0 ? h : (int)original_asim->height); |
385 | } |
405 | } |
… | |
… | |
489 | result = tmp; |
509 | result = tmp; |
490 | } |
510 | } |
491 | free (layers); |
511 | free (layers); |
492 | } |
512 | } |
493 | } |
513 | } |
|
|
514 | TIMING_TEST_PRINT_RESULT (asim); |
494 | |
515 | |
495 | if (pixmap) |
516 | if (pixmap) |
496 | { |
517 | { |
497 | if (result == NULL |
518 | if (result == NULL |
498 | || pmap_width != new_pmap_width |
519 | || pmap_width != new_pmap_width |
… | |
… | |
544 | |
565 | |
545 | if (result != background && result != original_asim) |
566 | if (result != background && result != original_asim) |
546 | destroy_asimage (&result); |
567 | destroy_asimage (&result); |
547 | |
568 | |
548 | XFreeGC (target->dpy, gc); |
569 | XFreeGC (target->dpy, gc); |
|
|
570 | TIMING_TEST_PRINT_RESULT (asim); |
549 | } |
571 | } |
550 | |
572 | |
551 | return true; |
573 | return true; |
552 | } |
574 | } |
553 | # endif /* HAVE_AFTERIMAGE */ |
575 | # endif /* HAVE_AFTERIMAGE */ |
… | |
… | |
561 | |
583 | |
562 | if (*file != '\0') |
584 | if (*file != '\0') |
563 | { |
585 | { |
564 | # ifdef HAVE_AFTERIMAGE |
586 | # ifdef HAVE_AFTERIMAGE |
565 | if (target->asimman == NULL) |
587 | if (target->asimman == NULL) |
566 | target->asimman = create_generic_imageman(target->rs[Rs_path]); |
588 | target->asimman = create_generic_imageman (target->rs[Rs_path]); |
567 | if ((f = strchr (file, ';')) == NULL) |
589 | if ((f = strchr (file, ';')) == NULL) |
568 | original_asim = get_asimage( target->asimman, file, 0xFFFFFFFF, 100 ); |
590 | original_asim = get_asimage (target->asimman, file, 0xFFFFFFFF, 100); |
569 | else |
591 | else |
570 | { |
592 | { |
571 | size_t len = f - file; |
593 | size_t len = f - file; |
572 | f = (char *)malloc (len + 1); |
594 | f = (char *)malloc (len + 1); |
573 | strncpy (f, file, len); |
595 | strncpy (f, file, len); |
574 | f[len] = '\0'; |
596 | f[len] = '\0'; |
575 | original_asim = get_asimage( target->asimman, f, 0xFFFFFFFF, 100 ); |
597 | original_asim = get_asimage (target->asimman, f, 0xFFFFFFFF, 100); |
576 | free( f ); |
598 | free (f); |
577 | } |
599 | } |
578 | return (original_asim != NULL); |
600 | return (original_asim != NULL); |
579 | # endif |
601 | # endif |
580 | } |
602 | } |
581 | return false; |
603 | return false; |
… | |
… | |
590 | if (!(flags & isTransparent)) |
612 | if (!(flags & isTransparent)) |
591 | { |
613 | { |
592 | flags |= isTransparent; |
614 | flags |= isTransparent; |
593 | return true; |
615 | return true; |
594 | } |
616 | } |
|
|
617 | return false; |
595 | } |
618 | } |
596 | |
619 | |
597 | bool |
620 | bool |
598 | bgPixmap_t::set_blur_radius (const char *geom) |
621 | bgPixmap_t::set_blur_radius (const char *geom) |
599 | { |
622 | { |
600 | int changed = 0; |
623 | int changed = 0; |
601 | unsigned int hr, vr; |
624 | unsigned int hr, vr; |
602 | int junk; |
625 | int junk; |
603 | int geom_flags = XParseGeometry (geom, &junk, &junk, &hr, &vr); |
626 | int geom_flags = XParseGeometry (geom, &junk, &junk, &hr, &vr); |
|
|
627 | |
604 | if (!(geom_flags&WidthValue)) |
628 | if (!(geom_flags&WidthValue)) |
605 | hr = 1; |
629 | hr = 1; |
606 | if (!(geom_flags&HeightValue)) |
630 | if (!(geom_flags&HeightValue)) |
607 | vr = hr; |
631 | vr = hr; |
608 | |
632 | |
609 | if (h_blurRadius != hr) |
633 | if (h_blurRadius != hr) |
610 | { |
634 | { |
611 | ++changed; |
635 | ++changed; |
612 | h_blurRadius = hr; |
636 | h_blurRadius = hr; |
613 | } |
637 | } |
|
|
638 | |
614 | if (v_blurRadius != vr) |
639 | if (v_blurRadius != vr) |
615 | { |
640 | { |
616 | ++changed; |
641 | ++changed; |
617 | v_blurRadius = vr; |
642 | v_blurRadius = vr; |
618 | } |
643 | } |
|
|
644 | |
619 | if (v_blurRadius == 0 && h_blurRadius == 0) |
645 | if (v_blurRadius == 0 && h_blurRadius == 0) |
620 | flags &= ~blurNeeded; |
646 | flags &= ~blurNeeded; |
621 | else |
647 | else |
622 | flags |= blurNeeded; |
648 | flags |= blurNeeded; |
|
|
649 | |
623 | return (changed>0); |
650 | return (changed>0); |
624 | } |
651 | } |
625 | |
652 | |
626 | static inline unsigned long |
653 | static inline unsigned long |
627 | compute_tint_shade_flags (rxvt_color *tint, int shade) |
654 | compute_tint_shade_flags (rxvt_color *tint, int shade) |
628 | { |
655 | { |
629 | unsigned long flags = 0; |
656 | unsigned long flags = 0; |
|
|
657 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
630 | |
658 | |
631 | if (shade > 0 && shade <100) |
659 | if (tint) |
|
|
660 | { |
|
|
661 | tint->get (c); |
|
|
662 | # define IS_COMPONENT_WHOLESOME(cmp) ((cmp) <= 0x000700 || (cmp) >= 0x00f700) |
|
|
663 | if (IS_COMPONENT_WHOLESOME (c.r) |
|
|
664 | && IS_COMPONENT_WHOLESOME (c.g) |
|
|
665 | && IS_COMPONENT_WHOLESOME (c.b)) |
|
|
666 | flags |= bgPixmap_t::tintWholesome; |
|
|
667 | # undef IS_COMPONENT_WHOLESOME |
|
|
668 | } |
|
|
669 | |
|
|
670 | if ((shade > 0 && shade < 100) || (shade > 100 && shade < 200)) |
632 | flags |= bgPixmap_t::tintNeeded; |
671 | flags |= bgPixmap_t::tintNeeded; |
633 | else if (tint) |
672 | else if (tint) |
634 | { |
673 | { |
635 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
|
|
636 | tint->get (c); |
|
|
637 | |
|
|
638 | if ((c.r > 0x000700 || c.g > 0x000700 || c.b > 0x000700) |
674 | if ((c.r > 0x000700 || c.g > 0x000700 || c.b > 0x000700) |
639 | && (c.r < 0x00f700 || c.g < 0x00f700 || c.b < 0x00f700)) |
675 | && (c.r < 0x00f700 || c.g < 0x00f700 || c.b < 0x00f700)) |
640 | { |
676 | { |
641 | flags |= bgPixmap_t::tintNeeded; |
677 | flags |= bgPixmap_t::tintNeeded; |
642 | # define IS_COMPONENT_WHOLESOME(cmp) ((cmp) <= 0x000700 || (cmp) >= 0x00f700) |
|
|
643 | if (IS_COMPONENT_WHOLESOME (c.r) |
|
|
644 | && IS_COMPONENT_WHOLESOME (c.g) |
|
|
645 | && IS_COMPONENT_WHOLESOME (c.b)) |
|
|
646 | flags |= bgPixmap_t::tintServerSide; |
|
|
647 | # undef IS_COMPONENT_WHOLESOME |
|
|
648 | } |
678 | } |
649 | } |
679 | } |
|
|
680 | |
|
|
681 | if (flags & bgPixmap_t::tintNeeded) |
|
|
682 | { |
|
|
683 | if (flags & bgPixmap_t::tintWholesome) |
|
|
684 | flags |= bgPixmap_t::tintServerSide; |
|
|
685 | #if XFT |
|
|
686 | flags |= bgPixmap_t::tintServerSide; |
|
|
687 | #endif |
|
|
688 | } |
|
|
689 | |
650 | return flags; |
690 | return flags; |
651 | } |
691 | } |
652 | |
692 | |
653 | bool |
693 | bool |
654 | bgPixmap_t::set_tint (rxvt_color &new_tint) |
694 | bgPixmap_t::set_tint (rxvt_color &new_tint) |
… | |
… | |
684 | if (new_shade == 100) |
724 | if (new_shade == 100) |
685 | new_shade = 0; |
725 | new_shade = 0; |
686 | |
726 | |
687 | if (new_shade != shade) |
727 | if (new_shade != shade) |
688 | { |
728 | { |
689 | unsigned long new_flags = compute_tint_shade_flags (&tint, new_shade); |
729 | unsigned long new_flags = compute_tint_shade_flags ((flags & tintSet) ? &tint : NULL, new_shade); |
690 | shade = new_shade; |
730 | shade = new_shade; |
691 | flags = (flags & ~tintFlags) | new_flags; |
731 | flags = (flags & ~tintFlags) | new_flags; |
692 | return true; |
732 | return true; |
693 | } |
733 | } |
694 | return false; |
734 | return false; |
695 | } |
735 | } |
696 | |
|
|
697 | |
736 | |
698 | /* make_transparency_pixmap() |
737 | /* make_transparency_pixmap() |
699 | * Builds a pixmap sized the same as terminal window, with depth same as the root window |
738 | * Builds a pixmap sized the same as terminal window, with depth same as the root window |
700 | * that pixmap contains tiled portion of the root pixmap that is supposed to be covered by |
739 | * that pixmap contains tiled portion of the root pixmap that is supposed to be covered by |
701 | * our window. |
740 | * our window. |
… | |
… | |
720 | int window_width = target->szHint.width; |
759 | int window_width = target->szHint.width; |
721 | int window_height = target->szHint.height; |
760 | int window_height = target->szHint.height; |
722 | int sx, sy; |
761 | int sx, sy; |
723 | XGCValues gcv; |
762 | XGCValues gcv; |
724 | |
763 | |
|
|
764 | TIMING_TEST_START (tp); |
725 | target->get_window_origin (sx, sy); |
765 | target->get_window_origin (sx, sy); |
726 | |
766 | |
727 | /* check if we are outside of the visible part of the virtual screen : */ |
767 | /* check if we are outside of the visible part of the virtual screen : */ |
728 | if (sx + window_width <= 0 || sy + window_height <= 0 |
768 | if (sx + window_width <= 0 || sy + window_height <= 0 |
729 | || sx >= root_width || sy >= root_height) |
769 | || sx >= root_width || sy >= root_height) |
… | |
… | |
733 | {/* we want to validate the pixmap and get it's size at the same time : */ |
773 | {/* we want to validate the pixmap and get it's size at the same time : */ |
734 | int junk; |
774 | int junk; |
735 | unsigned int ujunk; |
775 | unsigned int ujunk; |
736 | /* root pixmap may be bad - allow a error */ |
776 | /* root pixmap may be bad - allow a error */ |
737 | target->allowedxerror = -1; |
777 | target->allowedxerror = -1; |
|
|
778 | |
738 | if (!XGetGeometry (dpy, root_pixmap, &root, &junk, &junk, &root_pmap_width, &root_pmap_height, &ujunk, &ujunk)) |
779 | if (!XGetGeometry (dpy, root_pixmap, &root, &junk, &junk, &root_pmap_width, &root_pmap_height, &ujunk, &ujunk)) |
739 | root_pixmap = None; |
780 | root_pixmap = None; |
|
|
781 | |
740 | target->allowedxerror = 0; |
782 | target->allowedxerror = 0; |
741 | } |
783 | } |
742 | |
784 | |
743 | Pixmap tiled_root_pmap = XCreatePixmap (dpy, root, window_width, window_height, root_depth); |
785 | Pixmap tiled_root_pmap = XCreatePixmap (dpy, root, window_width, window_height, root_depth); |
744 | GC gc = NULL; |
786 | GC gc = NULL; |
… | |
… | |
768 | XEvent event; |
810 | XEvent event; |
769 | int ev_count = 0; |
811 | int ev_count = 0; |
770 | XGrabServer (dpy); |
812 | XGrabServer (dpy); |
771 | XMapRaised (dpy, src); |
813 | XMapRaised (dpy, src); |
772 | XSync (dpy, False); |
814 | XSync (dpy, False); |
|
|
815 | |
773 | /* XSync should get window where it's properly exposed, |
816 | /* XSync should get window where it's properly exposed, |
774 | * but to be on the safe side - let's check for the actuall event to arrive : */ |
817 | * but to be on the safe side - let's check for the actuall event to arrive : */ |
775 | while (XCheckWindowEvent (dpy, src, ExposureMask, &event)) |
818 | while (XCheckWindowEvent (dpy, src, ExposureMask, &event)) |
776 | ++ev_count; |
819 | ++ev_count; |
|
|
820 | |
777 | if (ev_count > 0); |
821 | if (ev_count > 0); |
778 | { /* hooray! - we can grab the image! */ |
822 | { /* hooray! - we can grab the image! */ |
779 | gc = XCreateGC (dpy, root, 0, NULL); |
823 | gc = XCreateGC (dpy, root, 0, NULL); |
780 | if (gc) |
824 | if (gc) |
781 | { |
825 | { |
… | |
… | |
785 | } |
829 | } |
786 | XDestroyWindow (dpy, src); |
830 | XDestroyWindow (dpy, src); |
787 | XUngrabServer (dpy); |
831 | XUngrabServer (dpy); |
788 | //fprintf (stderr, "%s:%d: ev_count = %d\n", __FUNCTION__, __LINE__, ev_count); |
832 | //fprintf (stderr, "%s:%d: ev_count = %d\n", __FUNCTION__, __LINE__, ev_count); |
789 | } |
833 | } |
|
|
834 | |
790 | if (!success) |
835 | if (!success) |
791 | { |
836 | { |
792 | XFreePixmap (dpy, tiled_root_pmap); |
837 | XFreePixmap (dpy, tiled_root_pmap); |
793 | tiled_root_pmap = None; |
838 | tiled_root_pmap = None; |
794 | } |
839 | } |
… | |
… | |
797 | } |
842 | } |
798 | else |
843 | else |
799 | {/* strightforward pixmap copy */ |
844 | {/* strightforward pixmap copy */ |
800 | gcv.tile = root_pixmap; |
845 | gcv.tile = root_pixmap; |
801 | gcv.fill_style = FillTiled; |
846 | gcv.fill_style = FillTiled; |
|
|
847 | |
802 | while (sx < 0) sx += (int)window_width; |
848 | while (sx < 0) sx += (int)window_width; |
803 | while (sy < 0) sy += (int)window_height; |
849 | while (sy < 0) sy += (int)window_height; |
|
|
850 | |
804 | gcv.ts_x_origin = -sx; |
851 | gcv.ts_x_origin = -sx; |
805 | gcv.ts_y_origin = -sy; |
852 | gcv.ts_y_origin = -sy; |
806 | gc = XCreateGC (dpy, root, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv); |
853 | gc = XCreateGC (dpy, root, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv); |
|
|
854 | |
807 | if (gc) |
855 | if (gc) |
808 | { |
856 | { |
809 | XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height); |
857 | XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height); |
810 | result |= transpPmapTiled; |
858 | result |= transpPmapTiled; |
811 | } |
859 | } |
812 | } |
860 | } |
|
|
861 | TIMING_TEST_PRINT_RESULT (tp); |
813 | |
862 | |
814 | if (tiled_root_pmap != None) |
863 | if (tiled_root_pmap != None) |
|
|
864 | { |
|
|
865 | if (!need_client_side_rendering ()) |
815 | { |
866 | { |
816 | if (flags & tintNeeded && !need_client_side_rendering ()) |
867 | if ((flags & tintNeeded)) |
817 | { |
868 | { |
|
|
869 | if (flags & tintWholesome) |
|
|
870 | { |
818 | /* In this case we can tint image server-side getting significant |
871 | /* In this case we can tint image server-side getting significant |
819 | * performance improvements, as we eliminate XImage transfer |
872 | * performance improvements, as we eliminate XImage transfer |
820 | */ |
873 | */ |
821 | gcv.foreground = Pixel (tint); |
874 | gcv.foreground = Pixel (tint); |
822 | gcv.function = GXand; |
875 | gcv.function = GXand; |
823 | gcv.fill_style = FillSolid; |
876 | gcv.fill_style = FillSolid; |
824 | if (gc) |
877 | if (gc) |
825 | XChangeGC (dpy, gc, GCFillStyle | GCForeground | GCFunction, &gcv); |
878 | XChangeGC (dpy, gc, GCFillStyle | GCForeground | GCFunction, &gcv); |
826 | else |
879 | else |
827 | gc = XCreateGC (dpy, root, GCFillStyle | GCForeground | GCFunction, &gcv); |
880 | gc = XCreateGC (dpy, root, GCFillStyle | GCForeground | GCFunction, &gcv); |
828 | if (gc) |
881 | if (gc) |
829 | { |
882 | { |
830 | XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height); |
883 | XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height); |
831 | result |= transpPmapTinted; |
884 | result |= transpPmapTinted; |
|
|
885 | } |
|
|
886 | } |
|
|
887 | else |
|
|
888 | { |
|
|
889 | # if XFT |
|
|
890 | Picture back_pic = 0; |
|
|
891 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
|
|
892 | |
|
|
893 | if (flags & tintSet) |
|
|
894 | tint.get (c); |
|
|
895 | |
|
|
896 | if (shade > 0 && shade < 100) |
|
|
897 | { |
|
|
898 | c.r = (c.r * shade) / 100; |
|
|
899 | c.g = (c.g * shade) / 100; |
|
|
900 | c.b = (c.b * shade) / 100; |
|
|
901 | } |
|
|
902 | else if( shade > 100 && shade < 200) |
|
|
903 | { |
|
|
904 | c.r = (c.r * (200 - shade)) / 100; |
|
|
905 | c.g = (c.g * (200 - shade)) / 100; |
|
|
906 | c.b = (c.b * (200 - shade)) / 100; |
|
|
907 | } |
|
|
908 | |
|
|
909 | XRenderPictFormat pf; |
|
|
910 | pf.type = PictTypeDirect; |
|
|
911 | pf.depth = 32; |
|
|
912 | pf.direct.redMask = 0xff; |
|
|
913 | pf.direct.greenMask = 0xff; |
|
|
914 | pf.direct.blueMask = 0xff; |
|
|
915 | pf.direct.alphaMask = 0xff; |
|
|
916 | |
|
|
917 | XRenderPictFormat *solid_format = XRenderFindFormat (dpy, |
|
|
918 | (PictFormatType| |
|
|
919 | PictFormatDepth| |
|
|
920 | PictFormatRedMask| |
|
|
921 | PictFormatGreenMask| |
|
|
922 | PictFormatBlueMask| |
|
|
923 | PictFormatAlphaMask), |
|
|
924 | &pf, |
|
|
925 | 0); |
|
|
926 | XRenderPictFormat *root_format = XRenderFindVisualFormat (dpy, DefaultVisualOfScreen (ScreenOfDisplay (dpy, target->display->screen))); |
|
|
927 | XRenderPictureAttributes pa ; |
|
|
928 | |
|
|
929 | back_pic = XRenderCreatePicture (dpy, tiled_root_pmap, root_format, 0, &pa); |
|
|
930 | |
|
|
931 | pa.repeat = True; |
|
|
932 | |
|
|
933 | Pixmap overlay_pmap = XCreatePixmap (dpy, root, 1, 1, 32); |
|
|
934 | Picture overlay_pic = XRenderCreatePicture (dpy, overlay_pmap, solid_format, CPRepeat, &pa); |
|
|
935 | XFreePixmap (dpy, overlay_pmap); |
|
|
936 | |
|
|
937 | pa.component_alpha = True; |
|
|
938 | Pixmap mask_pmap = XCreatePixmap (dpy, root, 1, 1, 32); |
|
|
939 | Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat|CPComponentAlpha, &pa); |
|
|
940 | XFreePixmap (dpy, mask_pmap); |
|
|
941 | |
|
|
942 | if (mask_pic && overlay_pic && back_pic) |
|
|
943 | { |
|
|
944 | XRenderColor mask_c; |
|
|
945 | |
|
|
946 | memset (&mask_c, (shade > 100) ? 0xFF : 0x0, sizeof (mask_c)); |
|
|
947 | mask_c.alpha = 0xffff; |
|
|
948 | XRenderFillRectangle (dpy, PictOpSrc, overlay_pic, &mask_c, 0, 0, 1, 1); |
|
|
949 | memset (&mask_c, 0x0, sizeof (mask_c)); |
|
|
950 | mask_c.alpha = 0; |
|
|
951 | |
|
|
952 | if (c.r == c.b && c.b == c.g) /* pure shading */ |
|
|
953 | { |
|
|
954 | mask_c.red = mask_c.green = mask_c.blue = 0xffff - c.r; |
|
|
955 | XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1); |
|
|
956 | XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, window_width, window_height); |
|
|
957 | } |
|
|
958 | else |
|
|
959 | { |
|
|
960 | mask_c.red = 0xffff - c.r; |
|
|
961 | XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1); |
|
|
962 | XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, window_width, window_height); |
|
|
963 | mask_c.red = 0; |
|
|
964 | mask_c.green = 0xffff - c.g; |
|
|
965 | XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1); |
|
|
966 | XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, window_width, window_height); |
|
|
967 | mask_c.green = 0; |
|
|
968 | mask_c.blue = 0xffff - c.b; |
|
|
969 | XRenderFillRectangle (dpy, PictOpSrc, mask_pic, &mask_c, 0, 0, 1, 1); |
|
|
970 | XRenderComposite (dpy, PictOpOver, overlay_pic, mask_pic, back_pic, 0, 0, 0, 0, 0, 0, window_width, window_height); |
|
|
971 | } |
|
|
972 | result |= transpPmapTinted; |
|
|
973 | } |
|
|
974 | XRenderFreePicture (dpy, mask_pic); |
|
|
975 | XRenderFreePicture (dpy, overlay_pic); |
|
|
976 | XRenderFreePicture (dpy, back_pic); |
|
|
977 | # if DO_TIMING_TEST |
|
|
978 | XSync (dpy, False); |
|
|
979 | # endif |
|
|
980 | # endif |
|
|
981 | } |
832 | } |
982 | } |
833 | } |
983 | } /* server side rendering completed */ |
|
|
984 | |
834 | if (pixmap) |
985 | if (pixmap) |
835 | XFreePixmap (dpy, pixmap); |
986 | XFreePixmap (dpy, pixmap); |
|
|
987 | |
836 | pixmap = tiled_root_pmap; |
988 | pixmap = tiled_root_pmap; |
837 | pmap_width = window_width; |
989 | pmap_width = window_width; |
838 | pmap_height = window_height; |
990 | pmap_height = window_height; |
839 | pmap_depth = root_depth; |
991 | pmap_depth = root_depth; |
840 | } |
992 | } |
841 | |
993 | |
842 | if (gc) |
994 | if (gc) |
843 | XFreeGC (dpy, gc); |
995 | XFreeGC (dpy, gc); |
|
|
996 | |
|
|
997 | TIMING_TEST_PRINT_RESULT (tp); |
844 | |
998 | |
845 | return result; |
999 | return result; |
846 | } |
1000 | } |
847 | |
1001 | |
848 | bool |
1002 | bool |
849 | bgPixmap_t::set_root_pixmap () |
1003 | bgPixmap_t::set_root_pixmap () |
850 | { |
1004 | { |
… | |
… | |
948 | tint.get (c); |
1102 | tint.get (c); |
949 | ShadeXImage (target, result, shade, c.r, c.g, c.b); |
1103 | ShadeXImage (target, result, shade, c.r, c.g, c.b); |
950 | } |
1104 | } |
951 | } |
1105 | } |
952 | # endif /* HAVE_AFTERIMAGE */ |
1106 | # endif /* HAVE_AFTERIMAGE */ |
|
|
1107 | |
953 | if (result != NULL) |
1108 | if (result != NULL) |
954 | { |
1109 | { |
955 | GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL); |
1110 | GC gc = XCreateGC (target->dpy, target->vt, 0UL, NULL); |
956 | if (gc) |
1111 | if (gc) |
957 | { |
1112 | { |
… | |
… | |
1018 | void |
1173 | void |
1019 | bgPixmap_t::apply() |
1174 | bgPixmap_t::apply() |
1020 | { |
1175 | { |
1021 | if (target) |
1176 | if (target) |
1022 | { |
1177 | { |
|
|
1178 | flags &= ~isVtOrigin; |
1023 | if (pixmap != None) |
1179 | if (pixmap != None) |
1024 | { /* set target's background to pixmap */ |
1180 | { /* set target's background to pixmap */ |
1025 | # ifdef ENABLE_TRANSPARENCY |
1181 | # ifdef ENABLE_TRANSPARENCY |
1026 | if (flags & isTransparent) |
1182 | if (flags & isTransparent) |
1027 | { |
1183 | { |
… | |
… | |
1033 | # endif |
1189 | # endif |
1034 | } |
1190 | } |
1035 | else |
1191 | else |
1036 | # endif |
1192 | # endif |
1037 | { |
1193 | { |
|
|
1194 | flags |= isVtOrigin; |
1038 | /* force old pixmap dereference in case it was transparent before :*/ |
1195 | /* force old pixmap dereference in case it was transparent before :*/ |
1039 | XSetWindowBackground (target->dpy, target->parent[0], target->pix_colors[Color_border]); |
1196 | XSetWindowBackground (target->dpy, target->parent[0], target->pix_colors[Color_border]); |
1040 | XSetWindowBackgroundPixmap (target->dpy, target->vt, pixmap); |
1197 | XSetWindowBackgroundPixmap (target->dpy, target->vt, pixmap); |
1041 | /* do we also need to set scrollbar's background here ? */ |
1198 | /* do we also need to set scrollbar's background here ? */ |
1042 | # if HAVE_SCROLLBARS |
1199 | # if HAVE_SCROLLBARS |
… | |
… | |
1053 | # if HAVE_SCROLLBARS |
1210 | # if HAVE_SCROLLBARS |
1054 | if (target->scrollBar.win) |
1211 | if (target->scrollBar.win) |
1055 | XSetWindowBackground (target->dpy, target->scrollBar.win, target->pix_colors[Color_border]); |
1212 | XSetWindowBackground (target->dpy, target->scrollBar.win, target->pix_colors[Color_border]); |
1056 | # endif |
1213 | # endif |
1057 | } |
1214 | } |
|
|
1215 | |
1058 | /* don't want Expose on the parent */ |
1216 | /* don't want Expose on the parent */ |
1059 | XClearArea (target->dpy, target->parent[0], 0, 0, 0, 0, False); |
1217 | XClearArea (target->dpy, target->parent[0], 0, 0, 0, 0, False); |
1060 | /* do want Expose on the vt */ |
1218 | /* do want Expose on the vt, so we get refreshed properly */ |
1061 | XClearArea (target->dpy, target->parent[0], 0, 0, 0, 0, True); |
1219 | XClearArea (target->dpy, target->vt, 0, 0, 0, 0, True); |
|
|
1220 | |
1062 | # if HAVE_SCROLLBARS |
1221 | # if HAVE_SCROLLBARS |
1063 | if (target->scrollBar.win) |
1222 | if (target->scrollBar.win) |
1064 | { |
1223 | { |
1065 | target->scrollBar.setIdle (); |
1224 | target->scrollBar.setIdle (); |
1066 | target->scrollbar_show (0); |
1225 | target->scrollbar_show (0); |
1067 | } |
1226 | } |
1068 | # endif |
1227 | # endif |
1069 | /* Is that really neccessary? we did a XClearArea to generate Expose events alreday ! */ |
|
|
1070 | target->want_refresh = 1; |
|
|
1071 | # ifdef ENABLE_TRANSPARENCY |
|
|
1072 | target->want_full_refresh = 1; |
|
|
1073 | # endif |
|
|
1074 | /* TODO: why do we need a flush here ??? It causes segfault on resize ! */ |
|
|
1075 | // target->flush (); |
|
|
1076 | } |
1228 | } |
1077 | } |
1229 | } |
1078 | |
1230 | |
1079 | void |
1231 | void |
1080 | rxvt_term::get_window_origin (int &x, int &y) |
1232 | rxvt_term::get_window_origin (int &x, int &y) |
… | |
… | |
1088 | rxvt_term::get_pixmap_property (int prop_id) |
1240 | rxvt_term::get_pixmap_property (int prop_id) |
1089 | { |
1241 | { |
1090 | if (prop_id > 0 && prop_id < NUM_XA) |
1242 | if (prop_id > 0 && prop_id < NUM_XA) |
1091 | if (xa[prop_id]) |
1243 | if (xa[prop_id]) |
1092 | { |
1244 | { |
1093 | int aformat, rootdepth; |
1245 | int aformat; |
1094 | unsigned long nitems, bytes_after; |
1246 | unsigned long nitems, bytes_after; |
1095 | Atom atype; |
1247 | Atom atype; |
1096 | unsigned char *prop = NULL; |
1248 | unsigned char *prop = NULL; |
1097 | int result = XGetWindowProperty (dpy, display->root, xa[prop_id], |
1249 | int result = XGetWindowProperty (dpy, display->root, xa[prop_id], |
1098 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
1250 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
… | |
… | |
1111 | */ |
1263 | */ |
1112 | int |
1264 | int |
1113 | rxvt_term::update_background () |
1265 | rxvt_term::update_background () |
1114 | { |
1266 | { |
1115 | bgPixmap.invalidate(); |
1267 | bgPixmap.invalidate(); |
|
|
1268 | |
1116 | /* no chance of real time refresh if we are blurring ! */ |
1269 | /* no chance of real time refresh if we are blurring ! */ |
1117 | if (bgPixmap.invalid_since + 0.5 < NOW && !(bgPixmap.flags & bgPixmap_t::blurNeeded)) |
1270 | if (bgPixmap.invalid_since + 0.5 < NOW && !(bgPixmap.flags & bgPixmap_t::blurNeeded)) |
1118 | bgPixmap.render(); |
1271 | bgPixmap.render(); |
1119 | else |
1272 | else |
1120 | { |
1273 | { |
… | |
… | |
1155 | |
1308 | |
1156 | if (visual->c_class != TrueColor || srcImage->format != ZPixmap) return ; |
1309 | if (visual->c_class != TrueColor || srcImage->format != ZPixmap) return ; |
1157 | |
1310 | |
1158 | if (shade == 0) |
1311 | if (shade == 0) |
1159 | shade = 100; |
1312 | shade = 100; |
1160 | |
1313 | |
1161 | /* for convenience */ |
1314 | /* for convenience */ |
1162 | mask_r = visual->red_mask; |
1315 | mask_r = visual->red_mask; |
1163 | mask_g = visual->green_mask; |
1316 | mask_g = visual->green_mask; |
1164 | mask_b = visual->blue_mask; |
1317 | mask_b = visual->blue_mask; |
1165 | |
1318 | |
… | |
… | |
1387 | Window cr; |
1540 | Window cr; |
1388 | unsigned int rootpixmap_w = 0, rootpixmap_h = 0; |
1541 | unsigned int rootpixmap_w = 0, rootpixmap_h = 0; |
1389 | |
1542 | |
1390 | if (!option (Opt_transparent)) |
1543 | if (!option (Opt_transparent)) |
1391 | return; /* Don't try any more */ |
1544 | return; /* Don't try any more */ |
1392 | #if 0 |
|
|
1393 | struct timeval stv; |
|
|
1394 | gettimeofday (&stv,NULL); |
|
|
1395 | #define PRINT_BACKGROUND_OP_TIME do{ struct timeval tv;gettimeofday (&tv,NULL); tv.tv_sec-= stv.tv_sec;\ |
|
|
1396 | fprintf (stderr,"%d: elapsed %ld usec\n",__LINE__,\ |
|
|
1397 | tv.tv_sec*1000000+tv.tv_usec-stv.tv_usec );}while(0) |
|
|
1398 | #else |
|
|
1399 | #define PRINT_BACKGROUND_OP_TIME do{}while(0) |
|
|
1400 | #endif |
|
|
1401 | |
|
|
1402 | |
1545 | |
1403 | XGetWindowAttributes (dpy, display->root, &wrootattr); |
1546 | XGetWindowAttributes (dpy, display->root, &wrootattr); |
1404 | rootdepth = wrootattr.depth; |
1547 | rootdepth = wrootattr.depth; |
1405 | |
1548 | |
1406 | XGetWindowAttributes (dpy, parent[0], &wattr); |
1549 | XGetWindowAttributes (dpy, parent[0], &wattr); |
… | |
… | |
1540 | { |
1683 | { |
1541 | XImage *image = XGetImage (dpy, bgPixmap.pixmap, 0, 0, szHint.width, szHint.height, AllPlanes, ZPixmap); |
1684 | XImage *image = XGetImage (dpy, bgPixmap.pixmap, 0, 0, szHint.width, szHint.height, AllPlanes, ZPixmap); |
1542 | success = False; |
1685 | success = False; |
1543 | if (image != NULL) |
1686 | if (image != NULL) |
1544 | { |
1687 | { |
1545 | PRINT_BACKGROUND_OP_TIME; |
|
|
1546 | if (gc == NULL) |
1688 | if (gc == NULL) |
1547 | gc = XCreateGC (dpy, vt, 0UL, &gcvalue); |
1689 | gc = XCreateGC (dpy, vt, 0UL, &gcvalue); |
1548 | if (ISSET_PIXCOLOR (Color_tint) || shade != 100) |
1690 | if (ISSET_PIXCOLOR (Color_tint) || shade != 100) |
1549 | ShadeXImage (this, image, shade, c.r, c.g, c.b); |
1691 | ShadeXImage (this, image, shade, c.r, c.g, c.b); |
1550 | XPutImage (dpy, bgPixmap.pixmap, gc, image, 0, 0, 0, 0, image->width, image->height); |
1692 | XPutImage (dpy, bgPixmap.pixmap, gc, image, 0, 0, 0, 0, image->width, image->height); |
1551 | XDestroyImage (image); |
1693 | XDestroyImage (image); |
1552 | success = True; |
1694 | success = True; |
1553 | } |
1695 | } |
1554 | } |
1696 | } |
1555 | #endif /* HAVE_AFTERIMAGE */ |
1697 | #endif /* HAVE_AFTERIMAGE */ |
1556 | PRINT_BACKGROUND_OP_TIME; |
|
|
1557 | |
1698 | |
1558 | if (gc != NULL) |
1699 | if (gc != NULL) |
1559 | XFreeGC (dpy, gc); |
1700 | XFreeGC (dpy, gc); |
1560 | |
1701 | |
1561 | bgPixmap.apply(); |
1702 | bgPixmap.apply(); |