… | |
… | |
72 | |
72 | |
73 | #ifdef HAVE_BG_PIXMAP |
73 | #ifdef HAVE_BG_PIXMAP |
74 | bool |
74 | bool |
75 | bgPixmap_t::window_size_sensitive () |
75 | bgPixmap_t::window_size_sensitive () |
76 | { |
76 | { |
77 | #ifdef XPM_BACKGROUND |
77 | # ifdef XPM_BACKGROUND |
78 | #ifdef HAVE_AFTERIMAGE |
78 | # ifdef HAVE_AFTERIMAGE |
79 | if (original_asim != NULL) |
79 | if (original_asim != NULL) |
80 | #endif |
80 | # endif |
81 | { |
81 | { |
82 | if (h_scale != 0 || v_scale != 0) |
82 | if (h_scale != 0 || v_scale != 0) |
83 | return true; |
83 | return true; |
84 | } |
84 | } |
85 | #endif |
85 | # endif |
86 | #ifdef ENABLE_TRANSPARENCY |
86 | # ifdef ENABLE_TRANSPARENCY |
87 | if (flags & bgPmap_Transparent) |
87 | if (flags & bgPmap_Transparent) |
88 | return true; |
88 | return true; |
89 | #endif |
89 | # endif |
90 | return false; |
90 | return false; |
91 | } |
91 | } |
92 | |
92 | |
93 | #ifdef XPM_BACKGROUND |
93 | # ifdef XPM_BACKGROUND |
94 | static inline bool |
94 | static inline bool |
95 | check_set_scale_value (int geom_flags, int flag, unsigned int &scale, unsigned int new_value) |
95 | check_set_scale_value (int geom_flags, int flag, unsigned int &scale, unsigned int new_value) |
96 | { |
96 | { |
97 | if (geom_flags & flag) |
97 | if (geom_flags & flag) |
98 | { |
98 | { |
… | |
… | |
168 | int x = 0, y = 0; |
168 | int x = 0, y = 0; |
169 | unsigned int w = 0, h = 0; |
169 | unsigned int w = 0, h = 0; |
170 | unsigned int n; |
170 | unsigned int n; |
171 | unsigned long new_flags = (flags&(~bgPmap_geometryFlags)); |
171 | unsigned long new_flags = (flags&(~bgPmap_geometryFlags)); |
172 | char *p; |
172 | char *p; |
173 | #define MAXLEN_GEOM 256 /* could be longer then regular geometry string */ |
173 | # define MAXLEN_GEOM 256 /* could be longer then regular geometry string */ |
174 | |
174 | |
175 | if (geom == NULL) |
175 | if (geom == NULL) |
176 | return false; |
176 | return false; |
177 | |
177 | |
178 | char str[MAXLEN_GEOM]; |
178 | char str[MAXLEN_GEOM]; |
179 | |
179 | |
180 | if (!strcmp (geom, "?")) |
180 | if (!strcmp (geom, "?")) |
181 | { |
181 | { |
182 | #if 0 /* TODO: */ |
182 | if (target) |
|
|
183 | { |
183 | sprintf (str, "[%dx%d+%d+%d]", /* can't presume snprintf () ! */ |
184 | sprintf (str, "[%dx%d+%d+%d]", /* can't presume snprintf () ! */ |
184 | min (h_scale, 32767), min (v_scale, 32767), |
185 | min (h_scale, 32767), min (v_scale, 32767), |
185 | min (h_align, 32767), min (v_align, 32767)); |
186 | min (h_align, 32767), min (v_align, 32767)); |
186 | process_xterm_seq (XTerm_title, str, CHAR_ST); |
187 | target->process_xterm_seq (XTerm_title, str, CHAR_ST); |
187 | #endif |
188 | } |
188 | return false; |
189 | return false; |
189 | } |
190 | } |
190 | while (isspace(*geom)) ++geom; |
191 | while (isspace(*geom)) ++geom; |
191 | if ((p = strchr (geom, ';')) == NULL) |
192 | if ((p = strchr (geom, ';')) == NULL) |
192 | p = strchr (geom, '\0'); |
193 | p = strchr (geom, '\0'); |
… | |
… | |
284 | if (ops) |
285 | if (ops) |
285 | { |
286 | { |
286 | while (*ops) |
287 | while (*ops) |
287 | { |
288 | { |
288 | while (*ops == ':' || isspace(*ops)) ++ops; |
289 | while (*ops == ':' || isspace(*ops)) ++ops; |
289 | #define CHECK_GEOM_OPS(op_str) (strncasecmp (ops, (op_str), sizeof(op_str)-1) == 0) |
290 | # define CHECK_GEOM_OPS(op_str) (strncasecmp (ops, (op_str), sizeof(op_str)-1) == 0) |
290 | if (CHECK_GEOM_OPS("tile")) |
291 | if (CHECK_GEOM_OPS("tile")) |
291 | { |
292 | { |
292 | w = h = 0; |
293 | w = h = 0; |
293 | geom_flags |= WidthValue|HeightValue; |
294 | geom_flags |= WidthValue|HeightValue; |
294 | } |
295 | } |
… | |
… | |
327 | { |
328 | { |
328 | w = h = 100; |
329 | w = h = 100; |
329 | x = y = 50; |
330 | x = y = 50; |
330 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
331 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
331 | } |
332 | } |
332 | #undef CHECK_GEOM_OPS |
333 | # undef CHECK_GEOM_OPS |
333 | while (*ops != ':' && *ops != '\0') ++ops; |
334 | while (*ops != ':' && *ops != '\0') ++ops; |
334 | } /* done parsing ops */ |
335 | } /* done parsing ops */ |
335 | } |
336 | } |
336 | |
337 | |
337 | if (check_set_scale_value (geom_flags, WidthValue, h_scale, w)) |
338 | if (check_set_scale_value (geom_flags, WidthValue, h_scale, w)) |
… | |
… | |
352 | //fprintf( stderr, "flags = %lX, scale = %ux%u, align=%+d%+d\n", |
353 | //fprintf( stderr, "flags = %lX, scale = %ux%u, align=%+d%+d\n", |
353 | // flags, h_scale, v_scale, h_align, v_align); |
354 | // flags, h_scale, v_scale, h_align, v_align); |
354 | return (changed > 0); |
355 | return (changed > 0); |
355 | } |
356 | } |
356 | |
357 | |
357 | #ifdef HAVE_AFTERIMAGE |
358 | # ifdef HAVE_AFTERIMAGE |
358 | bool |
359 | bool |
359 | bgPixmap_t::render_asim (rxvt_term *target, ASImage *background, ARGB32 background_tint) |
360 | bgPixmap_t::render_asim (ASImage *background, ARGB32 background_tint) |
360 | { |
361 | { |
361 | if (target == NULL) |
362 | if (target == NULL) |
362 | return false; |
363 | return false; |
363 | |
364 | |
364 | int target_width = (int)target->szHint.width; |
365 | int target_width = (int)target->szHint.width; |
… | |
… | |
536 | asimage2drawable (target->asv, pixmap, result, gc, src_x, src_y, dst_x, dst_y, dst_width, dst_height, True); |
537 | asimage2drawable (target->asv, pixmap, result, gc, src_x, src_y, dst_x, dst_y, dst_width, dst_height, True); |
537 | |
538 | |
538 | if (result != background && result != original_asim) |
539 | if (result != background && result != original_asim) |
539 | destroy_asimage (&result); |
540 | destroy_asimage (&result); |
540 | |
541 | |
541 | /* set target's background to pixmap */ |
|
|
542 | XSetWindowBackgroundPixmap (target->dpy, target->vt, pixmap); |
|
|
543 | |
|
|
544 | XFreeGC (target->dpy, gc); |
542 | XFreeGC (target->dpy, gc); |
545 | } |
543 | if (background) |
|
|
544 | flags |= bgPmap_Transparent; |
546 | else |
545 | else |
547 | { |
546 | flags &= ~bgPmap_Transparent; |
548 | /* set target background to a pixel */ |
|
|
549 | XSetWindowBackground (target->dpy, target->vt, target->pix_colors[Color_bg]); |
|
|
550 | } |
547 | } |
551 | |
548 | |
552 | return true; |
549 | return true; |
553 | } |
550 | } |
554 | #endif |
551 | # endif /* HAVE_AFTERIMAGE */ |
555 | |
552 | |
556 | void |
553 | void |
557 | rxvt_term::resize_pixmap () |
554 | rxvt_term::resize_pixmap () |
558 | { |
555 | { |
559 | |
556 | |
560 | #ifdef ENABLE_TRANSPARENCY |
557 | # ifdef ENABLE_TRANSPARENCY |
561 | if (option(Opt_transparent) && am_transparent) |
558 | if (option(Opt_transparent) && am_transparent) |
562 | { |
559 | { |
563 | /* we need to re-generate transparency pixmap in that case ! */ |
560 | /* we need to re-generate transparency pixmap in that case ! */ |
564 | check_our_parents (); |
561 | check_our_parents (); |
565 | return; |
562 | return; |
566 | } |
563 | } |
567 | #endif |
564 | # endif |
568 | #ifdef HAVE_AFTERIMAGE |
565 | # ifdef HAVE_AFTERIMAGE |
569 | bgPixmap.render_asim(this, NULL, TINT_LEAVE_SAME); |
566 | bgPixmap.render_asim(NULL, TINT_LEAVE_SAME); |
|
|
567 | bgPixmap.apply_background(); |
570 | #endif |
568 | # endif |
571 | } |
569 | } |
572 | |
570 | |
573 | void |
571 | void |
574 | rxvt_term::set_bgPixmap (const char *file) |
572 | rxvt_term::set_bgPixmap (const char *file) |
575 | { |
573 | { |
… | |
… | |
584 | } |
582 | } |
585 | |
583 | |
586 | XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); |
584 | XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); |
587 | if (*file != '\0') |
585 | if (*file != '\0') |
588 | { |
586 | { |
589 | #ifdef HAVE_AFTERIMAGE |
587 | # ifdef HAVE_AFTERIMAGE |
590 | if (asimman == NULL) |
588 | if (asimman == NULL) |
591 | asimman = create_generic_imageman(rs[Rs_path]); |
589 | asimman = create_generic_imageman(rs[Rs_path]); |
592 | if ((f = strchr (file, ';')) == NULL) |
590 | if ((f = strchr (file, ';')) == NULL) |
593 | bgPixmap.original_asim = get_asimage( asimman, file, 0xFFFFFFFF, 100 ); |
591 | bgPixmap.original_asim = get_asimage( asimman, file, 0xFFFFFFFF, 100 ); |
594 | else |
592 | else |
… | |
… | |
598 | strncpy (f, file, len); |
596 | strncpy (f, file, len); |
599 | f[len] = '\0'; |
597 | f[len] = '\0'; |
600 | bgPixmap.original_asim = get_asimage( asimman, f, 0xFFFFFFFF, 100 ); |
598 | bgPixmap.original_asim = get_asimage( asimman, f, 0xFFFFFFFF, 100 ); |
601 | free( f ); |
599 | free( f ); |
602 | } |
600 | } |
603 | #endif |
601 | # endif |
604 | } |
602 | } |
605 | resize_pixmap (); /* TODO: temporary fix - should be done by the caller! */ |
603 | resize_pixmap (); /* TODO: temporary fix - should be done by the caller! */ |
606 | } |
604 | } |
607 | |
605 | |
608 | #endif /* XPM_BACKGROUND */ |
606 | # endif /* XPM_BACKGROUND */ |
|
|
607 | |
|
|
608 | # ifdef ENABLE_TRANSPARENCY |
|
|
609 | /* make_transparency_pixmap() |
|
|
610 | * Builds a pixmap sized the same as terminal window, with depth same as the root window |
|
|
611 | * that pixmap contains tiled portion of the root pixmap that is supposed to be covered by |
|
|
612 | * our window. |
|
|
613 | */ |
|
|
614 | #if 0 |
|
|
615 | bool |
|
|
616 | bgPixmap_t::make_transparency_pixmap() |
|
|
617 | { |
|
|
618 | if (target == NULL) |
|
|
619 | return false; |
|
|
620 | |
|
|
621 | int sx, sy; |
|
|
622 | Window cr; |
|
|
623 | XTranslateCoordinates (target->dpy, target->parent[0], target->display->root, |
|
|
624 | 0, 0, &sx, &sy, &cr); |
|
|
625 | |
|
|
626 | /* check if we are outside of the visible part of the virtual screen : */ |
|
|
627 | if( sx + (int)szHint.width <= 0 || sy + (int)szHint.height <= 0 |
|
|
628 | || sx >= wrootattr.width || sy >= wrootattr.height ) |
|
|
629 | return false ; |
|
|
630 | |
|
|
631 | XWindowAttributes wattr, wrootattr; |
|
|
632 | |
|
|
633 | XGetWindowAttributes (dpy, display->root, &wrootattr); |
|
|
634 | |
|
|
635 | /* |
|
|
636 | * Make the frame window set by the window manager have |
|
|
637 | * the root background. Some window managers put multiple nested frame |
|
|
638 | * windows for each client, so we have to take care about that. |
|
|
639 | */ |
|
|
640 | i = (xa[XA_XROOTPMAP_ID] |
|
|
641 | && XGetWindowProperty (dpy, display->root, xa[XA_XROOTPMAP_ID], |
|
|
642 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
|
|
643 | &nitems, &bytes_after, &prop) == Success); |
|
|
644 | |
|
|
645 | if (!i || prop == NULL) |
|
|
646 | i = (xa[XA_ESETROOT_PMAP_ID] |
|
|
647 | && XGetWindowProperty (dpy, display->root, xa[XA_ESETROOT_PMAP_ID], |
|
|
648 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
|
|
649 | &nitems, &bytes_after, &prop) == Success); |
|
|
650 | |
|
|
651 | if (!i || prop == NULL) |
|
|
652 | rootpixmap = None; |
|
|
653 | |
|
|
654 | } |
|
|
655 | #endif /* 0 */ |
|
|
656 | # endif /* ENABLE_TRANSPARENCY */ |
|
|
657 | |
|
|
658 | void |
|
|
659 | bgPixmap_t::apply_background() |
|
|
660 | { |
|
|
661 | if (target) |
|
|
662 | { |
|
|
663 | if (pixmap != None) |
|
|
664 | { /* set target's background to pixmap */ |
|
|
665 | # ifdef ENABLE_TRANSPARENCY |
|
|
666 | if (flags & bgPmap_Transparent) |
|
|
667 | { |
|
|
668 | XSetWindowBackgroundPixmap (target->dpy, target->parent[0], pixmap); |
|
|
669 | XSetWindowBackgroundPixmap (target->dpy, target->vt, ParentRelative); |
|
|
670 | if (target->scrollBar.win) |
|
|
671 | XSetWindowBackgroundPixmap (target->dpy, target->scrollBar.win, ParentRelative); |
|
|
672 | } |
|
|
673 | else |
|
|
674 | # endif |
|
|
675 | { |
|
|
676 | /* force old pixmap dereference in case it was transparent before :*/ |
|
|
677 | XSetWindowBackground (target->dpy, target->parent[0], target->pix_colors[Color_bg]); |
|
|
678 | XSetWindowBackgroundPixmap (target->dpy, target->vt, pixmap); |
|
|
679 | /* do we also need to set scrollbar's background here ? */ |
|
|
680 | } |
|
|
681 | } |
|
|
682 | else |
|
|
683 | { /* set target background to a pixel */ |
|
|
684 | XSetWindowBackground (target->dpy, target->parent[0], target->pix_colors[Color_bg]); |
|
|
685 | XSetWindowBackground (target->dpy, target->vt, target->pix_colors[Color_bg]); |
|
|
686 | /* do we also need to set scrollbar's background here ? */ |
|
|
687 | } |
|
|
688 | /* don't want Expose on the parent */ |
|
|
689 | XClearArea (target->dpy, target->parent[0], 0, 0, 0, 0, False); |
|
|
690 | /* do want Expose on the vt */ |
|
|
691 | XClearArea (target->dpy, target->parent[0], 0, 0, 0, 0, True); |
|
|
692 | } |
|
|
693 | } |
609 | #endif /* HAVE_BG_PIXMAP */ |
694 | #endif /* HAVE_BG_PIXMAP */ |
|
|
695 | |
|
|
696 | |
610 | |
697 | |
611 | #ifdef ENABLE_TRANSPARENCY |
698 | #ifdef ENABLE_TRANSPARENCY |
612 | #ifndef HAVE_AFTERIMAGE |
699 | #ifndef HAVE_AFTERIMAGE |
613 | /* taken from aterm-0.4.2 */ |
700 | /* taken from aterm-0.4.2 */ |
614 | |
701 | |
… | |
… | |
854 | } |
941 | } |
855 | |
942 | |
856 | void |
943 | void |
857 | rxvt_term::check_our_parents_cb (time_watcher &w) |
944 | rxvt_term::check_our_parents_cb (time_watcher &w) |
858 | { |
945 | { |
859 | int i, pchanged, aformat, rootdepth; |
946 | int i, aformat, rootdepth; |
860 | unsigned long nitems, bytes_after; |
947 | unsigned long nitems, bytes_after; |
861 | Atom atype; |
948 | Atom atype; |
862 | unsigned char *prop = NULL; |
949 | unsigned char *prop = NULL; |
863 | Window root, oldp, *list; |
950 | Window root, oldp, *list; |
864 | Pixmap rootpixmap = None; |
951 | Pixmap rootpixmap = None; |
865 | XWindowAttributes wattr, wrootattr; |
952 | XWindowAttributes wattr, wrootattr; |
866 | int sx, sy; |
953 | int sx, sy; |
867 | Window cr; |
954 | Window cr; |
868 | unsigned int rootpixmap_w = 0, rootpixmap_h = 0; |
955 | unsigned int rootpixmap_w = 0, rootpixmap_h = 0; |
869 | |
956 | |
870 | pchanged = 0; |
|
|
871 | |
|
|
872 | if (!option (Opt_transparent)) |
957 | if (!option (Opt_transparent)) |
873 | return /*pchanged*/; /* Don't try any more */ |
958 | return; /* Don't try any more */ |
874 | |
959 | |
875 | #if 0 |
960 | #if 0 |
876 | struct timeval stv; |
961 | struct timeval stv; |
877 | gettimeofday (&stv,NULL); |
962 | gettimeofday (&stv,NULL); |
878 | #define PRINT_BACKGROUND_OP_TIME do{ struct timeval tv;gettimeofday (&tv,NULL); tv.tv_sec-= stv.tv_sec;\ |
963 | #define PRINT_BACKGROUND_OP_TIME do{ struct timeval tv;gettimeofday (&tv,NULL); tv.tv_sec-= stv.tv_sec;\ |
… | |
… | |
890 | |
975 | |
891 | if (rootdepth != wattr.depth) |
976 | if (rootdepth != wattr.depth) |
892 | { |
977 | { |
893 | if (am_transparent) |
978 | if (am_transparent) |
894 | { |
979 | { |
895 | pchanged = 1; |
|
|
896 | XSetWindowBackground (dpy, vt, pix_colors_focused[Color_bg]); |
980 | XSetWindowBackground (dpy, vt, pix_colors_focused[Color_bg]); |
897 | am_transparent = am_pixmap_trans = 0; |
981 | am_transparent = am_pixmap_trans = 0; |
898 | } |
982 | } |
899 | |
983 | |
900 | return /*pchanged*/; /* Don't try any more */ |
984 | return; /* Don't try any more */ |
901 | } |
985 | } |
902 | |
986 | |
903 | /* Get all X ops out of the queue so that our information is up-to-date. */ |
987 | /* Get all X ops out of the queue so that our information is up-to-date. */ |
904 | XSync (dpy, False); |
988 | XSync (dpy, False); |
905 | |
989 | |
… | |
… | |
1039 | back_im = tmp; |
1123 | back_im = tmp; |
1040 | } |
1124 | } |
1041 | } |
1125 | } |
1042 | /* TODO: temporary fix - redo the logic, so that same function can do both |
1126 | /* TODO: temporary fix - redo the logic, so that same function can do both |
1043 | transparency and non-transparency */ |
1127 | transparency and non-transparency */ |
1044 | bgPixmap.render_asim (this, back_im, tint); |
1128 | bgPixmap.render_asim (back_im, tint); |
1045 | destroy_asimage (&back_im); |
1129 | destroy_asimage (&back_im); |
1046 | |
1130 | |
1047 | } /* back_im != NULL */ |
1131 | } /* back_im != NULL */ |
1048 | else |
1132 | else |
1049 | success = False; |
1133 | success = False; |
… | |
… | |
1068 | #endif /* HAVE_AFTERIMAGE */ |
1152 | #endif /* HAVE_AFTERIMAGE */ |
1069 | PRINT_BACKGROUND_OP_TIME; |
1153 | PRINT_BACKGROUND_OP_TIME; |
1070 | |
1154 | |
1071 | if (gc != NULL) |
1155 | if (gc != NULL) |
1072 | XFreeGC (dpy, gc); |
1156 | XFreeGC (dpy, gc); |
1073 | |
1157 | |
|
|
1158 | bgPixmap.apply_background(); |
1074 | if (!success) |
1159 | if (!success) |
1075 | { |
|
|
1076 | if (am_transparent && am_pixmap_trans) |
|
|
1077 | { |
|
|
1078 | pchanged = 1; |
|
|
1079 | if (bgPixmap.pixmap != None) |
|
|
1080 | { |
|
|
1081 | XFreePixmap (dpy, bgPixmap.pixmap); |
|
|
1082 | bgPixmap.pixmap = None; |
|
|
1083 | } |
|
|
1084 | } |
|
|
1085 | |
|
|
1086 | am_pixmap_trans = 0; |
1160 | am_pixmap_trans = 0; |
1087 | } |
|
|
1088 | else |
1161 | else |
1089 | { |
1162 | { |
1090 | XSetWindowBackgroundPixmap (dpy, parent[0], bgPixmap.pixmap); |
|
|
1091 | XClearWindow (dpy, parent[0]); |
|
|
1092 | |
|
|
1093 | if (!am_transparent || !am_pixmap_trans) |
|
|
1094 | pchanged = 1; |
|
|
1095 | |
|
|
1096 | am_transparent = am_pixmap_trans = 1; |
1163 | am_transparent = am_pixmap_trans = 1; |
1097 | } |
1164 | } |
1098 | } /* rootpixmap != None */ |
1165 | } /* rootpixmap != None */ |
1099 | |
1166 | |
1100 | if (am_pixmap_trans) |
1167 | if (am_pixmap_trans) |
1101 | XSetWindowBackgroundPixmap (dpy, vt, ParentRelative); |
1168 | { |
1102 | else |
|
|
1103 | return; |
|
|
1104 | |
|
|
1105 | if (scrollBar.win) |
1169 | if (scrollBar.win) |
1106 | { |
1170 | { |
1107 | XSetWindowBackgroundPixmap (dpy, scrollBar.win, ParentRelative); |
|
|
1108 | scrollBar.setIdle (); |
1171 | scrollBar.setIdle (); |
1109 | scrollbar_show (0); |
1172 | scrollbar_show (0); |
1110 | } |
1173 | } |
1111 | |
1174 | |
1112 | if (am_transparent) |
1175 | if (am_transparent) |
1113 | { |
1176 | { |
1114 | want_refresh = want_full_refresh = 1; |
1177 | want_refresh = want_full_refresh = 1; |
1115 | if (am_pixmap_trans) |
1178 | if (am_pixmap_trans) |
1116 | flush (); |
1179 | flush (); |
|
|
1180 | } |
1117 | } |
1181 | } |
1118 | |
|
|
1119 | // return pchanged; |
|
|
1120 | } |
1182 | } |
1121 | #endif |
1183 | #endif |