--- rxvt-unicode/src/background.C 2012/06/01 16:07:35 1.229 +++ rxvt-unicode/src/background.C 2012/06/06 22:00:20 1.233 @@ -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; -} -# endif - -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]; -} - 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,7 +957,7 @@ 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 @@ -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); @@ -1136,9 +1098,9 @@ 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; } @@ -1148,7 +1110,7 @@ rxvt_term::bg_render () { bg_invalidate (); -# ifdef ENABLE_TRANSPARENCY +# if ENABLE_TRANSPARENCY if (bg_flags & BG_IS_TRANSPARENT) { /* we need to re-generate transparency pixmap in that case ! */ @@ -1157,10 +1119,10 @@ } # 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 @@ -1185,51 +1147,13 @@ 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 (); - } - -# ifndef NO_RESOURCES - find_resources ("image", "Image", XrmEnumAllLevels, rxvt_define_image); -# endif - - 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++; - } + if (fimage.set_file_geometry (rs[Rs_backgroundPixmap]) + && !bg_window_position_sensitive ()) + update_background (); } - - if (image_vec.size () > 0 - && !bg_window_position_sensitive ()) - update_background (); #endif }