Пример #1
0
nxeyes_state *init(void)
{
	nxeyes_state *state;
	GR_REGION_ID rid1, rid2;
	GR_SCREEN_INFO si;
	GR_WM_PROPERTIES props;

	if(!(state = malloc(sizeof(nxeyes_state)))) return NULL;
	state->oldx = state->oldy = state->x = state->y = 0;
	state->button_down = state->eyes_closed = state->quit = 0;
	state->olx = state->orx = EYEMASK_WIDTH / 2;
	state->oly = state->ory = EYEMASK_HEIGHT / 2;
	GrGetScreenInfo(&si);
	state->mousex = si.xpos;
	state->mousey = si.ypos;
	state->mouse_moved = 1;
	state->gc = GrNewGC();
	GrSetGCForeground(state->gc, GR_COLOR_WHITE);
	GrSetGCBackground(state->gc, GR_COLOR_BLACK);

	state->wid = GrNewWindow(GR_ROOT_WINDOW_ID, 0, 0, (EYEFG_HEIGHT * 2) +
			EYE_SPACING, EYEFG_HEIGHT, 0, GR_COLOR_WHITE, 0);

	rid1 = GrNewBitmapRegion(eyemask_bits, EYEMASK_WIDTH, EYEMASK_HEIGHT);
	rid2 = GrNewBitmapRegion(eyemask_bits, EYEMASK_WIDTH, EYEMASK_HEIGHT);
	GrOffsetRegion(rid2, EYEMASK_WIDTH + EYE_SPACING, 0);
	GrUnionRegion(rid1, rid1, rid2);
	GrSetWindowRegion(state->wid, rid1, GR_WINDOW_BOUNDING_MASK);
	GrDestroyRegion(rid1);
	GrDestroyRegion(rid2);

	props.flags = GR_WM_FLAGS_PROPS;
	props.props = GR_WM_PROPS_NODECORATE;
	GrSetWMProperties(state->wid, &props);

	GrSelectEvents(state->wid, GR_EVENT_MASK_CLOSE_REQ |
			GR_EVENT_MASK_MOUSE_POSITION |
			GR_EVENT_MASK_BUTTON_UP |
			GR_EVENT_MASK_BUTTON_DOWN |
			GR_EVENT_MASK_EXPOSURE |
			GR_EVENT_MASK_TIMER);

	GrSelectEvents(GR_ROOT_WINDOW_ID, GR_EVENT_MASK_MOUSE_POSITION);

	GrMapWindow(state->wid);

	srand(123);
#if MW_FEATURE_TIMERS
	start_blink_timer(state);
#endif	
	return state;
}
Пример #2
0
static void
GrDestroyRegionWrapper(void *r)
{
	nxDestroyRegionReq *req = r;

	GrDestroyRegion(req->regionid);
}
Пример #3
0
int
XDestroyRegion(Region r)
{
	GrDestroyRegion(r->rid);
	Xfree(r);

	return 1;
}
Пример #4
0
void
XShapeCombineMask(Display *dpy, Window dest, int destKind, int xOff, int yOff,
	Pixmap src, int op)
{
	GR_REGION_ID	mask;
	GR_WINDOW_INFO	info;

	if (destKind != ShapeBounding || op != ShapeSet)
	//if (destKind != ShapeClip || op != ShapeSet)
		return;

	if (src == None) {
		GrSetWindowRegion(dest, 0, 0);
		return;
	}

	GrGetWindowInfo(src, &info);
	mask = GrNewRegionFromPixmap(src, 0, 0, info.width, info.height);
	GrSetWindowRegion(dest, mask, mask);
	GrDestroyRegion(mask);
}
Пример #5
0
/*
 * Destroy windows and eventclient structures used by client.
 * Called by GsDropClient after a client has exited to clean
 * up resources.
 */
