--- rxvt-unicode/src/xpm.C 2004/03/17 03:47:14 1.10 +++ rxvt-unicode/src/xpm.C 2005/01/26 07:08:15 1.20 @@ -1,7 +1,6 @@ /*--------------------------------*-C-*---------------------------------* - * File: xpm.c + * File: xpm.C *----------------------------------------------------------------------* - * $Id: xpm.C,v 1.10 2004/03/17 03:47:14 pcg Exp $ * * All portions of code are copyright by their respective author/s. * Copyright (c) 1997 Carsten Haitzler @@ -64,22 +63,22 @@ if (geom == NULL) return 0; str = (char *)rxvt_malloc (MAXLEN_GEOM + 1); - if (!STRCMP (geom, "?")) + if (!strcmp (geom, "?")) { sprintf (str, "[%dx%d+%d+%d]", /* can't presume snprintf () ! */ min (bgpixmap->w, 9999), min (bgpixmap->h, 9999), min (bgpixmap->x, 9999), min (bgpixmap->y, 9999)); - xterm_seq (XTerm_title, str, CHAR_ST); + process_xterm_seq (XTerm_title, str, CHAR_ST); free (str); return 0; } - if ((p = STRCHR (geom, ';')) == NULL) - p = STRCHR (geom, '\0'); + if ((p = strchr (geom, ';')) == NULL) + p = strchr (geom, '\0'); n = (p - geom); if (n <= MAXLEN_GEOM) { - STRNCPY (str, geom, n); + strncpy (str, geom, n); str[n] = '\0'; flags = XParseGeometry (str, &x, &y, &w, &h); @@ -171,21 +170,23 @@ if (bgPixmap.pixmap == None) { /* So be it: I'm not using pixmaps */ TermWin.pixmap = None; - if (! (Options & Opt_transparent) || am_transparent == 0) + + if (!(options & Opt_transparent) || !am_transparent) XSetWindowBackground (display->display, TermWin.vt, - PixColors[Color_bg]); + pix_colors[Color_bg]); + return; } - gcvalue.foreground = PixColors[Color_bg]; + gcvalue.foreground = pix_colors[Color_bg]; gc = XCreateGC (display->display, TermWin.vt, GCForeground, &gcvalue); if (bgPixmap.pixmap != None) { /* we have a specified pixmap */ unsigned int w = bgPixmap.w, h = bgPixmap.h, - x = bgPixmap.x, y = bgPixmap.y; + x = bgPixmap.x, y = bgPixmap.y; unsigned int xpmh = xpmAttr.height, - xpmw = xpmAttr.width; + xpmw = xpmAttr.width; /* * don't zoom pixmap too much nor expand really small pixmaps @@ -201,7 +202,7 @@ /* basic X tiling - let the X server do it */ TermWin.pixmap = XCreatePixmap (display->display, TermWin.vt, xpmw, xpmh, - (unsigned int)XDEPTH); + (unsigned int)display->depth); XCopyArea (display->display, bgPixmap.pixmap, TermWin.pixmap, gc, 0, 0, xpmw, xpmh, 0, 0); } @@ -212,14 +213,14 @@ TermWin.pixmap = XCreatePixmap (display->display, TermWin.vt, width, height, - (unsigned int)XDEPTH); + (unsigned int)display->depth); /* * horizontal scaling */ rxvt_pixmap_incr (&w, &x, &incr, &p, width, xpmw); tmp = XCreatePixmap (display->display, TermWin.vt, - width, xpmh, (unsigned int)XDEPTH); + width, xpmh, (unsigned int)display->depth); XFillRectangle (display->display, tmp, gc, 0, 0, width, xpmh); @@ -238,29 +239,28 @@ rxvt_pixmap_incr (&h, &y, &incr, &p, height, xpmh); if (y > 0) - XFillRectangle (display->display, TermWin.pixmap, gc, 0, 0, width, - y); + XFillRectangle (display->display, TermWin.pixmap, gc, 0, 0, width, y); + if (h < height) - XFillRectangle (display->display, TermWin.pixmap, gc, 0, (int)h, - width, height - h + 1); + XFillRectangle (display->display, TermWin.pixmap, gc, 0, (int)h, width, height - h + 1); + for ( /*nil */ ; y < h; y++, p += incr) { if (p >= xpmh) p = 0; + /* copy one row from the tmp pixmap to the main pixmap */ XCopyArea (display->display, tmp, TermWin.pixmap, gc, 0, (int)p, width, 1, 0, (int)y); } + XFreePixmap (display->display, tmp); } } + XSetWindowBackgroundPixmap (display->display, TermWin.vt, TermWin.pixmap); XFreeGC (display->display, gc); am_transparent = 0; - - XClearWindow (display->display, TermWin.vt); - - XSync (display->display, False); } /* @@ -352,7 +352,8 @@ XFreePixmap (display->display, bgPixmap.pixmap); bgPixmap.pixmap = None; } - XSetWindowBackground (display->display, TermWin.vt, PixColors[Color_bg]); + + XSetWindowBackground (display->display, TermWin.vt, pix_colors[Color_bg]); if (*file != '\0') { @@ -364,9 +365,9 @@ /* XGetWindowAttributes (display->display, TermWin.vt, &attr); */ xpmAttr.closeness = 30000; - xpmAttr.colormap = XCMAP; - xpmAttr.visual = XVISUAL; - xpmAttr.depth = XDEPTH; + xpmAttr.colormap = display->cmap; + xpmAttr.visual = display->visual; + xpmAttr.depth = display->depth; xpmAttr.valuemask = (XpmCloseness | XpmColormap | XpmVisual | XpmDepth | XpmSize | XpmReturnPixels); @@ -380,10 +381,10 @@ char *p; /* semi-colon delimited */ - if ((p = STRCHR (file, ';')) == NULL) - p = STRCHR (file, '\0'); + if ((p = strchr (file, ';')) == NULL) + p = strchr (file, '\0'); - rxvt_warn ("couldn't load XPM file \"%.*s\", ignoring.", (p - file), file); + rxvt_warn ("couldn't load XPM file \"%.*s\", ignoring.\n", (p - file), file); } free (f);