--- rxvt-unicode/src/background.C 2012/05/31 05:53:46 1.226 +++ rxvt-unicode/src/background.C 2012/06/07 09:34:51 1.235 @@ -60,9 +60,8 @@ void rxvt_term::bg_destroy () { -# ifdef BG_IMAGE_FROM_FILE - for (vector::iterator bg_image = image_vec.begin (); bg_image < image_vec.end (); bg_image++) - bg_image->destroy (); +# if BG_IMAGE_FROM_FILE + fimage.destroy (); # endif if (bg_pixmap) @@ -86,17 +85,17 @@ bool rxvt_term::bg_window_size_sensitive () { -# ifdef ENABLE_TRANSPARENCY +# if ENABLE_TRANSPARENCY if (bg_flags & BG_IS_TRANSPARENT) return true; # endif -# ifdef BG_IMAGE_FROM_FILE - for (vector::iterator bg_image = image_vec.begin (); bg_image < image_vec.end (); bg_image++) +# if BG_IMAGE_FROM_FILE + if (fimage.flags & IM_IS_SET) { - if ((bg_image->flags & IM_IS_SIZE_SENSITIVE) - || bg_image->width () > szHint.width - || bg_image->height () > szHint.height) + if ((fimage.flags & IM_IS_SIZE_SENSITIVE) + || fimage.width () > szHint.width + || fimage.height () > szHint.height) return true; } # endif @@ -107,15 +106,15 @@ bool rxvt_term::bg_window_position_sensitive () { -# ifdef ENABLE_TRANSPARENCY +# if ENABLE_TRANSPARENCY if (bg_flags & BG_IS_TRANSPARENT) return true; # endif -# ifdef BG_IMAGE_FROM_FILE - for (vector::iterator bg_image = image_vec.begin (); bg_image < image_vec.end (); bg_image++) +# if BG_IMAGE_FROM_FILE + if (fimage.flags & IM_IS_SET) { - if (bg_image->flags & IM_ROOT_ALIGN) + if (fimage.flags & IM_ROOT_ALIGN) return true; } # endif @@ -123,7 +122,7 @@ return false; } -# ifdef BG_IMAGE_FROM_FILE +# if BG_IMAGE_FROM_FILE static inline int make_align_position (int align, int window_size, int image_size) { @@ -349,7 +348,7 @@ } } -# ifdef HAVE_PIXBUF +# if HAVE_PIXBUF bool rxvt_term::pixbuf_to_pixmap (GdkPixbuf *pixbuf, Pixmap pixmap, GC gc, int src_x, int src_y, int dst_x, int dst_y, @@ -486,7 +485,7 @@ bool need_blend = bg_flags & BG_IS_VALID; if (need_blend - && !(bg_flags & BG_HAS_RENDER)) + && !(display->flags & DISPLAY_HAS_RENDER)) return false; GdkPixbuf *result; @@ -539,11 +538,7 @@ tmp_pixmap = XCreatePixmap (dpy, vt, new_pmap_width, new_pmap_height, 32); else { - // optimise bg pixmap size when tiling, but only if there are no - // other pixbufs to render. Otherwise, the bg pixmap size must - // be equal to the window size. - if ((image.flags & IM_TILE) - && image_vec.size () == 1) + if (image.flags & IM_TILE) { new_pmap_width = min (image_width, target_width); new_pmap_height = min (image_height, target_height); @@ -653,39 +648,6 @@ } # endif /* HAVE_PIXBUF */ -# ifndef NO_RESOURCES -static int -rxvt_define_image (XrmDatabase *database ecb_unused, - XrmBindingList bindings ecb_unused, - XrmQuarkList quarks, - XrmRepresentation *type ecb_unused, - XrmValue *value, - XPointer closure ecb_unused) -{ - int size; - - for (size = 0; quarks[size] != NULLQUARK; size++) - ; - - if (size >= 2) - { - int id = strtol (XrmQuarkToString (quarks[size-2]), 0, 0); - if (id >= 1) - GET_R->parse_image (id, XrmQuarkToString (quarks[size-1]), (char *)value->addr); - } - return False; -} - -void -rxvt_term::parse_image (int id, const char *type, const char *arg) -{ - if (image_vec.size () < id + 1) - image_vec.resize (id + 1); - - rxvt_image *image = &image_vec[id]; -} -# endif - rxvt_image::rxvt_image () { alpha = 0xffff; @@ -695,7 +657,7 @@ h_align = v_align = defaultAlign; -# ifdef HAVE_PIXBUF +# if HAVE_PIXBUF pixbuf = 0; # endif } @@ -729,7 +691,7 @@ { bool ret = false; -# ifdef HAVE_PIXBUF +# if HAVE_PIXBUF GdkPixbuf *image = gdk_pixbuf_new_from_file (file, NULL); if (image) { @@ -839,7 +801,7 @@ { bool ret = false; #if XRENDER - if (!(bg_flags & BG_HAS_RENDER_CONV)) + if (!(display->flags & DISPLAY_HAS_RENDER_CONV)) return false; int size = max (h_blurRadius, v_blurRadius) * 2 + 1; @@ -933,7 +895,7 @@ } } # if XRENDER - else if (bg_flags & BG_HAS_RENDER) + else if (display->flags & DISPLAY_HAS_RENDER) { if (shade <= 100) { @@ -995,14 +957,14 @@ return ret; } -# ifdef ENABLE_TRANSPARENCY +# if ENABLE_TRANSPARENCY /* * Builds a pixmap of the same size as the terminal window that contains * the tiled portion of the root pixmap that is supposed to be covered by * our window. */ bool -rxvt_term::make_transparency_pixmap () +rxvt_term::render_root_image () { bool ret = false; @@ -1048,7 +1010,7 @@ if (root_pixmap != None && root_depth != depth) { #if XRENDER - if (bg_flags & BG_HAS_RENDER) + if (display->flags & DISPLAY_HAS_RENDER) { recoded_root_pmap = XCreatePixmap (dpy, vt, root_pmap_width, root_pmap_height, depth); @@ -1099,33 +1061,30 @@ bool need_blur = root_effects.need_blur (); bool need_tint = root_effects.need_tint (); - if (!(bg_flags & BG_CLIENT_RENDER)) + if (need_blur) { - if (need_blur) - { - if (blur_pixmap (bg_pixmap, window_width, window_height, false, - root_effects.h_blurRadius, root_effects.v_blurRadius)) - need_blur = false; - } - if (need_tint) - { - if (tint_pixmap (bg_pixmap, window_width, window_height, false, - root_effects.tint, root_effects.tint_set, root_effects.shade)) - need_tint = false; - } - if (need_tint) + if (blur_pixmap (bg_pixmap, window_width, window_height, false, + root_effects.h_blurRadius, root_effects.v_blurRadius)) + need_blur = false; + } + if (need_tint) + { + if (tint_pixmap (bg_pixmap, window_width, window_height, false, + root_effects.tint, root_effects.tint_set, root_effects.shade)) + need_tint = false; + } + if (need_tint) + { + XImage *ximage = XGetImage (dpy, bg_pixmap, 0, 0, bg_pmap_width, bg_pmap_height, AllPlanes, ZPixmap); + if (ximage) { - XImage *ximage = XGetImage (dpy, bg_pixmap, 0, 0, bg_pmap_width, bg_pmap_height, AllPlanes, ZPixmap); - if (ximage) - { - /* our own client-side tinting */ - tint_ximage (ximage, root_effects.tint, root_effects.tint_set, root_effects.shade); - - XPutImage (dpy, bg_pixmap, gc, ximage, 0, 0, 0, 0, ximage->width, ximage->height); - XDestroyImage (ximage); - } + /* our own client-side tinting */ + tint_ximage (ximage, root_effects.tint, root_effects.tint_set, root_effects.shade); + + XPutImage (dpy, bg_pixmap, gc, ximage, 0, 0, 0, 0, ximage->width, ximage->height); + XDestroyImage (ximage); } - } /* server side rendering completed */ + } XFreeGC (dpy, gc); } @@ -1139,31 +1098,34 @@ void rxvt_term::bg_set_root_pixmap () { - Pixmap new_root_pixmap = get_pixmap_property (xa[XA_XROOTPMAP_ID]); + Pixmap new_root_pixmap = display->get_pixmap_property (xa[XA_XROOTPMAP_ID]); if (new_root_pixmap == None) - new_root_pixmap = get_pixmap_property (xa[XA_ESETROOT_PMAP_ID]); + new_root_pixmap = display->get_pixmap_property (xa[XA_ESETROOT_PMAP_ID]); root_pixmap = new_root_pixmap; } # endif /* ENABLE_TRANSPARENCY */ -bool +void rxvt_term::bg_render () { + if (bg_flags & BG_INHIBIT_RENDER) + return; + bg_invalidate (); -# ifdef ENABLE_TRANSPARENCY +# if ENABLE_TRANSPARENCY if (bg_flags & BG_IS_TRANSPARENT) { /* we need to re-generate transparency pixmap in that case ! */ - if (make_transparency_pixmap ()) + if (render_root_image ()) bg_flags |= BG_IS_VALID; } # endif -# ifdef BG_IMAGE_FROM_FILE - for (vector::iterator bg_image = image_vec.begin (); bg_image < image_vec.end (); bg_image++) +# if BG_IMAGE_FROM_FILE + if (fimage.flags & IM_IS_SET) { - if (render_image (*bg_image)) + if (render_image (fimage)) bg_flags |= BG_IS_VALID; } # endif @@ -1181,57 +1143,18 @@ bg_flags |= BG_NEEDS_REFRESH; bg_valid_since = ev::now (); - - return true; } void rxvt_term::bg_init () { - bg_flags &= ~(BG_HAS_RENDER | BG_HAS_RENDER_CONV); -#if XRENDER - int major, minor; - if (XRenderQueryVersion (dpy, &major, &minor)) - bg_flags |= BG_HAS_RENDER; - XFilters *filters = XRenderQueryFilters (dpy, vt); - if (filters) - { - for (int i = 0; i < filters->nfilter; i++) - if (!strcmp (filters->filter[i], FilterConvolution)) - bg_flags |= BG_HAS_RENDER_CONV; - - XFree (filters); - } -#endif - -#ifdef BG_IMAGE_FROM_FILE +#if BG_IMAGE_FROM_FILE if (rs[Rs_backgroundPixmap]) { - rxvt_image *image = new_image (); - if (!image->set_file_geometry (rs[Rs_backgroundPixmap])) - image_vec.pop_back (); + if (fimage.set_file_geometry (rs[Rs_backgroundPixmap]) + && !bg_window_position_sensitive ()) + update_background (); } - -# ifndef NO_RESOURCES - find_resources ("image", "Image", XrmEnumAllLevels, rxvt_define_image); - vector::iterator bg_image = image_vec.begin (); - while (bg_image != image_vec.end ()) - { - if (!(bg_image->flags & IM_IS_SET)) - bg_image = image_vec.erase (bg_image); - else - { - if (bg_image->is_size_sensitive ()) - bg_image->flags |= IM_IS_SIZE_SENSITIVE; - - bg_image++; - } - } -# endif - - if (image_vec.size () > 0 - && !bg_window_position_sensitive ()) - update_background (); #endif }