--- rxvt-unicode/src/xpm.C 2007/06/20 13:46:25 1.40 +++ rxvt-unicode/src/xpm.C 2007/06/30 23:34:57 1.44 @@ -28,7 +28,81 @@ #ifdef XPM_BACKGROUND -static void rxvt_pixmap_incr (unsigned int *wh, unsigned int *xy, float *incr, float *p, unsigned int widthheight, unsigned int xpmwidthheight); +/* + * Calculate tiling sizes and increments + * At start, p == 0, incr == xpmwidthheight + */ +static void +rxvt_pixmap_incr (unsigned int *wh, unsigned int *xy, float *incr, float *p, unsigned int widthheight, unsigned int xpmwidthheight) +{ + unsigned int cwh, cxy; + float cincr, cp; + + cp = 0; + cincr = (float)xpmwidthheight; + cxy = *xy; + cwh = *wh; + if (cwh == 1) + { /* display one image, no horizontal/vertical scaling */ + cincr = (float)widthheight; + if (xpmwidthheight <= widthheight) + { + cwh = xpmwidthheight; + cxy = (cxy * (widthheight - cwh)) / 100; /* beware! order */ + cwh += cxy; + } + else + { + cxy = 0; + cwh = widthheight; + } + } + else if (cwh < 10) + { /* fit WH images across/down screen */ + cincr *= cwh; + cxy = 0; + cwh = widthheight; + } + else + { + cincr *= 100.0 / cwh; + if (cwh < 100) + { /* contract */ + float pos; + + cwh = (cwh * widthheight) / 100; + pos = (float)cxy / 100 * widthheight - (cwh / 2); + + cxy = (widthheight - cwh); + if (pos <= 0) + cxy = 0; + else if (pos < cxy) + cxy = (int) pos; + cwh += cxy; + } + else + { /* expand */ + if (cxy > 0) + { /* position */ + float pos; + + pos = (float)cxy / 100 * xpmwidthheight - (cincr / 2); + cp = xpmwidthheight - cincr; + if (pos <= 0) + cp = 0; + else if (pos < cp) + cp = pos; + } + cxy = 0; + cwh = widthheight; + } + } + cincr /= widthheight; + *wh = cwh; + *xy = cxy; + *incr = cincr; + *p = cp; +} /* * These GEOM strings indicate absolute size/position: @@ -193,7 +267,7 @@ { /* So be it: I'm not using pixmaps */ pixmap = None; -#ifdef TRANSPARENT +#ifdef ENABLE_TRANSPARENCY if (!option (Opt_transparent) || !am_transparent) #endif XSetWindowBackground (dpy, vt, pix_colors[Color_bg]); @@ -237,7 +311,7 @@ } else #ifdef HAVE_AFTERIMAGE -#ifdef TRANSPARENT +#ifdef ENABLE_TRANSPARENCY if (!option(Opt_transparent) || !am_transparent) /* will do that in check_our_parents otherwise */ #endif @@ -300,87 +374,11 @@ XSetWindowBackgroundPixmap (dpy, vt, pixmap); XFreeGC (dpy, gc); -#ifdef TRANSPARENT +#ifdef ENABLE_TRANSPARENCY am_transparent = 0; #endif } -/* - * Calculate tiling sizes and increments - * At start, p == 0, incr == xpmwidthheight - */ -static void -rxvt_pixmap_incr (unsigned int *wh, unsigned int *xy, float *incr, float *p, unsigned int widthheight, unsigned int xpmwidthheight) -{ - unsigned int cwh, cxy; - float cincr, cp; - - cp = 0; - cincr = (float)xpmwidthheight; - cxy = *xy; - cwh = *wh; - if (cwh == 1) - { /* display one image, no horizontal/vertical scaling */ - cincr = (float)widthheight; - if (xpmwidthheight <= widthheight) - { - cwh = xpmwidthheight; - cxy = (cxy * (widthheight - cwh)) / 100; /* beware! order */ - cwh += cxy; - } - else - { - cxy = 0; - cwh = widthheight; - } - } - else if (cwh < 10) - { /* fit WH images across/down screen */ - cincr *= cwh; - cxy = 0; - cwh = widthheight; - } - else - { - cincr *= 100.0 / cwh; - if (cwh < 100) - { /* contract */ - float pos; - - cwh = (cwh * widthheight) / 100; - pos = (float)cxy / 100 * widthheight - (cwh / 2); - - cxy = (widthheight - cwh); - if (pos <= 0) - cxy = 0; - else if (pos < cxy) - cxy = (int) pos; - cwh += cxy; - } - else - { /* expand */ - if (cxy > 0) - { /* position */ - float pos; - - pos = (float)cxy / 100 * xpmwidthheight - (cincr / 2); - cp = xpmwidthheight - cincr; - if (pos <= 0) - cp = 0; - else if (pos < cp) - cp = pos; - } - cxy = 0; - cwh = widthheight; - } - } - cincr /= widthheight; - *wh = cwh; - *xy = cxy; - *incr = cincr; - *p = cp; -} - Pixmap rxvt_term::set_bgPixmap (const char *file) { @@ -412,7 +410,10 @@ original_asim = get_asimage( asimman, file, 0xFFFFFFFF, 100 ); else { - f = strndup( file, f - file ); + size_t len = f - file; + f = (char *)malloc (len + 1); + strncpy (f, file, len); + f[len] = '\0'; original_asim = get_asimage( asimman, f, 0xFFFFFFFF, 100 ); free( f ); } @@ -455,13 +456,14 @@ #endif /* XPM_BACKGROUND */ -#ifdef TRANSPARENT +#ifdef ENABLE_TRANSPARENCY #if TINTING && !defined(HAVE_AFTERIMAGE) /* taken from aterm-0.4.2 */ typedef uint32_t RUINT32T; -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) { int sh_r, sh_g, sh_b; RUINT32T mask_r, mask_g, mask_b;