ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/rxvt-unicode/src/command.C
(Generate patch)

Comparing rxvt-unicode/src/command.C (file contents):
Revision 1.323 by ayin, Mon May 28 18:38:03 2007 UTC vs.
Revision 1.324 by sasha, Fri Jun 8 20:04:12 2007 UTC

1489 1489
1490 if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height) 1490 if (szHint.width != ev.xconfigure.width || szHint.height != ev.xconfigure.height)
1491 { 1491 {
1492 seen_resize = 1; 1492 seen_resize = 1;
1493 resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1); 1493 resize_all_windows (ev.xconfigure.width, ev.xconfigure.height, 1);
1494#ifdef XPM_BACKGROUND
1495 if (!option(Opt_transparent) && bgPixmap.auto_resize)
1496 {
1497 resize_pixmap ();
1498 scr_touch (true);
1499 }
1500#endif
1494 } 1501 }
1495 1502
1496 HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END)); 1503 HOOK_INVOKE ((this, HOOK_CONFIGURE_NOTIFY, DT_XEVENT, &ev, DT_END));
1497 1504
1498#ifdef TRANSPARENT 1505#ifdef TRANSPARENT
1839 && ev.xproperty.atom != xa[XA_ESETROOT_PMAP_ID]) 1846 && ev.xproperty.atom != xa[XA_ESETROOT_PMAP_ID])
1840 return; 1847 return;
1841 1848
1842 /* FALLTHROUGH */ 1849 /* FALLTHROUGH */
1843 case ReparentNotify: 1850 case ReparentNotify:
1844 if (option (Opt_transparent) && check_our_parents () && am_transparent) 1851 if (option (Opt_transparent))
1845 want_refresh = want_full_refresh = 1; 1852 check_our_parents ();
1846 break; 1853 break;
1847 } 1854 }
1848# endif 1855# endif
1849} 1856}
1850#endif 1857#endif
2228 } 2235 }
2229 } 2236 }
2230} 2237}
2231 2238
2232#ifdef TRANSPARENT 2239#ifdef TRANSPARENT
2233#if TINTING 2240#if TINTING && !defined(HAVE_AFTERIMAGE)
2234/* taken from aterm-0.4.2 */ 2241/* taken from aterm-0.4.2 */
2235 2242
2236typedef uint32_t RUINT32T; 2243typedef uint32_t RUINT32T;
2237 2244
2238void ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm) 2245void ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm)
2466 * Do transparency updates if required 2473 * Do transparency updates if required
2467 */ 2474 */
2468int 2475int
2469rxvt_term::check_our_parents () 2476rxvt_term::check_our_parents ()
2470{ 2477{
2478#if TRANSPARENT || ENABLE_PERL
2479 check_our_aprents_ev.stop();
2480 check_our_aprents_ev.start(NOW + 1./3.);
2481#endif
2482 return 0;
2483}
2484
2485void
2486rxvt_term::check_our_parents_cb (time_watcher &w)
2487{
2471 int i, pchanged, aformat, have_pixmap, rootdepth; 2488 int i, pchanged, aformat, have_pixmap, rootdepth;
2472 unsigned long nitems, bytes_after; 2489 unsigned long nitems, bytes_after;
2473 Atom atype; 2490 Atom atype;
2474 unsigned char *prop = NULL; 2491 unsigned char *prop = NULL;
2475 Window root, oldp, *list; 2492 Window root, oldp, *list;
2476 Pixmap rootpixmap = None; 2493 Pixmap rootpixmap = None;
2477 XWindowAttributes wattr, wrootattr; 2494 XWindowAttributes wattr, wrootattr;
2495 int sx, sy;
2496 Window cr;
2478 2497
2479 pchanged = 0; 2498 pchanged = 0;
2480 2499
2481 if (!option (Opt_transparent)) 2500 if (!option (Opt_transparent))
2482 return pchanged; /* Don't try any more */ 2501 return /*pchanged*/; /* Don't try any more */
2483 2502
2484 XGetWindowAttributes (dpy, display->root, &wrootattr); 2503 XGetWindowAttributes (dpy, display->root, &wrootattr);
2485 rootdepth = wrootattr.depth; 2504 rootdepth = wrootattr.depth;
2486 2505
2487 XGetWindowAttributes (dpy, parent[0], &wattr); 2506 XGetWindowAttributes (dpy, parent[0], &wattr);
2493 pchanged = 1; 2512 pchanged = 1;
2494 XSetWindowBackground (dpy, vt, pix_colors_focused[Color_bg]); 2513 XSetWindowBackground (dpy, vt, pix_colors_focused[Color_bg]);
2495 am_transparent = am_pixmap_trans = 0; 2514 am_transparent = am_pixmap_trans = 0;
2496 } 2515 }
2497 2516
2498 return pchanged; /* Don't try any more */ 2517 return /*pchanged*/; /* Don't try any more */
2499 } 2518 }
2500 2519
2501 /* Get all X ops out of the queue so that our information is up-to-date. */ 2520 /* Get all X ops out of the queue so that our information is up-to-date. */
2502 XSync (dpy, False); 2521 XSync (dpy, False);
2503 2522
2523 XTranslateCoordinates (dpy, parent[0], display->root,
2524 0, 0, &sx, &sy, &cr);
2525
2526 /* check if we are outside of the visible part of the virtual screen : */
2527 if( sx + (int)szHint.width <= 0 || sy + (int)szHint.height <= 0
2528 || sx >= wrootattr.width || sy >= wrootattr.height )
2529 return /* 0 */ ;
2504 /* 2530 /*
2505 * Make the frame window set by the window manager have 2531 * Make the frame window set by the window manager have
2506 * the root background. Some window managers put multiple nested frame 2532 * the root background. Some window managers put multiple nested frame
2507 * windows for each client, so we have to take care about that. 2533 * windows for each client, so we have to take care about that.
2508 */ 2534 */
2517 0L, 1L, False, XA_PIXMAP, &atype, &aformat, 2543 0L, 1L, False, XA_PIXMAP, &atype, &aformat,
2518 &nitems, &bytes_after, &prop) == Success); 2544 &nitems, &bytes_after, &prop) == Success);
2519 2545
2520 if (!i || prop == NULL 2546 if (!i || prop == NULL
2521#if TINTING 2547#if TINTING
2522 || !ISSET_PIXCOLOR (Color_tint) 2548 || (!ISSET_PIXCOLOR (Color_tint) && rs[Rs_shade] == NULL
2549#ifdef HAVE_AFTERIMAGE
2550 && original_asim == NULL && rs[Rs_blurradius] == NULL
2551#endif
2552 )
2523#endif 2553#endif
2524 ) 2554 )
2525 have_pixmap = 0; 2555 have_pixmap = 0;
2526 else 2556 else
2527 { 2557 {
2530 XFree (prop); 2560 XFree (prop);
2531 } 2561 }
2532 2562
2533 if (have_pixmap) 2563 if (have_pixmap)
2534 { 2564 {
2565 Bool success = False ;
2566 GC gc;
2567 XGCValues gcvalue;
2568#ifdef HAVE_AFTERIMAGE
2569 {
2570 Pixmap tmp_pmap = None ;
2571 ShadingInfo shade;
2572 ARGB32 tint ;
2573 unsigned int pmap_w = 0, pmap_h = 0;
2574
2575 if (get_drawable_size( rootpixmap, &pmap_w, &pmap_h ))
2576 {
2577 int root_x = 0, root_y = 0;
2578
2579 shade.shading = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100;
2580 if (ISSET_PIXCOLOR (Color_tint))
2581 {
2582 rgba c;
2583 pix_colors_focused [Color_tint].get (c);
2584 shade.tintColor.red = c.r;
2585 shade.tintColor.green = c.g;
2586 shade.tintColor.blue = c.b;
2587 }
2588 else
2589 shade.tintColor.red = shade.tintColor.green = shade.tintColor.blue = 0xFFFF;
2590 tint = shading2tint32( &shade );
2591 gc = XCreateGC (dpy, vt, 0UL, &gcvalue);
2592 if (GetWinPosition (parent[0], &root_x, &root_y) )
2593 {
2594 ASImageLayer *layers = create_image_layers( 2 );
2595 ASImage *merged_im = NULL;
2596 int back_x, back_y, back_w, back_h;
2597 /* merge_layers does good job at tiling background appropriately,
2598 so all we need is to cut out smallest possible piece : */
2599#define MAKE_ROOTPMAP_GEOM(xy,wh,widthheight) \
2600 do{ while( root_##xy < 0 ) root_##xy += (int)wrootattr.widthheight; \
2601 back_##xy = root_##xy % pmap_##wh; /* that gives us left side of the closest tile : */ \
2602 if( pmap_##wh >= back_##xy + szHint.widthheight ) \
2603 back_##wh = szHint.widthheight;/* background is large - limit it by our size */ \
2604 else \
2605 { /* small background - need the whole of it for successfull tiling :*/ \
2606 back_##xy = 0; \
2607 back_##wh = pmap_##wh; \
2608 }}while(0)
2609
2610 MAKE_ROOTPMAP_GEOM(x,w,width);
2611 MAKE_ROOTPMAP_GEOM(y,h,height);
2612
2613 layers[0].im = pixmap2asimage (display->asv, rootpixmap, back_x, back_y, back_w, back_h, AllPlanes, ASA_ASImage, 100);
2614 layers[0].clip_x = (back_w == pmap_w)?root_x:0;
2615 layers[0].clip_y = (back_h == pmap_h)?root_y:0;
2616 layers[0].clip_width = szHint.width;
2617 layers[0].clip_height = szHint.height;
2618 layers[0].tint = tint;
2619 if (rs[Rs_blurradius] && layers[0].im)
2620 {
2621 double r = atof(rs[Rs_blurradius]);
2622 ASImage* tmp = blur_asimage_gauss(display->asv, layers[0].im, r, r, 0xFFFFFFFF, ASA_ASImage, 100, ASIMAGE_QUALITY_DEFAULT );
2623 if( tmp )
2624 {
2625 destroy_asimage( &layers[0].im );
2626 layers[0].im = tmp;
2627 }
2628 }
2629 if (original_asim != NULL)
2630 {
2631 int fore_w, fore_h;
2632 layers[1].im = original_asim;
2633 if( bgPixmap.auto_resize )
2634 {
2635 fore_w = szHint.width;
2636 fore_h = szHint.height;
2637 }
2638 else
2639 {
2640 fore_w = bgPixmap.w;
2641 fore_h = bgPixmap.h;
2642 }
2643 if (fore_w != original_asim->width
2644 || fore_h != original_asim->height)
2645 {
2646 layers[1].im = scale_asimage( display->asv,
2647 original_asim,
2648 fore_w, fore_h,
2649 ASA_ASImage, 100,
2650 ASIMAGE_QUALITY_DEFAULT );
2651 }
2652
2653 layers[1].clip_width = szHint.width;
2654 layers[1].clip_height = szHint.height;
2655
2656 if (rs[Rs_blendtype])
2657 {
2658 layers[1].merge_scanlines = blend_scanlines_name2func(rs[Rs_blendtype]);
2659 if( layers[1].merge_scanlines == NULL )
2660 layers[1].merge_scanlines = alphablend_scanlines;
2661 }
2662 }
2663 merged_im = merge_layers( display->asv, layers, layers[1].im?2:1,
2664 szHint.width, szHint.height,
2665 ASA_XImage, 0, ASIMAGE_QUALITY_DEFAULT );
2666 if (layers[1].im != original_asim)
2667 destroy_asimage( &(layers[1].im) );
2668 destroy_asimage( &(layers[0].im) );
2669 if (merged_im != NULL)
2670 {
2671 tmp_pmap = asimage2pixmap( display->asv, DefaultRootWindow(dpy), merged_im, gc, True );
2672 destroy_asimage( &merged_im );
2673 }
2674 free( layers );
2675 }
2676 }
2677 if (tmp_pmap != None)
2678 {
2679 success = True;
2680 if (pixmap != None)
2681 XFreePixmap (dpy, pixmap);
2682 pixmap = tmp_pmap;
2683 }
2684 }
2685#else /* HAVE_AFTERIMAGE */
2686 {
2535 /* 2687 /*
2536 * Copy display->root pixmap transparency 2688 * Copy display->root pixmap transparency
2537 */ 2689 */
2538 int sx, sy, nx, ny; 2690 int nx, ny;
2539 unsigned int nw, nh; 2691 unsigned int nw, nh;
2540 Window cr;
2541 XImage *image; 2692 XImage *image;
2542 GC gc;
2543 XGCValues gcvalue;
2544 2693
2545 XTranslateCoordinates (dpy, parent[0], display->root,
2546 0, 0, &sx, &sy, &cr);
2547 nw = (unsigned int)szHint.width; 2694 nw = (unsigned int)szHint.width;
2548 nh = (unsigned int)szHint.height; 2695 nh = (unsigned int)szHint.height;
2549 nx = ny = 0; 2696 nx = ny = 0;
2550 2697
2551 if (sx < 0) 2698 if (sx < 0)
2552 { 2699 {
2553 nw += sx; 2700 nw += sx;
2554 nx = -sx; 2701 nx = -sx;
2555 sx = 0; 2702 sx = 0;
2556 } 2703 }
2557 2704
2558 if (sy < 0) 2705 if (sy < 0)
2559 { 2706 {
2560 nh += sy; 2707 nh += sy;
2561 ny = -sy; 2708 ny = -sy;
2562 sy = 0; 2709 sy = 0;
2563 } 2710 }
2564 2711
2565 min_it (nw, (unsigned int) (wrootattr.width - sx)); 2712 min_it (nw, (unsigned int) (wrootattr.width - sx));
2566 min_it (nh, (unsigned int) (wrootattr.height - sy)); 2713 min_it (nh, (unsigned int) (wrootattr.height - sy));
2567 2714
2568 XSync (dpy, False); 2715 XSync (dpy, False);
2569 allowedxerror = -1; 2716 allowedxerror = -1;
2570 image = XGetImage (dpy, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap); 2717 image = XGetImage (dpy, rootpixmap, sx, sy, nw, nh, AllPlanes, ZPixmap);
2571 2718
2572 /* XXX: handle BadMatch - usually because we're outside the pixmap */ 2719 /* XXX: handle BadMatch - usually because we're outside the pixmap */
2573 /* XXX: may need a delay here? */ 2720 /* XXX: may need a delay here? */
2574 allowedxerror = 0; 2721 allowedxerror = 0;
2575
2576 if (image == NULL) 2722 if (image != NULL)
2723 {
2724 if (pixmap != None)
2725 XFreePixmap (dpy, pixmap);
2726
2727#if TINTING
2728 if (ISSET_PIXCOLOR (Color_tint))
2729 {
2730 int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100;
2731
2732 rgba c;
2733 pix_colors_focused [Color_tint].get (c);
2734 ShadeXImage (this, image, shade, c.r, c.g, c.b);
2735 }
2736#endif
2737
2738 pixmap = XCreatePixmap (dpy, vt, szHint.width, szHint.height, image->depth);
2739 gc = XCreateGC (dpy, vt, 0UL, &gcvalue);
2740 XPutImage (dpy, pixmap, gc, image, 0, 0,
2741 nx, ny, image->width, image->height);
2742 XDestroyImage (image);
2743 success = True ;
2744 }
2745 }
2746#endif /* HAVE_AFTERIMAGE */
2747 if (gc != NULL)
2748 XFreeGC (dpy, gc);
2749
2750 if (!success)
2577 { 2751 {
2578 if (am_transparent && am_pixmap_trans) 2752 if (am_transparent && am_pixmap_trans)
2579 { 2753 {
2580 pchanged = 1; 2754 pchanged = 1;
2581 if (pixmap != None) 2755 if (pixmap != None)
2587 2761
2588 am_pixmap_trans = 0; 2762 am_pixmap_trans = 0;
2589 } 2763 }
2590 else 2764 else
2591 { 2765 {
2592 if (pixmap != None)
2593 XFreePixmap (dpy, pixmap);
2594
2595#if TINTING
2596 if (ISSET_PIXCOLOR (Color_tint))
2597 {
2598 int shade = rs[Rs_shade] ? atoi (rs[Rs_shade]) : 100;
2599
2600 rgba c;
2601 pix_colors_focused [Color_tint].get (c);
2602
2603 ShadeXImage (this, image, shade, c.r, c.g, c.b);
2604 }
2605#endif
2606
2607 pixmap = XCreatePixmap (dpy, vt, szHint.width, szHint.height, image->depth);
2608 gc = XCreateGC (dpy, vt, 0UL, &gcvalue);
2609 XPutImage (dpy, pixmap, gc, image, 0, 0,
2610 nx, ny, image->width, image->height);
2611 XFreeGC (dpy, gc);
2612 XDestroyImage (image);
2613 XSetWindowBackgroundPixmap (dpy, parent[0], pixmap); 2766 XSetWindowBackgroundPixmap (dpy, parent[0], pixmap);
2614 XClearWindow (dpy, parent[0]); 2767 XClearWindow (dpy, parent[0]);
2615 2768
2616 if (!am_transparent || !am_pixmap_trans) 2769 if (!am_transparent || !am_pixmap_trans)
2617 pchanged = 1; 2770 pchanged = 1;
2695 want_refresh = want_full_refresh = 1; 2848 want_refresh = want_full_refresh = 1;
2696 if (am_pixmap_trans) 2849 if (am_pixmap_trans)
2697 flush (); 2850 flush ();
2698 } 2851 }
2699 2852
2700 return pchanged; 2853// return pchanged;
2701} 2854}
2702#endif 2855#endif
2703 2856
2704/*}}} */ 2857/*}}} */
2705 2858
3946#ifdef XPM_BACKGROUND 4099#ifdef XPM_BACKGROUND
3947 resize_pixmap (); 4100 resize_pixmap ();
3948 scr_touch (true); 4101 scr_touch (true);
3949#endif 4102#endif
3950 } 4103 }
4104#if TRANSPARENT && defined(HAVE_AFTERIMAGE)
4105 if (option(Opt_transparent))
4106 check_our_parents ();
4107#endif
4108
3951 } 4109 }
3952 break; 4110 break;
3953 4111
3954 case Rxvt_restoreFG: 4112 case Rxvt_restoreFG:
3955 set_window_color (Color_fg, str); 4113 set_window_color (Color_fg, str);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines