/* Draw all roaches. */ void DrawRoaches(void) { Roach *roach; int rx; for (rx=0; rx<curRoaches; rx++) { roach = &roaches[rx]; if (roach->intX >= 0) { GrClearArea(GR_ROOT_WINDOW_ID, roach->intX, roach->intY, roach->rp->width, roach->rp->height, GR_FALSE); } } for (rx=0; rx<curRoaches; rx++) { roach = &roaches[rx]; if (!roach->hidden) { int size = roach->rp->width * roach->rp->height; GR_PIXELVAL roachbuf[size]; GR_PIXELVAL screenbuf[size]; int i; roach->intX = roach->x; roach->intY = roach->y; roach->rp = &roachPix[roach->index]; /* //XSetForeground(display, gc, AllocNamedColor(roachColor, black)); //XSetFillStyle(display, gc, FillStippled); //XSetStipple(display, gc, roach->rp->pixmap); //XSetTSOrigin(display, gc, roach->intX, roach->intY); //XFillRectangle(display, rootWin, gc, //roach->intX, roach->intY, roach->rp->width, roach->rp->height); */ /* read roach bitmap*/ GrReadArea(roach->rp->pixmap, 0, 0, roach->rp->width, roach->rp->height, roachbuf); /* read root window*/ GrReadArea(GR_ROOT_WINDOW_ID, roach->intX, roach->intY, roach->rp->width, roach->rp->height, screenbuf); /* convert fg roach bitmap bits to roach color on root window bits*/ for (i=0; i<size; ++i) if (roachbuf[i] != BLACK) screenbuf[i] = roachColor; /* write root window*/ GrArea(GR_ROOT_WINDOW_ID, gc, roach->intX, roach->intY, roach->rp->width, roach->rp->height, screenbuf, MWPF_PIXELVAL); } else { roach->intX = -1; } } GrFlush(); }
int mvpw_read_area(mvp_widget_t *widget, int x, int y, int w, int h, uint32_t *pixels) { if ((widget == NULL) || (pixels == NULL)) return -1; if ((x < 0) || (x >= widget->width)) return -1; if ((y < 0) || (y >= widget->height)) return -1; if ((w < 0) || (w > widget->width)) return -1; if ((h < 0) || (h > widget->height)) return -1; GrReadArea(widget->wid, x, y, w, h, pixels); return 0; }
/* FIXME: fails with size > 64k if sizeof(int) == 2*/ static void GrReadAreaWrapper(void *r) { nxReadAreaReq *req = r; int size; GR_PIXELVAL * area; /* FIXME: optimize for smaller pixelvals*/ size = req->width * req->height * sizeof(GR_PIXELVAL); if(!(area = malloc(size))) { /*GsPutCh(current_fd, GrRetENoMem);*/ /* FIXME*/ /*return;*/ } GrReadArea(req->drawid, req->x, req->y, req->width, req->height, area); GsWriteType(current_fd,GrNumReadArea); GsWrite(current_fd, area, size); free(area); }
/* * Here when a button is pressed. */ void do_buttondown(GR_EVENT_BUTTON *bp) { GR_PIXELVAL intable[W2_WIDTH * W2_HEIGHT]; GR_PIXELVAL outtable[W2_WIDTH * W2_HEIGHT * 6]; GR_PIXELVAL *inp; GR_PIXELVAL *outp; GR_PIXELVAL *oldinp; GR_COORD row; GR_COORD col; /*static int xx = 100; static int yy = 50;*/ if (bp->wid == w3) { GrRaiseWindow(w3); GrReadArea(w2, 0, 0, W2_WIDTH, W2_HEIGHT, intable); inp = intable; outp = outtable; for (row = 0; row < W2_HEIGHT; row++) { oldinp = inp; for (col = 0; col < W2_WIDTH; col++) { *outp++ = *inp; *outp++ = *inp++; } inp = oldinp; for (col = 0; col < W2_WIDTH; col++) { *outp++ = *inp; *outp++ = *inp++; } inp = oldinp; for (col = 0; col < W2_WIDTH; col++) { *outp++ = *inp; *outp++ = *inp++; } } GrArea(w1, gc1, 0, 0, W2_WIDTH * 2, W2_HEIGHT * 3, outtable, MWPF_PIXELVAL); return; } if (bp->wid == w4) { GrRaiseWindow(w4); linexpos = bp->x; lineypos = bp->y; xorxpos = bp->x; xorypos = bp->y; GrLine(w4, gc4, xorxpos, xorypos, linexpos, lineypos); lineok = GR_TRUE; return; } if (bp->wid != w1) { /* * Cause a fatal error for testing if more than one * button is pressed. */ if ((bp->buttons & -((int) bp->buttons)) != bp->buttons) GrClearWindow(-1, 0); return; } GrRaiseWindow(w1); /*GrMoveWindow(w1, ++xx, yy);*/ if (bp->buttons & GR_BUTTON_L) { GrClearWindow(w1, GR_TRUE); return; } begxpos = bp->x; xpos = bp->x; ypos = bp->y; }