for (i=0; i<length; i++) {
for (i=0; i< (int) length; i++) {
void solid_cde(char *color) {	int wsmax = 16;	static XImage *image[16];	static Window ws_wins[16];	static int nws = -1;	Window expose;	Pixmap pixmap;	XGCValues gcv;	GC gc;	XSetWindowAttributes swa;	Visual visual;	unsigned long mask, pixel;	XColor cdef;	Colormap cmap;	int n;	if (subwin || window != rootwin) {		rfbLog("cannot set subwin to solid color, must be rootwin\n");		return;	}	/* create the "clear" window just for generating exposures */	swa.override_redirect = True;	swa.backing_store = NotUseful;	swa.save_under = False;	swa.background_pixmap = None;	visual.visualid = CopyFromParent;	mask = (CWOverrideRedirect|CWBackingStore|CWSaveUnder|CWBackPixmap);	expose = XCreateWindow(dpy, window, 0, 0, wdpy_x, wdpy_y, 0, depth,	    InputOutput, &visual, mask, &swa);	if (! color) {		/* restore the backdrop windows from the XImage snapshots */		for (n=0; n < nws; n++) {			Window twin;			if (! image[n]) {				continue;			}			twin = ws_wins[n];			if (! twin) {				twin = rootwin;			}			if (! valid_window(twin, NULL, 0)) {				continue;			}			pixmap = XCreatePixmap(dpy, twin, wdpy_x, wdpy_y,			    depth);						/* draw the image to a pixmap: */			gcv.function = GXcopy;			gcv.plane_mask = AllPlanes;			gc = XCreateGC(dpy, twin, GCFunction|GCPlaneMask, &gcv);			XPutImage(dpy, pixmap, gc, image[n], 0, 0, 0, 0,			    wdpy_x, wdpy_y);			gcv.foreground = gcv.background = BlackPixel(dpy, scr);			gc = XCreateGC(dpy, twin, GCForeground|GCBackground,			    &gcv);			rfbLog("restoring CDE ws%d snapshot to 0x%lx\n",			    n, twin);			/* set the pixmap as the bg: */			XSetWindowBackgroundPixmap(dpy, twin, pixmap);			XFreePixmap(dpy, pixmap);			XClearWindow(dpy, twin);			XFlush(dpy);		}				/* generate exposures */		XMapWindow(dpy, expose);		XSync(dpy, False);		XDestroyWindow(dpy, expose);		return;	}	if (nws < 0) {		/* need to retrieve snapshots of the ws backgrounds: */		Window iwin, wm_win;		XSetWindowAttributes iswa;		Atom dt_list, wm_info, type;		int format;		unsigned long length, after;		unsigned char *data;		unsigned int * dp;		nws = 0;		/* extract the hidden wm properties about backdrops: */		wm_info = XInternAtom(dpy, "_MOTIF_WM_INFO", True);		if (wm_info == None) {			return;		}		XGetWindowProperty(dpy, rootwin, wm_info, 0L, 10L, False,		    AnyPropertyType, &type, &format, &length, &after, &data);		/*		 * xprop -notype -root _MOTIF_WM_INFO		 * _MOTIF_WM_INFO = 0x2, 0x580028		 */		if (length < 2 || format != 32 || after != 0) {			return;		}		dp = (unsigned int *) data;		wm_win = (Window) *(dp+1);	/* 2nd item. */		dt_list = XInternAtom(dpy, "_DT_WORKSPACE_LIST", True);		if (dt_list == None) {			return;		}		XGetWindowProperty(dpy, wm_win, dt_list, 0L, 10L, False,		   AnyPropertyType, &type, &format, &length, &after, &data);		nws = length;		if (nws > wsmax) {			nws = wsmax;		}		if (nws < 0) {			nws = 0;		}		rfbLog("special CDE win: 0x%lx, %d workspaces\n", wm_win, nws);		if (nws == 0) {			return;		}		for (n=0; n<nws; n++) {			Atom ws_atom;			char tmp[32];			Window twin;			XWindowAttributes attr;			int i, cnt;			image[n] = NULL;			ws_wins[n] = 0x0;			sprintf(tmp, "_DT_WORKSPACE_INFO_ws%d", n);			ws_atom = XInternAtom(dpy, tmp, False);			if (ws_atom == None) {				continue;			}			XGetWindowProperty(dpy, wm_win, ws_atom, 0L, 100L,			   False, AnyPropertyType, &type, &format, &length,			   &after, &data);			if (format != 8 || after != 0) {				continue;			}			/*			 * xprop -notype -id wm_win			 * _DT_WORKSPACE_INFO_ws0 = "One", "3", "0x2f2f4a",			 * "0x63639c", "0x103", "1", "0x58044e"			 */			cnt = 0;			twin = 0x0;			for (i=0; i<length; i++) {				if (*(data+i) != '\0') {					continue;				}				cnt++;	/* count nulls to indicate field */				if (cnt == 6) {					/* one past the null: */					char *q = (char *) (data+i+1);					unsigned long in;					if (sscanf(q, "0x%lx", &in) == 1) {						twin = (Window) in;						break;					}				}			}			ws_wins[n] = twin;			if (! twin) {				twin = rootwin;			}			XGetWindowAttributes(dpy, twin, &attr);			if (twin != rootwin) {				if (attr.map_state != IsViewable) {					XMapWindow(dpy, twin);				}				XRaiseWindow(dpy, twin);			}			XSync(dpy, False);					/* create image window: */			iswa.override_redirect = True;			iswa.backing_store = NotUseful;			iswa.save_under = False;			iswa.background_pixmap = ParentRelative;			visual.visualid = CopyFromParent;			iwin = XCreateWindow(dpy, twin, 0, 0, wdpy_x, wdpy_y,			    0, depth, InputOutput, &visual, mask, &iswa);			rfbLog("snapshotting CDE backdrop ws%d 0x%lx -> "			    "0x%lx ...\n", n, twin, iwin);			XMapWindow(dpy, iwin);			XSync(dpy, False);			image[n] = XGetImage(dpy, iwin, 0, 0, wdpy_x, wdpy_y,			    AllPlanes, ZPixmap);			XSync(dpy, False);			XDestroyWindow(dpy, iwin);			if (twin != rootwin) {				XLowerWindow(dpy, twin);				if (attr.map_state != IsViewable) {					XUnmapWindow(dpy, twin);				}			}		}	}	if (nws == 0) {		return;	}	/* use black for low colors or failure */	pixel = BlackPixel(dpy, scr);	if (depth > 8 || strcmp(color, solid_default)) {		cmap = DefaultColormap (dpy, scr);		if (XParseColor(dpy, cmap, color, &cdef) &&		    XAllocColor(dpy, cmap, &cdef)) {			pixel = cdef.pixel;		} else {			rfbLog("error parsing/allocing color: %s\n", color);		}	}	rfbLog("setting solid backgrounds...\n");	for (n=0; n < nws; n++)  {		Window twin = ws_wins[n];		if (image[n] == NULL) {			continue;		}		if (! twin)  {			twin = rootwin;		}		XSetWindowBackground(dpy, twin, pixel);	}	XMapWindow(dpy, expose);	XSync(dpy, False);	XDestroyWindow(dpy, expose);}