--- rxvt-unicode/src/background.C 2012/12/30 11:34:43 1.248 +++ rxvt-unicode/src/background.C 2012/12/31 12:05:46 1.256 @@ -44,7 +44,7 @@ rxvt_term::bg_window_size_sensitive () { # if BG_IMAGE_FROM_ROOT - if (option (Opt_transparent)) + if (root_img) return true; # endif @@ -65,7 +65,7 @@ rxvt_term::bg_window_position_sensitive () { # if BG_IMAGE_FROM_ROOT - if (option (Opt_transparent)) + if (root_img) return true; # endif @@ -254,7 +254,7 @@ } void -rxvt_term::get_image_geometry (rxvt_image &image, int &w, int &h, int &x, int &y) +rxvt_term::render_image (rxvt_image &image) { int image_width = image.img->w; int image_height = image.img->h; @@ -263,6 +263,11 @@ int h_scale = min (image.h_scale, 32767 * 100 / parent_width); int v_scale = min (image.v_scale, 32767 * 100 / parent_height); + int w; + int h; + int x; + int y; + w = h_scale * parent_width / 100; h = v_scale * parent_height / 100; @@ -287,27 +292,13 @@ x = make_align_position (image.h_align, parent_width, w); y = make_align_position (image.v_align, parent_height, h); } -} - -bool -rxvt_term::render_image (rxvt_image &image) -{ - int parent_width = szHint.width; - int parent_height = szHint.height; - - int x = 0; - int y = 0; - int w = 0; - int h = 0; - - get_image_geometry (image, w, h, x, y); if (!(image.flags & IM_ROOT_ALIGN) && (x >= parent_width || y >= parent_height || x + w <= 0 || y + h <= 0)) - return false; + return; rxvt_img *img = image.img->scale (w, h); @@ -317,7 +308,7 @@ img->repeat_mode (RepeatNone); img->sub_rect (-x, -y, parent_width, parent_height)->replace (img); - if (bg_flags & BG_IS_VALID) + if (bg_img) img->draw (bg_img, PictOpOver, image.alpha * 1. / 0xffff); XRenderPictFormat *format = XRenderFindVisualFormat (dpy, visual); @@ -325,8 +316,6 @@ delete bg_img; bg_img = img; - - return true; } rxvt_image::rxvt_image () @@ -442,7 +431,7 @@ * the tiled portion of the root pixmap that is supposed to be covered by * our window. */ -bool +void rxvt_term::render_root_image () { /* root dimensions may change from call to call - but Display structure should @@ -458,13 +447,10 @@ sx = parent_x; sy = parent_y; - if (!root_img) - return false; - /* check if we are outside of the visible part of the virtual screen : */ if (sx + parent_width <= 0 || sy + parent_height <= 0 || sx >= root_width || sy >= root_height) - return 0; + return; while (sx < 0) sx += root_img->w; while (sy < 0) sy += root_img->h; @@ -482,15 +468,6 @@ delete bg_img; bg_img = img; - - return true; -} - -void -rxvt_term::bg_set_root_pixmap () -{ - delete root_img; - root_img = rxvt_img::new_from_root (this); } # endif /* BG_IMAGE_FROM_ROOT */ @@ -500,30 +477,26 @@ if (bg_flags & BG_INHIBIT_RENDER) return; - bg_invalidate (); + delete bg_img; + bg_img = 0; + bg_flags = 0; + + if (!mapped) + return; + # if BG_IMAGE_FROM_ROOT - if (option (Opt_transparent)) + if (root_img) { - /* we need to re-generate transparency pixmap in that case ! */ - if (render_root_image ()) - bg_flags |= BG_IS_VALID | BG_IS_TRANSPARENT; + render_root_image (); + bg_flags |= BG_IS_TRANSPARENT; } # endif # if BG_IMAGE_FROM_FILE if (fimage.img) - { - if (render_image (fimage)) - bg_flags |= BG_IS_VALID; - } + render_image (fimage); # endif - if (!(bg_flags & BG_IS_VALID)) - { - delete bg_img; - bg_img = 0; - } - scr_recolour (false); bg_flags |= BG_NEEDS_REFRESH; @@ -545,7 +518,7 @@ if (rs [Rs_shade]) root_effects.set_shade (rs [Rs_shade]); - bg_set_root_pixmap (); + rxvt_img::new_from_root (this)->replace (root_img); XSelectInput (dpy, display->root, PropertyChangeMask); rootwin_ev.start (display, display->root); }