void
GsDestroyClientResources(GR_CLIENT * client)
{
	GR_WINDOW     * wp, *nwp;
	GR_PIXMAP     * pp, *npp;
	GR_GC 	      * gp, *ngp;
	GR_REGION     * rp, *nrp;
	GR_FONT       * fp, *nfp;
	GR_CURSOR     *	cp, *ncp;
	GR_EVENT_CLIENT *ecp, *necp;
	GR_EVENT_CLIENT *pecp = NULL;
	GR_EVENT_LIST	*evp;
	GR_GRABBED_KEY	*kp, *nkp;
#if MW_FEATURE_IMAGES
	GR_IMAGE      * ip, *nip;
#endif
#if MW_FEATURE_TIMERS
	GR_TIMER      * tp, *ntp;
#endif

DPRINTF("Destroy client %d resources\n", client->id);
	/* search window list, destroy windows owned by client*/
	for(wp=listwp; wp; wp=nwp) {
		nwp = wp->next;
		/*
		 * Remove eventclient structures for this client
		 */
		ecp = wp->eventclients;
		while (ecp) {
			necp = ecp->next;
			if (ecp->client == client) {
DPRINTF( "  Destroy window %d eventclient mask %08lx\n", wp->id, ecp->eventmask);
				if (ecp == wp->eventclients)
					wp->eventclients = ecp->next;
				else
					pecp->next = ecp->next;
				free(ecp);
			} else
				pecp = ecp;
			ecp = necp;
		}
		if (wp->owner == client) {
DPRINTF("  Destroy window %d\n", wp->id);
			GrDestroyWindow(wp->id);
		}
	}

	/* search pixmap list, destroy pixmaps owned by client*/
	for(pp=listpp; pp; pp=npp) {
		npp = pp->next;
		if (pp->owner == client) {
DPRINTF("  Destroy pixmap %d\n", pp->id);
			GrDestroyWindow(pp->id);
		}
	}

	/* free gc's owned by client*/
	for(gp=listgcp; gp; gp=ngp) {
		ngp = gp->next;
		if (gp->owner == client) {
DPRINTF("  Destroy gc %d\n", gp->id);
			GrDestroyGC(gp->id);
		}
	}

	/* free fonts owned by client*/
	for(fp=listfontp; fp; fp=nfp) {
		nfp = fp->next;
		if (fp->owner == client) {
DPRINTF("  Destroy font %d\n", fp->id);
			GrDestroyFont(fp->id);
		}
	}

	/* free regions owned by client*/
	for(rp=listregionp; rp; rp=nrp) {
		nrp = rp->next;
		if (rp->owner == client) {
DPRINTF("  Destroy region %d\n", rp->id);
			GrDestroyRegion(rp->id);
		}
	}

#if MW_FEATURE_IMAGES
	/* free images owned by client*/
	for(ip=listimagep; ip; ip=nip) {
		nip = ip->next;
		if (ip->owner == client) {
DPRINTF("  Destroy image %d\n", ip->id);
			GrFreeImage(ip->id);
		}
	}
#endif

#if MW_FEATURE_TIMERS
	/* free timers owned by client*/
	for(tp=list_timer; tp; tp=ntp) {
		ntp = tp->next;
		if (tp->owner == client) {
DPRINTF("  Destroy timer %d\n", tp->id);
			GrDestroyTimer(tp->id);
		}
	}
#endif

	/* free cursors owned by client*/
	for(cp=listcursorp; cp; cp=ncp) {
		ncp = cp->next;
		if (cp->owner == client) {
DPRINTF("  Destroy cursor %d\n", cp->id);
			GrDestroyCursor(cp->id);
		}
	}

	/* Free key grabs associated with client*/
	for (kp=list_grabbed_keys; kp; kp = nkp) {
		nkp = kp->next;
		if (kp->owner == curclient) {
DPRINTF("  Destroy grabkey %d,%d\n", kp->wid, kp->key);
			GrUngrabKey(kp->wid, kp->key);
		}
	}

	/* Free events associated with client*/
	evp = client->eventhead;
	while (evp) {
DPRINTF("  Destroy event %d\n", evp->event.type);
		client->eventhead = evp->next;
		evp->next = eventfree;
		eventfree = evp;
		evp = client->eventhead;
	}
}
Пример #6
0
/*
 * Destroy windows and eventclient structures used by client.
 * Called by GsDropClient after a client has exited to clean
 * up resources.
 */
