--- rxvt-unicode/src/background.C 2010/10/13 23:04:57 1.80 +++ rxvt-unicode/src/background.C 2010/10/16 20:25:06 1.84 @@ -5,6 +5,7 @@ * All portions of code are copyright by their respective author/s. * Copyright (c) 2005-2008 Marc Lehmann * Copyright (c) 2007 Sasha Vasko + * Copyright (c) 2010 Emanuele Giaquinta * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -177,17 +178,6 @@ if (original_asim) return true; # endif -# ifdef ENABLE_TRANSPARENCY - if (flags & isTransparent) - { -# ifdef HAVE_AFTERIMAGE - if ((flags & blurNeeded) && !(flags & blurServerSide)) - return true; -# endif - if ((flags & tintNeeded) && !(flags & tintServerSide)) - return true; - } -# endif return false; } @@ -943,17 +933,27 @@ # ifdef HAVE_AFTERIMAGE if (!target->asimman) target->asimman = create_generic_imageman (target->rs[Rs_path]); - original_asim = get_asimage (target->asimman, file, 0xFFFFFFFF, 100); - if (original_asim) - have_image = true; - return have_image; + ASImage *image = get_asimage (target->asimman, file, 0xFFFFFFFF, 100); + if (image) + { + if (original_asim) + safe_asimage_destroy (original_asim); + original_asim = image; + have_image = true; + return true; + } # endif # ifdef HAVE_PIXBUF - pixbuf = gdk_pixbuf_new_from_file (file, NULL); - if (pixbuf) - have_image = true; - return have_image; + GdkPixbuf *image = gdk_pixbuf_new_from_file (file, NULL); + if (image) + { + if (pixbuf) + g_object_unref (pixbuf); + pixbuf = image; + have_image = true; + return true; + } # endif } @@ -1115,6 +1115,7 @@ return false; } +#if XFT static void get_gaussian_kernel (int radius, int width, double *kernel, XFixed *params) { @@ -1135,6 +1136,7 @@ for (int i = 0; i < width; i++) params[i+2] = XDoubleToFixed (kernel[i] / sum); } +#endif bool bgPixmap_t::blur_pixmap (Pixmap pixmap, Visual *visual, int width, int height) @@ -1318,6 +1320,7 @@ int window_height = target->szHint.height; int sx, sy; XGCValues gcv; + GC gc; TIMING_TEST_START (tp); target->get_window_origin (sx, sy); @@ -1341,85 +1344,30 @@ target->allowedxerror = 0; } + if (root_pixmap == None) + return 0; + Pixmap tiled_root_pmap = XCreatePixmap (dpy, root, window_width, window_height, root_depth); - GC gc = NULL; if (tiled_root_pmap == None) /* something really bad happened - abort */ return 0; - if (root_pixmap == None) - { - /* use tricks to obtain the root background image :*/ - /* we want to create Overrideredirect window overlapping out window - with background type of Parent Relative and then grab it */ - XSetWindowAttributes attr; - Window src; - bool success = false; - - attr.background_pixmap = ParentRelative; - attr.backing_store = Always; - attr.event_mask = ExposureMask; - attr.override_redirect = True; - src = XCreateWindow (dpy, root, sx, sy, window_width, window_height, 0, - CopyFromParent, CopyFromParent, CopyFromParent, - CWBackPixmap|CWBackingStore|CWOverrideRedirect|CWEventMask, - &attr); - - if (src != None) - { - XEvent event; - int ev_count = 0; - XGrabServer (dpy); - XMapRaised (dpy, src); - XSync (dpy, False); - - /* XSync should get window where it's properly exposed, - * but to be on the safe side - let's check for the actual event to arrive : */ - while (XCheckWindowEvent (dpy, src, ExposureMask, &event)) - ++ev_count; - - if (ev_count > 0); - { - /* hooray! - we can grab the image! */ - gc = XCreateGC (dpy, root, 0, NULL); - if (gc) - { - XCopyArea (dpy, src, tiled_root_pmap, gc, 0, 0, window_width, window_height, 0, 0); - success = true; - } - } - - XDestroyWindow (dpy, src); - XUngrabServer (dpy); - //fprintf (stderr, "%s:%d: ev_count = %d\n", __FUNCTION__, __LINE__, ev_count); - } + /* straightforward pixmap copy */ + gcv.tile = root_pixmap; + gcv.fill_style = FillTiled; + + while (sx < 0) sx += (int)root_width; + while (sy < 0) sy += (int)root_height; + + gcv.ts_x_origin = -sx; + gcv.ts_y_origin = -sy; + gc = XCreateGC (dpy, root, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv); - if (!success) - { - XFreePixmap (dpy, tiled_root_pmap); - tiled_root_pmap = None; - } - else - result |= transpPmapTiled; - } - else + if (gc) { - /* straightforward pixmap copy */ - gcv.tile = root_pixmap; - gcv.fill_style = FillTiled; - - while (sx < 0) sx += (int)root_width; - while (sy < 0) sy += (int)root_height; - - gcv.ts_x_origin = -sx; - gcv.ts_y_origin = -sy; - gc = XCreateGC (dpy, root, GCFillStyle | GCTile | GCTileStipXOrigin | GCTileStipYOrigin, &gcv); - - if (gc) - { - XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height); - result |= transpPmapTiled; - } + XFillRectangle (dpy, tiled_root_pmap, gc, 0, 0, window_width, window_height); + result |= transpPmapTiled; + XFreeGC (dpy, gc); } TIMING_TEST_PRINT_RESULT (tp); @@ -1427,12 +1375,12 @@ { if (!need_client_side_rendering ()) { - if ((flags & blurNeeded)) + if (flags & (blurNeeded | blurServerSide)) { if (blur_pixmap (tiled_root_pmap, DefaultVisual (dpy, target->display->screen), window_width, window_height)) result |= transpPmapBlurred; } - if ((flags & tintNeeded)) + if (flags & (tintNeeded | tintServerSide)) { if (tint_pixmap (tiled_root_pmap, DefaultVisual (dpy, target->display->screen), window_width, window_height)) result |= transpPmapTinted; @@ -1448,9 +1396,6 @@ pmap_depth = root_depth; } - if (gc) - XFreeGC (dpy, gc); - TIMING_TEST_PRINT_RESULT (tp); return result;