… | |
… | |
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 & isTransparent) |
88 | return true; |
88 | return true; |
89 | # endif |
89 | # endif |
90 | return false; |
90 | return false; |
91 | } |
91 | } |
92 | |
92 | |
… | |
… | |
160 | dst_size = target_size - dst_pos; |
160 | dst_size = target_size - dst_pos; |
161 | return src_pos; |
161 | return src_pos; |
162 | } |
162 | } |
163 | |
163 | |
164 | bool |
164 | bool |
165 | bgPixmap_t::handle_geometry (const char *geom) |
165 | bgPixmap_t::set_geometry (const char *geom) |
166 | { |
166 | { |
167 | int geom_flags = 0, changed = 0; |
167 | int geom_flags = 0, changed = 0; |
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 & (~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, "?")) |
|
|
181 | { |
|
|
182 | if (target) |
|
|
183 | { |
|
|
184 | sprintf (str, "[%dx%d+%d+%d]", /* can't presume snprintf () ! */ |
|
|
185 | min (h_scale, 32767), min (v_scale, 32767), |
|
|
186 | min (h_align, 32767), min (v_align, 32767)); |
|
|
187 | target->process_xterm_seq (XTerm_title, str, CHAR_ST); |
|
|
188 | } |
|
|
189 | return false; |
|
|
190 | } |
|
|
191 | while (isspace(*geom)) ++geom; |
180 | while (isspace(*geom)) ++geom; |
192 | if ((p = strchr (geom, ';')) == NULL) |
181 | if ((p = strchr (geom, ';')) == NULL) |
193 | p = strchr (geom, '\0'); |
182 | p = strchr (geom, '\0'); |
194 | |
183 | |
195 | n = (p - geom); |
184 | n = (p - geom); |
196 | if (n < MAXLEN_GEOM) |
185 | if (n < MAXLEN_GEOM) |
197 | { |
186 | { |
198 | char *ops; |
187 | char *ops; |
199 | new_flags |= bgPmap_geometrySet; |
188 | new_flags |= geometrySet; |
200 | |
189 | |
201 | strncpy (str, geom, n); |
190 | strncpy (str, geom, n); |
202 | str[n] = '\0'; |
191 | str[n] = '\0'; |
203 | if (str[0] == ':') |
192 | if (str[0] == ':') |
204 | ops = &str[0]; |
193 | ops = &str[0]; |
… | |
… | |
225 | { |
214 | { |
226 | y = x; |
215 | y = x; |
227 | geom_flags |= YValue; |
216 | geom_flags |= YValue; |
228 | } |
217 | } |
229 | |
218 | |
230 | if (flags & bgPmap_geometrySet) |
219 | if (flags & geometrySet) |
231 | {/* new geometry is an adjustment to the old one ! */ |
220 | {/* new geometry is an adjustment to the old one ! */ |
232 | if ((geom_flags & WidthValue) && (geom_flags & HeightValue)) |
221 | if ((geom_flags & WidthValue) && (geom_flags & HeightValue)) |
233 | { |
222 | { |
234 | if (w == 0 && h != 0) |
223 | if (w == 0 && h != 0) |
235 | { |
224 | { |
… | |
… | |
253 | } |
242 | } |
254 | else /* setting up geometry from scratch */ |
243 | else /* setting up geometry from scratch */ |
255 | { |
244 | { |
256 | if (!(geom_flags & XValue)) |
245 | if (!(geom_flags & XValue)) |
257 | {/* use default geometry - centered */ |
246 | {/* use default geometry - centered */ |
258 | x = y = bgPmap_defaultAlign; |
247 | x = y = defaultAlign; |
259 | } |
248 | } |
260 | else if (!(geom_flags & YValue)) |
249 | else if (!(geom_flags & YValue)) |
261 | y = x; |
250 | y = x; |
262 | |
251 | |
263 | if ((geom_flags & (WidthValue|HeightValue)) == 0) |
252 | if ((geom_flags & (WidthValue|HeightValue)) == 0) |
264 | {/* use default geometry - scaled */ |
253 | {/* use default geometry - scaled */ |
265 | w = h = bgPmap_defaultScale; |
254 | w = h = defaultScale; |
266 | } |
255 | } |
267 | else if (geom_flags & WidthValue) |
256 | else if (geom_flags & WidthValue) |
268 | { |
257 | { |
269 | if (!(geom_flags & HeightValue)) |
258 | if (!(geom_flags & HeightValue)) |
270 | h = w; |
259 | h = w; |
271 | } |
260 | } |
272 | else |
261 | else |
273 | w = h; |
262 | w = h; |
274 | } |
263 | } |
275 | } /* done parsing geometry string */ |
264 | } /* done parsing geometry string */ |
276 | else if (!(flags & bgPmap_geometrySet)) |
265 | else if (!(flags & geometrySet)) |
277 | { /* default geometry - scaled and centered */ |
266 | { /* default geometry - scaled and centered */ |
278 | x = y = bgPmap_defaultAlign; |
267 | x = y = defaultAlign; |
279 | w = h = bgPmap_defaultScale; |
268 | w = h = defaultScale; |
280 | } |
269 | } |
281 | |
270 | |
282 | if (!(flags & bgPmap_geometrySet)) |
271 | if (!(flags & geometrySet)) |
283 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
272 | geom_flags |= WidthValue|HeightValue|XValue|YValue; |
284 | |
273 | |
285 | if (ops) |
274 | if (ops) |
286 | { |
275 | { |
287 | while (*ops) |
276 | while (*ops) |
… | |
… | |
298 | if (w == 0 && h == 0) |
287 | if (w == 0 && h == 0) |
299 | { |
288 | { |
300 | w = 100; |
289 | w = 100; |
301 | geom_flags |= WidthValue; |
290 | geom_flags |= WidthValue; |
302 | } |
291 | } |
303 | new_flags |= bgPmap_propScale; |
292 | new_flags |= propScale; |
304 | } |
293 | } |
305 | else if (CHECK_GEOM_OPS("hscale")) |
294 | else if (CHECK_GEOM_OPS("hscale")) |
306 | { |
295 | { |
307 | if (w == 0) |
296 | if (w == 0) |
308 | w = 100; |
297 | w = 100; |
… | |
… | |
538 | |
527 | |
539 | if (result != background && result != original_asim) |
528 | if (result != background && result != original_asim) |
540 | destroy_asimage (&result); |
529 | destroy_asimage (&result); |
541 | |
530 | |
542 | XFreeGC (target->dpy, gc); |
531 | XFreeGC (target->dpy, gc); |
543 | if (background) |
|
|
544 | flags |= bgPmap_Transparent; |
|
|
545 | else |
|
|
546 | flags &= ~bgPmap_Transparent; |
|
|
547 | } |
532 | } |
548 | |
533 | |
549 | return true; |
534 | return true; |
550 | } |
535 | } |
551 | # endif /* HAVE_AFTERIMAGE */ |
536 | # endif /* HAVE_AFTERIMAGE */ |
552 | |
537 | |
553 | void |
538 | bool |
554 | rxvt_term::resize_pixmap () |
539 | bgPixmap_t::set_file (const char *file) |
555 | { |
540 | { |
|
|
541 | char *f; |
556 | |
542 | |
557 | # ifdef ENABLE_TRANSPARENCY |
543 | assert (file != NULL); |
558 | if (option(Opt_transparent) && am_transparent) |
544 | |
559 | { |
545 | if (*file != '\0') |
560 | /* we need to re-generate transparency pixmap in that case ! */ |
|
|
561 | check_our_parents (); |
|
|
562 | return; |
|
|
563 | } |
546 | { |
564 | # endif |
|
|
565 | # ifdef HAVE_AFTERIMAGE |
547 | # ifdef HAVE_AFTERIMAGE |
566 | bgPixmap.render_asim(NULL, TINT_LEAVE_SAME); |
|
|
567 | bgPixmap.apply_background(); |
|
|
568 | # endif |
|
|
569 | } |
|
|
570 | |
|
|
571 | void |
|
|
572 | rxvt_term::set_bgPixmap (const char *file) |
|
|
573 | { |
|
|
574 | char *f; |
|
|
575 | |
|
|
576 | assert (file != NULL); |
|
|
577 | |
|
|
578 | if (bgPixmap.pixmap != None) |
|
|
579 | { |
|
|
580 | XFreePixmap (dpy, bgPixmap.pixmap); |
|
|
581 | bgPixmap.pixmap = None; |
|
|
582 | } |
|
|
583 | |
|
|
584 | XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); |
|
|
585 | if (*file != '\0') |
|
|
586 | { |
|
|
587 | # ifdef HAVE_AFTERIMAGE |
|
|
588 | if (asimman == NULL) |
548 | if (target->asimman == NULL) |
589 | asimman = create_generic_imageman(rs[Rs_path]); |
549 | target->asimman = create_generic_imageman(target->rs[Rs_path]); |
590 | if ((f = strchr (file, ';')) == NULL) |
550 | if ((f = strchr (file, ';')) == NULL) |
591 | bgPixmap.original_asim = get_asimage( asimman, file, 0xFFFFFFFF, 100 ); |
551 | original_asim = get_asimage( target->asimman, file, 0xFFFFFFFF, 100 ); |
592 | else |
552 | else |
593 | { |
553 | { |
594 | size_t len = f - file; |
554 | size_t len = f - file; |
595 | f = (char *)malloc (len + 1); |
555 | f = (char *)malloc (len + 1); |
596 | strncpy (f, file, len); |
556 | strncpy (f, file, len); |
597 | f[len] = '\0'; |
557 | f[len] = '\0'; |
598 | bgPixmap.original_asim = get_asimage( asimman, f, 0xFFFFFFFF, 100 ); |
558 | original_asim = get_asimage( target->asimman, f, 0xFFFFFFFF, 100 ); |
599 | free( f ); |
559 | free( f ); |
600 | } |
560 | } |
|
|
561 | return (original_asim != NULL); |
601 | # endif |
562 | # endif |
602 | } |
563 | } |
603 | resize_pixmap (); /* TODO: temporary fix - should be done by the caller! */ |
564 | return false; |
604 | } |
565 | } |
605 | |
566 | |
606 | # endif /* XPM_BACKGROUND */ |
567 | # endif /* XPM_BACKGROUND */ |
607 | |
568 | |
608 | # ifdef ENABLE_TRANSPARENCY |
569 | # ifdef ENABLE_TRANSPARENCY |
|
|
570 | bool |
|
|
571 | bgPixmap_t::set_transparent () |
|
|
572 | { |
|
|
573 | if (!(flags & isTransparent)) |
|
|
574 | { |
|
|
575 | flags |= isTransparent; |
|
|
576 | return true; |
|
|
577 | } |
|
|
578 | } |
|
|
579 | |
|
|
580 | bool |
|
|
581 | bgPixmap_t::set_blur_radius (const char *geom) |
|
|
582 | { |
|
|
583 | int changed = 0; |
|
|
584 | unsigned int hr, vr; |
|
|
585 | int junk; |
|
|
586 | int geom_flags = XParseGeometry (geom, &junk, &junk, &hr, &vr); |
|
|
587 | if (!(geom_flags&WidthValue)) |
|
|
588 | hr = 1; |
|
|
589 | if (!(geom_flags&HeightValue)) |
|
|
590 | vr = hr; |
|
|
591 | |
|
|
592 | if (h_blurRadius != hr) |
|
|
593 | { |
|
|
594 | ++changed; |
|
|
595 | h_blurRadius = hr; |
|
|
596 | } |
|
|
597 | if (v_blurRadius != vr) |
|
|
598 | { |
|
|
599 | ++changed; |
|
|
600 | v_blurRadius = vr; |
|
|
601 | } |
|
|
602 | return (changed>0); |
|
|
603 | } |
|
|
604 | |
|
|
605 | static inline unsigned long |
|
|
606 | compute_tint_shade_flags (rxvt_color *tint, int shade) |
|
|
607 | { |
|
|
608 | unsigned long flags = 0; |
|
|
609 | |
|
|
610 | if (shade > 0 && shade <100) |
|
|
611 | flags |= bgPixmap_t::tintNeeded; |
|
|
612 | else if (tint) |
|
|
613 | { |
|
|
614 | rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); |
|
|
615 | tint->get (c); |
|
|
616 | |
|
|
617 | flags |= bgPixmap_t::tintNeeded; |
|
|
618 | if ((c.r > 0x000700 || c.g > 0x000700 || c.b > 0x000700) |
|
|
619 | && (c.r < 0x00f700 || c.g < 0x00f700 || c.b < 0x00f700)) |
|
|
620 | { |
|
|
621 | flags |= bgPixmap_t::tintNeeded; |
|
|
622 | #define IS_COMPONENT_WHOLESOME(cmp) ((cmp) <= 0x000700 || (cmp) >= 0x00f700) |
|
|
623 | if (IS_COMPONENT_WHOLESOME (c.r) |
|
|
624 | && IS_COMPONENT_WHOLESOME (c.g) |
|
|
625 | && IS_COMPONENT_WHOLESOME (c.b)) |
|
|
626 | flags |= bgPixmap_t::tintServerSide; |
|
|
627 | #undef IS_COMPONENT_WHOLESOME |
|
|
628 | } |
|
|
629 | } |
|
|
630 | return flags; |
|
|
631 | } |
|
|
632 | |
|
|
633 | bool |
|
|
634 | bgPixmap_t::set_tint (rxvt_color &new_tint) |
|
|
635 | { |
|
|
636 | if (tint != new_tint) |
|
|
637 | { |
|
|
638 | unsigned long new_flags = compute_tint_shade_flags (&new_tint, shade); |
|
|
639 | tint = new_tint; |
|
|
640 | flags = (flags & ~tintFlags) | new_flags | tintSet; |
|
|
641 | return true; |
|
|
642 | } |
|
|
643 | return false; |
|
|
644 | } |
|
|
645 | |
|
|
646 | bool |
|
|
647 | bgPixmap_t::unset_tint () |
|
|
648 | { |
|
|
649 | unsigned long new_flags = compute_tint_shade_flags (NULL, shade); |
|
|
650 | |
|
|
651 | if (new_flags != (flags & tintFlags)) |
|
|
652 | { |
|
|
653 | flags = (flags&~tintFlags)|new_flags; |
|
|
654 | return true; |
|
|
655 | } |
|
|
656 | return false; |
|
|
657 | } |
|
|
658 | |
|
|
659 | bool |
|
|
660 | bgPixmap_t::set_shade (const char *shade_str) |
|
|
661 | { |
|
|
662 | int new_shade = (shade_str) ? atoi (shade_str) : 0; |
|
|
663 | |
|
|
664 | if (new_shade == 100) |
|
|
665 | new_shade = 0; |
|
|
666 | |
|
|
667 | if (new_shade != shade) |
|
|
668 | { |
|
|
669 | unsigned long new_flags = compute_tint_shade_flags (&tint, new_shade); |
|
|
670 | shade = new_shade; |
|
|
671 | flags = (flags & ~tintFlags) | new_flags; |
|
|
672 | return true; |
|
|
673 | } |
|
|
674 | return false; |
|
|
675 | } |
|
|
676 | |
|
|
677 | |
609 | /* make_transparency_pixmap() |
678 | /* make_transparency_pixmap() |
610 | * Builds a pixmap sized the same as terminal window, with depth same as the root window |
679 | * 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 |
680 | * that pixmap contains tiled portion of the root pixmap that is supposed to be covered by |
612 | * our window. |
681 | * our window. |
613 | */ |
682 | */ |
614 | #if 0 |
|
|
615 | bool |
683 | bool |
616 | bgPixmap_t::make_transparency_pixmap() |
684 | bgPixmap_t::make_transparency_pixmap () |
617 | { |
685 | { |
618 | if (target == NULL) |
686 | if (target == NULL) |
619 | return false; |
687 | return false; |
620 | |
688 | |
|
|
689 | /* root dimentions may change from call to call - but Display structure should |
|
|
690 | * be always up-to-date, so let's use it : |
|
|
691 | */ |
|
|
692 | Window root = target->display->root; |
|
|
693 | int screen = target->display->screen; |
|
|
694 | Display *dpy = target->dpy; |
|
|
695 | int root_width = DisplayWidth (dpy, screen); |
|
|
696 | int root_height = DisplayHeight (dpy, screen); |
|
|
697 | unsigned int root_pmap_width, root_pmap_height; |
|
|
698 | int window_width = target->szHint.width; |
|
|
699 | int window_height = target->szHint.height; |
621 | int sx, sy; |
700 | int sx, sy; |
622 | Window cr; |
701 | XGCValues gcv; |
623 | XTranslateCoordinates (target->dpy, target->parent[0], target->display->root, |
|
|
624 | 0, 0, &sx, &sy, &cr); |
|
|
625 | |
702 | |
|
|
703 | target->get_window_origin (sx, sy); |
|
|
704 | |
626 | /* check if we are outside of the visible part of the virtual screen : */ |
705 | /* 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 |
706 | if (sx + window_width <= 0 || sy + window_height <= 0 |
628 | || sx >= wrootattr.width || sy >= wrootattr.height ) |
707 | || sx >= root_width || sy >= root_height) |
629 | return false ; |
708 | return false; |
|
|
709 | |
|
|
710 | if (root_pixmap != None) |
|
|
711 | {/* we want to validate the pixmap and get it's size at the same time : */ |
|
|
712 | int junk; |
|
|
713 | unsigned int ujunk; |
|
|
714 | /* root pixmap may be bad - allow a error */ |
|
|
715 | target->allowedxerror = -1; |
|
|
716 | if (!XGetGeometry (dpy, root_pixmap, &root, &junk, &junk, &root_pmap_width, &root_pmap_height, &ujunk, &ujunk)) |
|
|
717 | root_pixmap = None; |
|
|
718 | target->allowedxerror = 0; |
|
|
719 | } |
|
|
720 | |
|
|
721 | Pixmap tiled_root_pmap = XCreatePixmap (dpy, root, window_width, window_height, root_depth); |
|
|
722 | GC gc = NULL; |
|
|
723 | |
|
|
724 | if (tiled_root_pmap == None) /* something really bad happened - abort */ |
|
|
725 | return false; |
|
|
726 | |
|
|
727 | if (root_pixmap == None) |
|
|
728 | { /* use tricks to obtain the root background image :*/ |
|
|
729 | /* we want to create Overrideredirect window overlapping out window |
|
|
730 | with background type of Parent Relative and then grab it */ |
|
|
731 | XSetWindowAttributes attr; |
|
|
732 | Window src; |
|
|
733 | bool success = false; |
|
|
734 | |
|
|
735 | attr.background_pixmap = ParentRelative; |
|
|
736 | attr.backing_store = Always; |
|
|
737 | attr.event_mask = ExposureMask; |
|
|
738 | attr.override_redirect = True; |
|
|
739 | src = XCreateWindow (dpy, root, sx, sy, window_width, window_height, 0, |
|
|
740 | CopyFromParent, CopyFromParent, CopyFromParent, |
|
|
741 | CWBackPixmap|CWBackingStore|CWOverrideRedirect|CWEventMask, |
|
|
742 | &attr); |
|
|
743 | |
|
|
744 | if (src != None) |
|
|
745 | { |
|
|
746 | XEvent event; |
|
|
747 | int ev_count = 0; |
|
|
748 | XGrabServer (dpy); |
|
|
749 | XMapRaised (dpy, src); |
|
|
750 | XSync (dpy, False); |
|
|
751 | /* XSync should get window where it's properly exposed, |
|
|
752 | * but to be on the safe side - let's check for the actuall event to arrive : */ |
|
|
753 | while (XCheckWindowEvent (dpy, src, ExposureMask, &event)) |
|
|
754 | ++ev_count; |
|
|
755 | if (ev_count > 0); |
|
|
756 | { /* hooray! - we can grab the image! */ |
|
|
757 | gc = XCreateGC (dpy, root, 0, NULL); |
|
|
758 | XCopyArea (dpy, src, tiled_root_pmap, gc, 0, 0, window_width, window_height, 0, 0); |
|
|
759 | success = true; |
|
|
760 | } |
|
|
761 | XDestroyWindow (dpy, src); |
|
|
762 | XUngrabServer (dpy); |
|
|
763 | //fprintf (stderr, "%s:%d: ev_count = %d\n", __FUNCTION__, __LINE__, ev_count); |
|
|
764 | } |
|
|
765 | if (!success) |
|
|
766 | { |
|
|
767 | XFreePixmap (dpy, tiled_root_pmap); |
|
|
768 | tiled_root_pmap = None; |
|
|
769 | } |
|
|
770 | } |
|
|
771 | else |
|
|
772 | {/* strightforward pixmap copy */ |
|
|
773 | gcv.tile = root_pixmap; |
|
|
774 | gcv.fill_style = FillTiled; |
|
|
775 | while (sx < 0) sx += (int)window_width; |
|
|
776 | while (sy < 0) sy += (int)window_height; |
|
|
777 | gcv.ts_x_origin = -sx; |
|
|
778 | gcv.ts_y_origin = -sy; |
|
|
779 | gc = XCreateGC (dpy, root, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv); |
|
|
780 | XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height); |
|
|
781 | } |
|
|
782 | |
|
|
783 | if (tiled_root_pmap != None) |
|
|
784 | { |
|
|
785 | if (flags & tintNeeded) |
|
|
786 | { |
|
|
787 | if ((flags & tintServerSide) |
|
|
788 | && h_blurRadius <= 1 && v_blurRadius <= 1 |
|
|
789 | # ifdef HAVE_AFTERIMAGE |
|
|
790 | && original_asim == NULL |
|
|
791 | # endif |
|
|
792 | ) |
|
|
793 | { /* In this case we can tint image server-side getting significant |
|
|
794 | * performance improvements, as we eliminate XImage transfer |
|
|
795 | */ |
|
|
796 | gcv.foreground = Pixel (tint); |
|
|
797 | gcv.function = GXand; |
|
|
798 | gcv.fill_style = FillSolid; |
|
|
799 | if (gc) |
|
|
800 | XChangeGC (dpy, gc, GCFillStyle | GCForeground | GCFunction, &gcv); |
|
|
801 | else |
|
|
802 | gc = XCreateGC (dpy, root, GCFillStyle | GCForeground | GCFunction, &gcv); |
|
|
803 | XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height); |
|
|
804 | } |
|
|
805 | } |
|
|
806 | if (pixmap) |
|
|
807 | XFreePixmap (dpy, pixmap); |
|
|
808 | pixmap = tiled_root_pmap; |
|
|
809 | pmap_width = window_width; |
|
|
810 | pmap_height = window_height; |
|
|
811 | pmap_depth = root_depth; |
|
|
812 | } |
|
|
813 | |
|
|
814 | if (gc) |
|
|
815 | XFreeGC (dpy, gc); |
|
|
816 | } |
|
|
817 | |
|
|
818 | bool |
|
|
819 | bgPixmap_t::set_root_pixmap () |
|
|
820 | { |
|
|
821 | Pixmap new_root_pixmap = None; |
630 | |
822 | |
631 | XWindowAttributes wattr, wrootattr; |
823 | new_root_pixmap = target->get_pixmap_property (XA_XROOTPMAP_ID); |
|
|
824 | if (new_root_pixmap == None) |
|
|
825 | new_root_pixmap = target->get_pixmap_property (XA_ESETROOT_PMAP_ID); |
632 | |
826 | |
633 | XGetWindowAttributes (dpy, display->root, &wrootattr); |
827 | if (new_root_pixmap != root_pixmap) |
634 | |
828 | { |
635 | /* |
829 | root_pixmap = new_root_pixmap; |
636 | * Make the frame window set by the window manager have |
830 | return true; |
637 | * the root background. Some window managers put multiple nested frame |
831 | } |
638 | * windows for each client, so we have to take care about that. |
832 | return false; |
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 | } |
833 | } |
655 | #endif /* 0 */ |
|
|
656 | # endif /* ENABLE_TRANSPARENCY */ |
834 | # endif /* ENABLE_TRANSPARENCY */ |
|
|
835 | |
|
|
836 | bool |
|
|
837 | bgPixmap_t::render_background () |
|
|
838 | { |
|
|
839 | /* TODO: temporary implementation - need to move check_parents stuff in here */ |
|
|
840 | # ifdef ENABLE_TRANSPARENCY |
|
|
841 | if (flags & isTransparent) |
|
|
842 | { |
|
|
843 | /* we need to re-generate transparency pixmap in that case ! */ |
|
|
844 | target->check_our_parents (); |
|
|
845 | return true; |
|
|
846 | } |
|
|
847 | # endif |
|
|
848 | # ifdef HAVE_AFTERIMAGE |
|
|
849 | render_asim (NULL, TINT_LEAVE_SAME); |
|
|
850 | apply_background (); |
|
|
851 | return true; |
|
|
852 | # endif |
|
|
853 | return false; |
|
|
854 | } |
|
|
855 | |
|
|
856 | bool |
|
|
857 | bgPixmap_t::set_target (rxvt_term *new_target) |
|
|
858 | { |
|
|
859 | if (new_target) |
|
|
860 | if (target != new_target) |
|
|
861 | { |
|
|
862 | target = new_target; |
|
|
863 | # ifdef ENABLE_TRANSPARENCY |
|
|
864 | root_depth = DefaultDepthOfScreen (ScreenOfDisplay (target->dpy, target->display->screen)); |
|
|
865 | # endif |
|
|
866 | return true; |
|
|
867 | } |
|
|
868 | return false; |
|
|
869 | } |
657 | |
870 | |
658 | void |
871 | void |
659 | bgPixmap_t::apply_background() |
872 | bgPixmap_t::apply_background() |
660 | { |
873 | { |
661 | if (target) |
874 | if (target) |
662 | { |
875 | { |
663 | if (pixmap != None) |
876 | if (pixmap != None) |
664 | { /* set target's background to pixmap */ |
877 | { /* set target's background to pixmap */ |
665 | # ifdef ENABLE_TRANSPARENCY |
878 | # ifdef ENABLE_TRANSPARENCY |
666 | if (flags & bgPmap_Transparent) |
879 | if (flags & isTransparent) |
667 | { |
880 | { |
668 | XSetWindowBackgroundPixmap (target->dpy, target->parent[0], pixmap); |
881 | XSetWindowBackgroundPixmap (target->dpy, target->parent[0], pixmap); |
669 | XSetWindowBackgroundPixmap (target->dpy, target->vt, ParentRelative); |
882 | XSetWindowBackgroundPixmap (target->dpy, target->vt, ParentRelative); |
670 | if (target->scrollBar.win) |
883 | if (target->scrollBar.win) |
671 | XSetWindowBackgroundPixmap (target->dpy, target->scrollBar.win, ParentRelative); |
884 | XSetWindowBackgroundPixmap (target->dpy, target->scrollBar.win, ParentRelative); |
… | |
… | |
691 | XClearArea (target->dpy, target->parent[0], 0, 0, 0, 0, True); |
904 | XClearArea (target->dpy, target->parent[0], 0, 0, 0, 0, True); |
692 | } |
905 | } |
693 | } |
906 | } |
694 | #endif /* HAVE_BG_PIXMAP */ |
907 | #endif /* HAVE_BG_PIXMAP */ |
695 | |
908 | |
|
|
909 | |
|
|
910 | void |
|
|
911 | rxvt_term::get_window_origin (int &x, int &y) |
|
|
912 | { |
|
|
913 | Window cr; |
|
|
914 | XTranslateCoordinates (dpy, parent[0], display->root, 0, 0, &x, &y, &cr); |
|
|
915 | } |
|
|
916 | |
|
|
917 | Pixmap |
|
|
918 | rxvt_term::get_pixmap_property (int prop_id) |
|
|
919 | { |
|
|
920 | if (prop_id > 0 && prop_id < NUM_XA) |
|
|
921 | if (xa[prop_id]) |
|
|
922 | { |
|
|
923 | int aformat, rootdepth; |
|
|
924 | unsigned long nitems, bytes_after; |
|
|
925 | Atom atype; |
|
|
926 | unsigned char *prop = NULL; |
|
|
927 | int result = XGetWindowProperty (dpy, display->root, xa[prop_id], |
|
|
928 | 0L, 1L, False, XA_PIXMAP, &atype, &aformat, |
|
|
929 | &nitems, &bytes_after, &prop); |
|
|
930 | if (result == Success && prop && atype == XA_PIXMAP) |
|
|
931 | { |
|
|
932 | return *(Pixmap *)prop; |
|
|
933 | } |
|
|
934 | } |
|
|
935 | return None; |
|
|
936 | } |
696 | |
937 | |
697 | |
938 | |
698 | #ifdef ENABLE_TRANSPARENCY |
939 | #ifdef ENABLE_TRANSPARENCY |
699 | #ifndef HAVE_AFTERIMAGE |
940 | #ifndef HAVE_AFTERIMAGE |
700 | /* taken from aterm-0.4.2 */ |
941 | /* taken from aterm-0.4.2 */ |
… | |
… | |
954 | Window cr; |
1195 | Window cr; |
955 | unsigned int rootpixmap_w = 0, rootpixmap_h = 0; |
1196 | unsigned int rootpixmap_w = 0, rootpixmap_h = 0; |
956 | |
1197 | |
957 | if (!option (Opt_transparent)) |
1198 | if (!option (Opt_transparent)) |
958 | return; /* Don't try any more */ |
1199 | return; /* Don't try any more */ |
959 | |
|
|
960 | #if 0 |
1200 | #if 0 |
961 | struct timeval stv; |
1201 | struct timeval stv; |
962 | gettimeofday (&stv,NULL); |
1202 | gettimeofday (&stv,NULL); |
963 | #define PRINT_BACKGROUND_OP_TIME do{ struct timeval tv;gettimeofday (&tv,NULL); tv.tv_sec-= stv.tv_sec;\ |
1203 | #define PRINT_BACKGROUND_OP_TIME do{ struct timeval tv;gettimeofday (&tv,NULL); tv.tv_sec-= stv.tv_sec;\ |
964 | fprintf (stderr,"%d: elapsed %ld usec\n",__LINE__,\ |
1204 | fprintf (stderr,"%d: elapsed %ld usec\n",__LINE__,\ |
… | |
… | |
1047 | whole_tint = (IS_COMPONENT_WHOLESOME(c.r) |
1287 | whole_tint = (IS_COMPONENT_WHOLESOME(c.r) |
1048 | && IS_COMPONENT_WHOLESOME(c.g) |
1288 | && IS_COMPONENT_WHOLESOME(c.g) |
1049 | && IS_COMPONENT_WHOLESOME(c.b)); |
1289 | && IS_COMPONENT_WHOLESOME(c.b)); |
1050 | no_tint = (c.r >= 0x00f700 && c.g >= 0x00f700 && c.b >= 0x00f700); |
1290 | no_tint = (c.r >= 0x00f700 && c.g >= 0x00f700 && c.b >= 0x00f700); |
1051 | #undef IS_COMPONENT_WHOLESOME |
1291 | #undef IS_COMPONENT_WHOLESOME |
1052 | /* theer are no performance advantages to reusing same pixmap */ |
|
|
1053 | if (bgPixmap.pixmap != None) |
|
|
1054 | XFreePixmap (dpy, bgPixmap.pixmap); |
|
|
1055 | bgPixmap.pixmap = XCreatePixmap (dpy, vt, szHint.width, szHint.height, rootdepth); |
|
|
1056 | bgPixmap.pmap_width = szHint.width; |
|
|
1057 | bgPixmap.pmap_height = szHint.height; |
|
|
1058 | bgPixmap.pmap_depth = rootdepth; |
|
|
1059 | |
1292 | |
1060 | #if 0 /* TODO : identify cases where this will be detrimental to performance : */ |
1293 | bgPixmap.make_transparency_pixmap(); |
1061 | /* we want to tile root pixmap into our own pixmap in this cases : |
|
|
1062 | * 1) rootpixmap does not cover our window entirely |
|
|
1063 | * 2) whole_tint - we can use server-side tinting or tinting disabled |
|
|
1064 | */ |
|
|
1065 | if ( whole_tint || no_tint || pmap_w < sx + szHint.width || pmap_h < sy + szHint.height) |
|
|
1066 | { |
|
|
1067 | } |
|
|
1068 | #endif |
|
|
1069 | gcvalue.tile = rootpixmap; |
|
|
1070 | gcvalue.fill_style = FillTiled; |
|
|
1071 | gcvalue.ts_x_origin = -sx; |
|
|
1072 | gcvalue.ts_y_origin = -sy; |
|
|
1073 | gc = XCreateGC (dpy, rootpixmap, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcvalue); |
|
|
1074 | XFillRectangle (dpy, bgPixmap.pixmap, gc, 0, 0, szHint.width, szHint.height); |
|
|
1075 | |
1294 | |
1076 | if (whole_tint && !no_tint) |
1295 | if (whole_tint && !no_tint) |
1077 | { |
1296 | { |
1078 | /* In this case we can tint image server-side getting significant |
|
|
1079 | * performance improvements, as we eliminate XImage transfer |
|
|
1080 | */ |
|
|
1081 | gcvalue.foreground = Pixel (pix_colors_focused [Color_tint]); |
|
|
1082 | gcvalue.function = GXand; |
|
|
1083 | gcvalue.fill_style = FillSolid; |
|
|
1084 | XChangeGC (dpy, gc, GCFillStyle | GCForeground | GCFunction, &gcvalue); |
|
|
1085 | XFillRectangle (dpy, bgPixmap.pixmap, gc, 0, 0, szHint.width, szHint.height); |
|
|
1086 | } |
1297 | } |
1087 | success = True; |
1298 | success = True; |
1088 | #ifdef HAVE_AFTERIMAGE |
1299 | #ifdef HAVE_AFTERIMAGE |
1089 | if (rs[Rs_blurradius] || bgPixmap.original_asim != NULL || (!whole_tint && (!no_tint || shade !=100))) |
1300 | if (rs[Rs_blurradius] || bgPixmap.original_asim != NULL || (!whole_tint && (!no_tint || shade !=100))) |
1090 | { |
1301 | { |