--- rxvt-unicode/src/xpm.C 2003/11/24 17:31:28 1.2 +++ rxvt-unicode/src/xpm.C 2004/01/31 02:15:02 1.6 @@ -1,7 +1,7 @@ /*--------------------------------*-C-*---------------------------------* * File: xpm.c *----------------------------------------------------------------------* - * $Id: xpm.C,v 1.2 2003/11/24 17:31:28 pcg Exp $ + * $Id: xpm.C,v 1.6 2004/01/31 02:15:02 pcg Exp $ * * All portions of code are copyright by their respective author/s. * Copyright (c) 1997 Carsten Haitzler @@ -49,27 +49,26 @@ * And this GEOM string is for querying current scale/position: * @ `?' */ -/* EXTPROTO */ int -rxvt_scale_pixmap(pR_ const char *geom) +rxvt_term::scale_pixmap (const char *geom) { int flags, changed = 0; int x = 0, y = 0; unsigned int w = 0, h = 0; unsigned int n; char *p, *str; - bgPixmap_t *bgpixmap = &(R->h->bgPixmap); + bgPixmap_t *bgpixmap = &(bgPixmap); #define MAXLEN_GEOM sizeof("[1000x1000+1000+1000]") if (geom == NULL) return 0; - str = rxvt_malloc(MAXLEN_GEOM + 1); + str = (char *)rxvt_malloc (MAXLEN_GEOM + 1); 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)); - rxvt_xterm_seq(aR_ XTerm_title, str, CHAR_ST); + xterm_seq (XTerm_title, str, CHAR_ST); free(str); return 0; } @@ -143,34 +142,33 @@ return changed; } -/* EXTPROTO */ void -rxvt_resize_pixmap(pR) +rxvt_term::resize_pixmap () { XGCValues gcvalue; GC gc; unsigned int width = TermWin_TotalWidth(); unsigned int height = TermWin_TotalHeight(); - if (R->TermWin.pixmap != None) - XFreePixmap(R->Xdisplay, R->TermWin.pixmap); + if (TermWin.pixmap != None) + XFreePixmap(Xdisplay, TermWin.pixmap); - if (R->h->bgPixmap.pixmap == None) { /* So be it: I'm not using pixmaps */ - R->TermWin.pixmap = None; - if (!(R->Options & Opt_transparent) || R->h->am_transparent == 0) - XSetWindowBackground(R->Xdisplay, R->TermWin.vt, - R->PixColors[Color_bg]); + if (bgPixmap.pixmap == None) { /* So be it: I'm not using pixmaps */ + TermWin.pixmap = None; + if (!(Options & Opt_transparent) || am_transparent == 0) + XSetWindowBackground(Xdisplay, TermWin.vt, + PixColors[Color_bg]); return; } - gcvalue.foreground = R->PixColors[Color_bg]; - gc = XCreateGC(R->Xdisplay, R->TermWin.vt, GCForeground, &gcvalue); + gcvalue.foreground = PixColors[Color_bg]; + gc = XCreateGC(Xdisplay, TermWin.vt, GCForeground, &gcvalue); - if (R->h->bgPixmap.pixmap != None) { /* we have a specified pixmap */ - unsigned int w = R->h->bgPixmap.w, h = R->h->bgPixmap.h, - x = R->h->bgPixmap.x, y = R->h->bgPixmap.y; - unsigned int xpmh = R->h->xpmAttr.height, - xpmw = R->h->xpmAttr.width; + if (bgPixmap.pixmap != None) { /* we have a specified pixmap */ + unsigned int w = bgPixmap.w, h = bgPixmap.h, + x = bgPixmap.x, y = bgPixmap.y; + unsigned int xpmh = xpmAttr.height, + xpmw = xpmAttr.width; /* * don't zoom pixmap too much nor expand really small pixmaps @@ -183,16 +181,16 @@ if (w == 0) { /* basic X tiling - let the X server do it */ - R->TermWin.pixmap = XCreatePixmap(R->Xdisplay, R->TermWin.vt, + TermWin.pixmap = XCreatePixmap(Xdisplay, TermWin.vt, xpmw, xpmh, (unsigned int)XDEPTH); - XCopyArea(R->Xdisplay, R->h->bgPixmap.pixmap, R->TermWin.pixmap, gc, + XCopyArea(Xdisplay, bgPixmap.pixmap, TermWin.pixmap, gc, 0, 0, xpmw, xpmh, 0, 0); } else { float incr, p; Pixmap tmp; - R->TermWin.pixmap = XCreatePixmap(R->Xdisplay, R->TermWin.vt, + TermWin.pixmap = XCreatePixmap(Xdisplay, TermWin.vt, width, height, (unsigned int)XDEPTH); /* @@ -200,16 +198,16 @@ */ rxvt_pixmap_incr(&w, &x, &incr, &p, width, xpmw); - tmp = XCreatePixmap(R->Xdisplay, R->TermWin.vt, + tmp = XCreatePixmap(Xdisplay, TermWin.vt, width, xpmh, (unsigned int)XDEPTH); - XFillRectangle(R->Xdisplay, tmp, gc, 0, 0, width, + XFillRectangle(Xdisplay, tmp, gc, 0, 0, width, xpmh); for ( /*nil */ ; x < w; x++, p += incr) { if (p >= xpmw) p = 0; /* copy one column from the original pixmap to the tmp pixmap */ - XCopyArea(R->Xdisplay, R->h->bgPixmap.pixmap, tmp, gc, + XCopyArea(Xdisplay, bgPixmap.pixmap, tmp, gc, (int)p, 0, 1, xpmh, (int)x, 0); } @@ -219,28 +217,28 @@ rxvt_pixmap_incr(&h, &y, &incr, &p, height, xpmh); if (y > 0) - XFillRectangle(R->Xdisplay, R->TermWin.pixmap, gc, 0, 0, width, + XFillRectangle(Xdisplay, TermWin.pixmap, gc, 0, 0, width, y); if (h < height) - XFillRectangle(R->Xdisplay, R->TermWin.pixmap, gc, 0, (int)h, + XFillRectangle(Xdisplay, 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(R->Xdisplay, tmp, R->TermWin.pixmap, gc, + XCopyArea(Xdisplay, tmp, TermWin.pixmap, gc, 0, (int)p, width, 1, 0, (int)y); } - XFreePixmap(R->Xdisplay, tmp); + XFreePixmap(Xdisplay, tmp); } } - XSetWindowBackgroundPixmap(R->Xdisplay, R->TermWin.vt, R->TermWin.pixmap); - XFreeGC(R->Xdisplay, gc); - R->h->am_transparent = 0; + XSetWindowBackgroundPixmap(Xdisplay, TermWin.vt, TermWin.pixmap); + XFreeGC(Xdisplay, gc); + am_transparent = 0; - XClearWindow(R->Xdisplay, R->TermWin.vt); + XClearWindow(Xdisplay, TermWin.vt); - XSync(R->Xdisplay, False); + XSync(Xdisplay, False); } /* @@ -248,7 +246,7 @@ * At start, p == 0, incr == xpmwidthheight */ /* INTPROTO */ -void +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; @@ -284,7 +282,7 @@ if (pos <= 0) cxy = 0; else if (pos < cxy) - cxy = pos; + cxy = (int) pos; cwh += cxy; } else { /* expand */ if (cxy > 0) { /* position */ @@ -308,19 +306,18 @@ *p = cp; } -/* EXTPROTO */ Pixmap -rxvt_set_bgPixmap(pR_ const char *file) +rxvt_term::set_bgPixmap (const char *file) { char *f; assert(file != NULL); - if (R->h->bgPixmap.pixmap != None) { - XFreePixmap(R->Xdisplay, R->h->bgPixmap.pixmap); - R->h->bgPixmap.pixmap = None; + if (bgPixmap.pixmap != None) { + XFreePixmap(Xdisplay, bgPixmap.pixmap); + bgPixmap.pixmap = None; } - XSetWindowBackground(R->Xdisplay, R->TermWin.vt, R->PixColors[Color_bg]); + XSetWindowBackground(Xdisplay, TermWin.vt, PixColors[Color_bg]); if (*file != '\0') { /* XWindowAttributes attr; */ @@ -328,21 +325,21 @@ /* * we already have the required attributes */ -/* XGetWindowAttributes(R->Xdisplay, R->TermWin.vt, &attr); */ +/* XGetWindowAttributes(Xdisplay, TermWin.vt, &attr); */ - R->h->xpmAttr.closeness = 30000; - R->h->xpmAttr.colormap = XCMAP; - R->h->xpmAttr.visual = XVISUAL; - R->h->xpmAttr.depth = XDEPTH; - R->h->xpmAttr.valuemask = (XpmCloseness | XpmColormap | XpmVisual | + xpmAttr.closeness = 30000; + xpmAttr.colormap = XCMAP; + xpmAttr.visual = XVISUAL; + xpmAttr.depth = XDEPTH; + xpmAttr.valuemask = (XpmCloseness | XpmColormap | XpmVisual | XpmDepth | XpmSize | XpmReturnPixels); /* search environment variables here too */ - f = (char *)rxvt_File_find(file, ".xpm", R->h->rs[Rs_path]); + f = (char *)rxvt_File_find(file, ".xpm", rs[Rs_path]); if (f == NULL - || XpmReadFileToPixmap(R->Xdisplay, Xroot, f, - &R->h->bgPixmap.pixmap, NULL, - &R->h->xpmAttr)) { + || XpmReadFileToPixmap(Xdisplay, Xroot, f, + &bgPixmap.pixmap, NULL, + &xpmAttr)) { char *p; /* semi-colon delimited */ @@ -354,8 +351,8 @@ } free(f); } - rxvt_resize_pixmap(aR); - return R->h->bgPixmap.pixmap; + resize_pixmap (); + return bgPixmap.pixmap; } #endif /* XPM_BACKGROUND */