void
GsDestroyClientResources(GR_CLIENT * client)
{
	GR_WINDOW     * wp, *nwp;
	GR_PIXMAP     * pp, *npp;
	GR_GC 	      * gp, *ngp;
	GR_REGION     * rp, *nrp;
	GR_FONT       * fp, *nfp;
	GR_IMAGE      * ip, *nip;
	GR_CURSOR     *	cp, *ncp;
	GR_EVENT_CLIENT *ecp, *necp;
	GR_EVENT_CLIENT *pecp = NULL;
	GR_EVENT_LIST	*evp;

printf("Destroy client %d resources\n", client->id);
	/* search window list, destroy windows owned by client*/
	for(wp=listwp; wp; wp=nwp) {
		nwp = wp->next;
		/*
		 * Remove eventclient structures for this client
		 */
		ecp = wp->eventclients;
		while (ecp) {
			necp = ecp->next;
			if (ecp->client == client) {
printf( "  Destroy window %d eventclient mask %08lx\n", wp->id, ecp->eventmask);
				if (ecp == wp->eventclients)
					wp->eventclients = ecp->next;
				else
					pecp->next = ecp->next;
				free(ecp);
			} else
				pecp = ecp;
			ecp = necp;
		}
		if (wp->owner == client) {
printf("  Destroy window %d\n", wp->id);
			GrDestroyWindow(wp->id);
		}
	}

	/* search pixmap list, destroy pixmaps owned by client*/
	for(pp=listpp; pp; pp=npp) {
		npp = pp->next;
		if (pp->owner == client) {
printf("  Destroy pixmap %d\n", pp->id);
			GrDestroyWindow(pp->id);
		}
	}

	/* free gc's owned by client*/
	for(gp=listgcp; gp; gp=ngp) {
		ngp = gp->next;
		if (gp->owner == client) {
printf("  Destroy gc %d\n", gp->id);
			GrDestroyGC(gp->id);
		}
	}

	/* free fonts owned by client*/
	for(fp=listfontp; fp; fp=nfp) {
		nfp = fp->next;
		if (fp->owner == client) {
printf("  Destroy font %d\n", fp->id);
			GrDestroyFont(fp->id);
		}
	}

	/* free regions owned by client*/
	for(rp=listregionp; rp; rp=nrp) {
		nrp = rp->next;
		if (rp->owner == client) {
printf("  Destroy region %d\n", rp->id);
			GrDestroyRegion(rp->id);
		}
	}

	/* free images owned by client*/
	for(ip=listimagep; ip; ip=nip) {
		nip = ip->next;
		if (ip->owner == client) {
printf("  Destroy image %d\n", ip->id);
			GrFreeImage(ip->id);
		}
	}

	/* free cursors owned by client*/
	for(cp=listcursorp; cp; cp=ncp) {
		ncp = cp->next;
		if (cp->owner == client) {
printf("  Destroy cursor %d\n", cp->id);
			GrDestroyCursor(cp->id);
		}
	}

	/* Free events associated with client*/
	evp = client->eventhead;
	while (evp) {
printf("  Destroy event %d\n", evp->event.type);
		client->eventhead = evp->next;
		evp->next = eventfree;
		eventfree = evp;
		evp = client->eventhead;
	}
}
Пример #7
0
int
main(int ac, char **av)
{
	GR_WINDOW_ID window;
	GR_GC_ID gc;
	GR_FONT_ID fontid;
	int x, y, fnum;
	GR_REGION_ID regionid;
#if CLIP_POLYGON
	GR_POINT points[] = { {20, 20}, {300, 20}, {300, 300}, {20, 300} };
#else
	GR_RECT clip_rect = { 20, 20, 300, 300 };
#endif

	if (GrOpen() < 0)
		exit(1);

	window = GrNewWindowEx(GR_WM_PROPS_APPWINDOW,
		"t1demo loadable fonts (truetype, t1lib, pcf, mgl, hzk)",
		GR_ROOT_WINDOW_ID, 50, 50, WIDTH, HEIGHT, BLACK);
	GrSelectEvents(window, GR_EVENT_MASK_EXPOSURE | GR_EVENT_MASK_CLOSE_REQ);
	GrMapWindow(window);

	gc = GrNewGC();
	GrSetGCUseBackground(gc, GR_FALSE);
	GrSetGCBackground(gc, BLACK);

#if CLIP_POLYGON
	/* polygon clip region */
	regionid = GrNewPolygonRegion(MWPOLY_EVENODD, 3, points);
#else
	/* rectangle clip region */
	regionid = GrNewRegion();
	GrUnionRectWithRegion(regionid, &clip_rect);
#endif
	GrSetGCRegion(gc, regionid);

	srand(time(0));
	while (1) {
		GR_EVENT event;

		GrCheckNextEvent(&event);
		if (event.type == GR_EVENT_TYPE_CLOSE_REQ) {
			GrClose();
			exit(0);
		}

		fontid = GrCreateFontEx(names[fnum=RAND(MAXFONTS)], 0, 0, NULL);
		GrSetFontSizeEx(fontid, RAND(80) + 1, RAND(80) + 1);
		GrSetFontRotation(fontid, 330);		/* 33 degrees */
		GrSetFontAttr(fontid, GR_TFKERNING | GR_TFANTIALIAS, 0);
		GrSetGCFont(gc, fontid);

		GrSetGCForeground(gc, rand() & 0xffffff);
		/*GrSetGCBackground(gc, rand() & 0xffffff); */

		x = RAND(WIDTH);
		y = RAND(HEIGHT);

#if HAVE_HZK_SUPPORT
		{
#if HZKBIG5
		/* hzk big5 unicode-16 test*/
		static unsigned short buffer[] = {
		    0x9060, 0x898b, 0x79d1, 0x6280, 0x0061, 0x0041, 0
		};
		GrText(window, gc, x, y, buffer, 7, GR_TFUC16);

		/* hzk big5 dbcs test #1*/
		x = RAND(WIDTH);
		y = RAND(HEIGHT);
		GrText(window, gc, x, y,
		       "Microwindows,Åwªï¨Ï¥Î¤¤­^¤åÂI°}¦rÅé", -1, GR_TFASCII);

		/* hzk big5 dbcs test #2*/
		x = RAND(WIDTH);
		y = RAND(HEIGHT);
		GrText(window, gc, x, y, "£t£u£v£w£¸£¹£º", -1, GR_TFASCII);
#else
	#if 0
		/* hzk test #1*/
		static char buffer[] = {
			0x6c, 0x49, 0x73, 0x8b, 0x79,
			0xd1, 0x62, 0x80, 0x61, 0x00,
			0x41, 0x00, 0x00, 0xa1, 0x00,
			0xa6, 0x6c, 0x49, 0, 0
		};

		/* *static unsigned short buffer[] = {
			0x496c, 0x8b73, 0xd179, 0x8062, 0x0061,
			0x0041, 0xa100, 0xa600, 0x496c, 0
		};***/

		GrText(window, gc, x, y, buffer, 9, GR_TFUC16);
	#endif
		/* HZK Metrix font test, includes Chinese and English */
		x = RAND(WIDTH);
		y = RAND(HEIGHT);
		GrText(window, gc, x, y,
		       "Microwindows,»¶Ó­Ê¹ÓÃÖÐÓ¢ÎĵãÕó×ÖÌå", -1, GR_TFASCII);
#endif /* HZKBIG5*/
		}
#elif HAVE_BIG5_SUPPORT
		/* encoding BIG5 test 61 B1 64 B1 64 61 */
		GrText(window, gc, x, y, "\151\261\144\261\144\151", 6, MWTF_DBCS_BIG5);
#elif HAVE_GB2312_SUPPORT
		/* encoding GB2312 test BD A1 BD A1 */
		GrText(window, gc, x, y, "\275\241\275\241", 4, MWTF_DBCS_GB);
#elif HAVE_EUCJP_SUPPORT
		/* encoding EUC_JP test A2 A1 */
		GrText(window, gc, x, y, "ï¿½Þ¥ï¿½ï¿½ï¿½ï¿½í¥¦ï¿½ï¿½ï¿½ï¿½ï¿½É¥ï¿½ï¿½ï¿½ï¿½Ø¤è¤¦ï¿½ï¿½ï¿½ï¿½!", -1, MWTF_DBCS_EUCJP);
#elif HAVE_JISX0213_SUPPORT
		/* encoding JISX0213 test A2 A1 */
		GrText(window, gc, x, y, "\242\241", 2, MWTF_DBCS_JIS);
#elif HAVE_KSC5601_SUPPORT
		/* encoding KSC5601 test B0 B0 */
		GrText(window, gc, x, y, "\273\273", 2, MWTF_DBCS_EUCKR);
#elif HAVE_FREETYPE_2_SUPPORT
		/* ASCII test */
		GrText(window, gc, x, y, "Microwindows", -1, GR_TFASCII);
#elif HAVE_PCF_SUPPORT
		/* note: large PCF fonts require XCHAR2B, this is not
		   figured out yet for these fonts.  FIXME */
		if (fnum == 3) {
			/* japanese jiskan24*/
			unsigned short text[] =
			    { 0x213a, 0x213b, 0x2170, 0x2276, 0x2339 };
			GrText(window, gc, x,y, text, 5, GR_TFUC16);
		} else if (fnum == 4) {
			/* chinese gb24st*/
			unsigned short text[] =
			    /* FIXME: why doesn't first row index correctly?*/
			    /*{ 0x7765, 0x7766, 0x7767, 0x777a, 0x777e };*/
			    { 0x2129, 0x212a, 0x212b, 0x212c, 0x212d };
			GrText(window, gc, x,y, text, 5, GR_TFUC16);
		} else
			GrText(window, gc, x,y, "Microwindows", -1, GR_TFASCII);
#elif HAVE_FNT_SUPPORT
		/* UC16 test */
		if (fnum == 2 || fnum == 3) {
			/* japanese jiskan24, jiskan16-2000-1*/
			unsigned short text[] =
			    { 0x213a, 0x213b, 0x2170, 0x2276, 0x2339 };
			GrText(window, gc, x,y, text, 5, GR_TFUC16);
		} else if (fnum == 4) {
			/* chinese gbk16-xke*/
			unsigned short text[] =
			    { 0x8144, 0x8147, 0x8148, 0xfe4e, 0xfe4f };
			GrText(window, gc, x,y, text, 5, GR_TFUC16);
		} else
			GrText(window, gc, x,y, "Microwindows", -1, GR_TFASCII);
#else
		/* ASCII test */
		GrText(window, gc, x, y, "Microwindows", -1, GR_TFASCII);
#endif
		GrFlush();
		GrDestroyFont(fontid);
	}
	GrDestroyRegion(regionid);
	GrClose();
	return 0;
}
Пример #8
0
int main()
{
	GR_WINDOW_ID 	window;
	GR_EVENT 	event;
        GR_GC_ID 	gc;
	GR_FONT_ID	fontid;
        int 		i, x, y;
	GR_REGION_ID	regionid = 0;
#if CLIP_POLYGON
	GR_POINT	points[]={ {100, 100},
				{300, 100},
				{300, 300},
				{100, 300}};
#else
	GR_RECT		clip_rect={100,100,300,300};
#endif
   
        srand(time(0));
   
        GrOpen();
	window = GrNewWindow(GR_ROOT_WINDOW_ID, 50,50, MAXW,MAXH, 4, BLACK,BLUE);
	GrMapWindow(window);

        gc = GrNewGC();

#if CLIP_POLYGON
	/* polygon clip region*/
	regionid = GrNewPolygonRegion(MWPOLY_EVENODD, 3, points);
#else
	/* rectangle clip region*/
        regionid = GrNewRegion();
	GrUnionRectWithRegion(regionid, &clip_rect);
#endif

	GrSetGCRegion(gc, regionid);
	
        GrSelectEvents(window,GR_EVENT_MASK_ALL);
        GrSetGCUseBackground(gc,GR_FALSE);
	GrSetGCBackground(gc, GR_RGB(0, 0, 0));
	while(1) {
	      GrCheckNextEvent(&event);
	   
	      i = (int)((float)MAXFONTS * rand() / (RAND_MAX + 1.0));
	      fontid = GrCreateFont(names[i], 20, NULL);
	      GrSetFontSize(fontid, 1+(int)(80.0 * rand() / (RAND_MAX+1.0)));
	      GrSetFontRotation(fontid, 330);	/* 33 degrees*/
  	      GrSetFontAttr(fontid, GR_TFKERNING | GR_TFANTIALIAS, 0);
  	      GrSetGCFont(gc, fontid);
	      /*GrSetGCBackground(gc, rand() & 0xffffff);*/
 	      GrSetGCForeground(gc, rand() & 0xffffff);
	      x = (int) ((MAXW * 1.0) *rand()/(RAND_MAX+1.0));
	      y = (int) ((MAXH * 1.0) *rand()/(RAND_MAX+1.0));

#if HAVE_HZK_SUPPORT
             {	/* to test Unicode 16 chinese characters display ,use HZK font Bitmap font (Metrix font). */
#ifndef BIG5		
		char buffer[256];
		buffer[0]=0x6c;
		buffer[1]=0x49;
		buffer[2]=0x73;
		buffer[3]=0x8b;
		buffer[4]=0x79;
		buffer[5]=0xd1;
		buffer[6]=0x62;
		buffer[7]=0x80;
		buffer[8]=0x61;
		buffer[9]=0x00;
		buffer[10]=0x41;
		buffer[11]=0x00;

		buffer[12]=0x00;
		buffer[13]=0xa1;
		buffer[14]=0x00;
		buffer[15]=0xa6;
		buffer[16]=0x6c;
		buffer[17]=0x49;
		buffer[18]=0x0;
		buffer[19]=0x0;
		GrText(window, gc,x,y+20, buffer,17, GR_TFUC16);
		x=0;y=16;
		GrText(window, gc,x,y+20, buffer,17, GR_TFUC16);
#else
		unsigned short buffer[7];
		buffer[0]=0x9060;
		buffer[1]=0x898b;
		buffer[2]=0x79d1;
		buffer[3]=0x6280;
		buffer[4]=0x0061;
		buffer[5]=0x0041;
		buffer[6]=0x0;
		GrText(window, gc,x,y+20, buffer,7, GR_TFUC16);
		x=0;y=16;
		GrText(window, gc,x,y+20, buffer,7, GR_TFUC16);
#endif
	      }

#ifndef BIG5
	      x=0;y=16;
	      /* HZK Metrix font test, includes Chinese and English*/
	      GrText(window, gc,x,y, "Microwindows,欢迎使用中英文点阵字体",
		      -1, GR_TFASCII);
#else	
	      GrText(window, gc,x,y, "Microwindows,舧ㄏノい璣ゅ翴皚砰",
		      -1, GR_TFASCII);
	      x=0;y=16*3+4;
	      GrText(window, gc,x,y, "89:", -1, GR_TFASCII);
#endif
	      GrFlush();

#else /* !HZK_FONT_SUPPORT*/

#if HAVE_BIG5_SUPPORT
	      /* ENCODING_BIG5 test*/
	      GrText(window, gc,x,y, "眃眃", -1, GR_TFASCII);
#else
#if HAVE_GB2312_SUPPORT
	      /* ENCODING_GB2312 test*/
	      GrText(window, gc,x,y, "\275\241\275\241", -1, GR_TFASCII);
#else
	      /* ASCII test*/
	      GrText(window, gc,x,y, "Microwindows", -1, GR_TFASCII);
#endif
#endif

#endif /* HZK_FONT_SUPPORT*/


	      GrDestroyFont(fontid);

		if(event.type == GR_EVENT_TYPE_CLOSE_REQ) {
			GrClose();
			exit(0);
		}
	}

	GrDestroyRegion(regionid);
	GrClose();
}
Пример #9
0
/*
   Calculate Visible region of root window.
*/
int
CalcRootVisible(void)
{
    GR_REGION_ID covered;
    GR_REGION_ID visible;
    GR_WINDOW_ID parent;
    GR_WINDOW_ID *children;
    GR_COUNT nChildren;
    GR_COUNT wx;
    GR_RECT rect;
    GR_WINDOW_INFO info;
    
    /*
       Get children of root.
    */
    GrQueryTree(GR_ROOT_WINDOW_ID, &parent, &children, &nChildren);
    
    /*
       For each mapped child, add the window rectangle to the covered
       region.
    */
    covered = GrNewRegion();
    for (wx=0; wx<nChildren; wx++) {
	GrGetWindowInfo(children[wx], &info);
	if (info.unmapcount == 0) {
	    rect.x = info.x;
	    rect.y = info.y;
	    rect.width = info.width;
	    rect.height = info.height;
	    GrUnionRectWithRegion(covered, &rect);
	}
    }
    free(children);

    /*
       Subtract the covered region from the root window region.
    */
    visible = GrNewRegion();
    rect.x = 0;
    rect.y = 0;
    rect.width = display_width;
    rect.height = display_height;
    GrUnionRectWithRegion(visible, &rect);
    GrSubtractRegion(visible, visible, covered);
    GrDestroyRegion(covered);
    
    /*
       Save visible region globally.
    */
    if (rootVisible)
	GrDestroyRegion(rootVisible);
    rootVisible = visible;

    /*
       Mark all roaches visible.
    */
    for (wx=0; wx<curRoaches; wx++) 
	roaches[wx].hidden = 0;

    return 0;
}