--- rxvt-unicode/src/background.C 2010/10/09 14:58:15 1.73 +++ rxvt-unicode/src/background.C 2010/10/12 22:14:04 1.77 @@ -106,6 +106,9 @@ h_scale = v_scale = 0; h_align = v_align = 0; #endif +#ifdef ENABLE_TRANSPARENCY + shade = 100; +#endif flags = 0; pixmap = None; valid_since = invalid_since = 0; @@ -501,7 +504,7 @@ if (!(background_flags & transpPmapTinted) && (flags & tintNeeded)) { ShadingInfo as_shade; - as_shade.shading = (shade == 0) ? 100 : shade; + as_shade.shading = shade; rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); if (flags & tintSet) @@ -513,7 +516,7 @@ background_tint = shading2tint32 (&as_shade); } - if (!(background_flags & transpPmapBlured) && (flags & blurNeeded) && background != NULL) + if (!(background_flags & transpPmapBlurred) && (flags & blurNeeded) && background != NULL) { ASImage *tmp = blur_asimage_gauss (target->asv, background, h_blurRadius, v_blurRadius, 0xFFFFFFFF, (original_asim == NULL || tint == TINT_LEAVE_SAME) ? ASA_XImage : ASA_ASImage, @@ -961,7 +964,7 @@ { unsigned long flags = 0; rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); - bool has_shade = (shade > 0 && shade < 100) || (shade > 100 && shade < 200); + bool has_shade = shade != 100; if (tint) { @@ -1031,12 +1034,11 @@ bool bgPixmap_t::set_shade (const char *shade_str) { - int new_shade = (shade_str) ? atoi (shade_str) : 0; + int new_shade = (shade_str) ? atoi (shade_str) : 100; - if (new_shade < 0 && new_shade > -100) + clamp_it (new_shade, -100, 200); + if (new_shade < 0) new_shade = 200 - (100 + new_shade); - else if (new_shade == 100) - new_shade = 0; if (new_shade != shade) { @@ -1050,7 +1052,7 @@ } bool -bgPixmap_t::tint_pixmap (Pixmap pixmap, Window root, int width, int height) +bgPixmap_t::tint_pixmap (Pixmap pixmap, Visual *visual, int width, int height) { Display *dpy = target->dpy; bool ret = false; @@ -1066,7 +1068,7 @@ gcv.foreground = Pixel (tint); gcv.function = GXand; gcv.fill_style = FillSolid; - gc = XCreateGC (dpy, root, GCFillStyle | GCForeground | GCFunction, &gcv); + gc = XCreateGC (dpy, pixmap, GCFillStyle | GCForeground | GCFunction, &gcv); if (gc) { XFillRectangle (dpy, pixmap, gc, 0, 0, width, height); @@ -1082,49 +1084,33 @@ if (flags & tintSet) tint.get (c); - if (shade > 0 && shade < 100) + if (shade <= 100) { c.r = (c.r * shade) / 100; c.g = (c.g * shade) / 100; c.b = (c.b * shade) / 100; } - else if (shade > 100 && shade < 200) + else { c.r = ((0xffff - c.r) * (200 - shade)) / 100; c.g = ((0xffff - c.g) * (200 - shade)) / 100; c.b = ((0xffff - c.b) * (200 - shade)) / 100; } - XRenderPictFormat pf; - pf.type = PictTypeDirect; - pf.depth = 32; - pf.direct.redMask = 0xff; - pf.direct.greenMask = 0xff; - pf.direct.blueMask = 0xff; - pf.direct.alphaMask = 0xff; - - XRenderPictFormat *solid_format = XRenderFindFormat (dpy, - (PictFormatType| - PictFormatDepth| - PictFormatRedMask| - PictFormatGreenMask| - PictFormatBlueMask| - PictFormatAlphaMask), - &pf, - 0); - XRenderPictFormat *root_format = XRenderFindVisualFormat (dpy, DefaultVisualOfScreen (ScreenOfDisplay (dpy, target->display->screen))); + XRenderPictFormat *solid_format = XRenderFindStandardFormat (dpy, PictStandardARGB32); + XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); XRenderPictureAttributes pa; - Picture back_pic = XRenderCreatePicture (dpy, pixmap, root_format, 0, &pa); + Picture back_pic = XRenderCreatePicture (dpy, pixmap, format, 0, &pa); pa.repeat = True; - Pixmap overlay_pmap = XCreatePixmap (dpy, root, 1, 1, 32); + Pixmap overlay_pmap = XCreatePixmap (dpy, pixmap, 1, 1, 32); Picture overlay_pic = XRenderCreatePicture (dpy, overlay_pmap, solid_format, CPRepeat, &pa); XFreePixmap (dpy, overlay_pmap); pa.component_alpha = True; - Pixmap mask_pmap = XCreatePixmap (dpy, root, 1, 1, 32); + Pixmap mask_pmap = XCreatePixmap (dpy, pixmap, 1, 1, 32); Picture mask_pic = XRenderCreatePicture (dpy, mask_pmap, solid_format, CPRepeat|CPComponentAlpha, &pa); XFreePixmap (dpy, mask_pmap); @@ -1294,7 +1280,7 @@ { if ((flags & tintNeeded)) { - if (tint_pixmap (tiled_root_pmap, root, window_width, window_height)) + if (tint_pixmap (tiled_root_pmap, DefaultVisual (dpy, target->display->screen), window_width, window_height)) result |= transpPmapTinted; } } /* server side rendering completed */ @@ -1546,9 +1532,6 @@ if (visual->c_class != TrueColor || srcImage->format != ZPixmap) return ; - if (shade == 0) - shade = 100; - /* for convenience */ mask_r = visual->red_mask; mask_g = visual->green_mask; @@ -1613,10 +1596,8 @@ } /* prepare limits for color transformation (each channel is handled separately) */ - if (shade < 0) { - shade = -shade; - if (shade < 0) shade = 0; - if (shade > 100) shade = 100; + if (shade > 100) { + shade = 200 - shade; lower_lim_r = 65535-rm; lower_lim_g = 65535-gm; @@ -1628,8 +1609,6 @@ upper_lim_r = upper_lim_g = upper_lim_b = 65535; } else { - if (shade < 0) shade = 0; - if (shade > 100) shade = 100; lower_lim_r = lower_lim_g = lower_lim_b = 0;