rem: XSync(dpy, 0);
add: XFlush(dpy);  if (time(NULL)-time0 > MAX_ANIMATION_TIME) break;
context: wShadeWindow(WWindow  *wwin){    XWindowAttributes attribs;    time_t time0 = time(NULL);#ifdef ANIMATIONS    int y, s, w, h;#endif    if (wwin->flags.shaded)	return;    XLowerWindow(dpy, wwin->client_win);    #ifdef WMSOUND    wSoundPlay(WMSOUND_SHADE);#endif#ifdef ANIMATIONS    if (!wwin->screen_ptr->flags.startup && !wwin->flags.skip_next_animation	&& !wPreferences.no_animations) {	/* do the shading animation */	h = wwin->frame->core->height;        s = h/SHADE_STEPS;        if (s < 1) s=1;	w = wwin->frame->core->width;	y = wwin->frame->top_width;	while (h>wwin->frame->top_width+1) {	    XMoveWindow(dpy, wwin->client_win, 0, y);	    XResizeWindow(dpy, wwin->frame->core->window, w, h);	    XSync(dpy, 0);            if (SHADE_DELAY > 0)                wusleep(SHADE_DELAY*1000L);	    h-=s;	    y-=s;	    if (time(NULL)-time0 > MAX_ANIMATION_TIME)		break;	}	XMoveWindow(dpy, wwin->client_win, 0, wwin->frame->top_width);    }#endif  /* ANIMATIONS */    wwin->flags.skip_next_animation = 0;    XGetWindowAttributes(dpy, wwin->client_win, &attribs);        wwin->flags.shaded=1;    wwin->flags.mapped=0;    /* prevent window withdrawal when getting UnmapNotify */    XSelectInput(dpy, wwin->client_win, 		 attribs.your_event_mask & ~StructureNotifyMask);    XUnmapWindow(dpy, wwin->client_win);    XSelectInput(dpy, wwin->client_win, attribs.your_event_mask);        /* for the client it's just like iconification */    wFrameWindowResize(wwin->frame, wwin->frame->core->width,		       wwin->frame->top_width-1);    wClientSetState(wwin, IconicState, None);    /* update window list to reflect shaded state */    UpdateSwitchMenu(wwin->screen_ptr, wwin, ACTION_CHANGE_STATE);#ifdef ANIMATIONS    if (!wwin->screen_ptr->flags.startup) {	/* Look at processEvents() for reason of this code. */    	XSync(dpy, 0);    	processEvents(XPending(dpy));    }#endif}