--- rxvt-unicode/src/background.C 2008/01/29 17:52:52 1.29 +++ rxvt-unicode/src/background.C 2010/08/29 13:40:42 1.43 @@ -3,7 +3,7 @@ *----------------------------------------------------------------------* * * All portions of code are copyright by their respective author/s. - * Copyright (c) 2005-2006 Marc Lehmann + * Copyright (c) 2005-2008 Marc Lehmann * Copyright (c) 2007 Sasha Vasko * * This program is free software; you can redistribute it and/or modify @@ -29,17 +29,21 @@ #if DO_TIMING_TEST # include #define TIMING_TEST_START(id) \ - struct timeval timing_test_##id##_stv;\ + struct timeval timing_test_##id##_stv; \ gettimeofday (&timing_test_##id##_stv, NULL); #define TIMING_TEST_PRINT_RESULT(id) \ - do{ struct timeval tv;gettimeofday (&tv, NULL); tv.tv_sec -= (timing_test_##id##_stv).tv_sec;\ - fprintf (stderr, "%s: %s: %d: elapsed %ld usec\n", #id, __FILE__, __LINE__,\ - tv.tv_sec * 1000000 + tv.tv_usec - (timing_test_##id##_stv).tv_usec);}while (0) + do { \ + struct timeval tv; \ + gettimeofday (&tv, NULL); \ + tv.tv_sec -= (timing_test_##id##_stv).tv_sec; \ + fprintf (stderr, "%s: %s: %d: elapsed %ld usec\n", #id, __FILE__, __LINE__, \ + tv.tv_sec * 1000000 + tv.tv_usec - (timing_test_##id##_stv).tv_usec); \ + } while (0) #else -#define TIMING_TEST_START(id) do{}while (0) -#define TIMING_TEST_PRINT_RESULT(id) do{}while (0) +#define TIMING_TEST_START(id) do {} while (0) +#define TIMING_TEST_PRINT_RESULT(id) do {} while (0) #endif /* @@ -48,7 +52,7 @@ * adjustment and may optionally be followed by a colon and one or more * colon-delimited pixmap operations. * The following table shows the valid geometry strings and their - * affects on the background image : + * effects on the background image : * * WxH+X+Y Set scaling to W% by H%, and position to X% by Y%. * W and H are percentages of the terminal window size. @@ -138,8 +142,8 @@ return false; } -bool -bgPixmap_t::window_position_sensitive () +bool +bgPixmap_t::window_position_sensitive () { # ifdef ENABLE_TRANSPARENCY if (flags & isTransparent) @@ -261,7 +265,7 @@ unsigned int w = 0, h = 0; unsigned int n; unsigned long new_flags = (flags & (~geometryFlags)); - char *p; + const char *p; # define MAXLEN_GEOM 256 /* could be longer than regular geometry string */ if (geom == NULL) @@ -451,10 +455,14 @@ if (target == NULL) return false; - int target_width = (int)target->szHint.width; - int target_height = (int)target->szHint.height; - int new_pmap_width = target_width, new_pmap_height = target_height; - ASImage *result = NULL; + target->init_asv (); + + ASImage *result = 0; + + int target_width = target->szHint.width; + int target_height = target->szHint.height; + int new_pmap_width = target_width; + int new_pmap_height = target_height; int x = 0; int y = 0; @@ -493,7 +501,7 @@ if (background_tint != TINT_LEAVE_SAME) { - ASImage* tmp = tile_asimage (target->asv, background, 0, 0, + ASImage *tmp = tile_asimage (target->asv, background, 0, 0, target_width, target_height, background_tint, ASA_XImage, 100, ASIMAGE_QUALITY_DEFAULT); if (tmp) @@ -531,7 +539,7 @@ ASImage *tmp = tile_asimage (target->asv, result, (h_scale > 0) ? 0 : (int)result->width - x, (v_scale > 0) ? 0 : (int)result->height - y, - new_pmap_width, + new_pmap_width, new_pmap_height, TINT_LEAVE_SAME, ASA_XImage, 100, ASIMAGE_QUALITY_DEFAULT); @@ -548,7 +556,6 @@ { /* if blending background and image - pixmap has to be sized same as target window */ ASImageLayer *layers = create_image_layers (2); - ASImage *merged_im = NULL; layers[0].im = background; layers[0].clip_width = target_width; @@ -665,27 +672,24 @@ bool bgPixmap_t::set_file (const char *file) { - char *f; - assert (file); if (*file) { # ifdef HAVE_AFTERIMAGE - if (target->asimman == NULL) + if (!target->asimman) target->asimman = create_generic_imageman (target->rs[Rs_path]); - if ((f = strchr (file, ';')) == NULL) - original_asim = get_asimage (target->asimman, file, 0xFFFFFFFF, 100); - else + if (const char *p = strchr (file, ';')) { - size_t len = f - file; - f = (char *)malloc (len + 1); + size_t len = p - file; + char *f = rxvt_temp_buf (len + 1); memcpy (f, file, len); f[len] = '\0'; original_asim = get_asimage (target->asimman, f, 0xFFFFFFFF, 100); - free (f); } + else + original_asim = get_asimage (target->asimman, file, 0xFFFFFFFF, 100); return original_asim; # endif @@ -848,7 +852,7 @@ if (target == NULL) return 0; - /* root dimentions may change from call to call - but Display structure should + /* root dimensions may change from call to call - but Display structure should * be always up-to-date, so let's use it : */ Window root = target->display->root; @@ -947,7 +951,7 @@ } else { - /* strightforward pixmap copy */ + /* straightforward pixmap copy */ gcv.tile = root_pixmap; gcv.fill_style = FillTiled; @@ -1108,7 +1112,7 @@ # endif /* ENABLE_TRANSPARENCY */ # ifndef HAVE_AFTERIMAGE -static void ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm); +static void ShadeXImage(rxvt_term *term, XImage *srcImage, int shade, int rm, int gm, int bm); # endif bool @@ -1121,7 +1125,7 @@ TIMING_TEST_START (tp); - invalidate(); + invalidate (); # ifdef ENABLE_TRANSPARENCY if (flags & isTransparent) { @@ -1140,10 +1144,12 @@ if (original_asim || (background_flags & transpTransformations) != (flags & transpTransformations)) { + target->init_asv (); + ASImage *background = NULL; ARGB32 as_tint = TINT_LEAVE_SAME; if (background_flags) - background = pixmap2ximage (target->asv, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, 100); + background = pixmap2ximage (target->asv, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, 100); # ifdef ENABLE_TRANSPARENCY if (!(background_flags & transpPmapTinted) && (flags & tintNeeded)) @@ -1160,9 +1166,10 @@ as_tint = shading2tint32 (&as_shade); } + if (!(background_flags & transpPmapBlured) && (flags & blurNeeded) && background != NULL) { - ASImage* tmp = blur_asimage_gauss (target->asv, background, h_blurRadius, v_blurRadius, 0xFFFFFFFF, + ASImage *tmp = blur_asimage_gauss (target->asv, background, h_blurRadius, v_blurRadius, 0xFFFFFFFF, (original_asim == NULL || tint == TINT_LEAVE_SAME)?ASA_XImage:ASA_ASImage, 100, ASIMAGE_QUALITY_DEFAULT); if (tmp) @@ -1176,21 +1183,20 @@ if (render_asim (background, as_tint)) flags = flags & ~isInvalid; if (background) - destroy_asimage (&background); + destroy_asimage (&background); } else if (background_flags && pmap_depth != target->depth) - { - result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); - } + result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); # elif !XFT /* our own client-side tinting */ - /* ATTENTION: We ASSUME that XFT will let us do all the tinting neccessary server-side. + /* ATTENTION: We ASSUME that XFT will let us do all the tinting necessary server-side. This may need to be changed in need_client_side_rendering() logic is altered !!! */ if (background_flags && (flags & isInvalid)) { result = XGetImage (target->dpy, pixmap, 0, 0, pmap_width, pmap_height, AllPlanes, ZPixmap); + if (result != NULL && !(background_flags & transpPmapTinted) && (flags & tintNeeded)) { rgba c (rgba::MAX_CC,rgba::MAX_CC,rgba::MAX_CC); @@ -1275,6 +1281,7 @@ # endif return true; } + return false; } @@ -1324,10 +1331,10 @@ scr_touch or we get a great deal of flicker otherwise: */ XClearWindow (target->dpy, target->parent[0]); - if (target->scrollBar.win) + if (target->scrollBar.state && target->scrollBar.win) { target->scrollBar.state = STATE_IDLE; - target->scrollbar_show (0); + target->scrollBar.show (0); } target->want_refresh = 1; @@ -1343,7 +1350,7 @@ typedef uint32_t RUINT32T; static void -ShadeXImage(rxvt_term *term, XImage* srcImage, int shade, int rm, int gm, int bm) +ShadeXImage(rxvt_term *term, XImage *srcImage, int shade, int rm, int gm, int bm) { int sh_r, sh_g, sh_b; RUINT32T mask_r, mask_g, mask_b;