rem: XSync(dpy, 0); processEvents(XPending(dpy));
add: ProcessPendingEvents();
context: wShadeWindow(WWindow  *wwin){    time_t time0;#ifdef ANIMATIONS    int y, s, w, h;#endif    if (wwin->flags.shaded)        return;    time0 = time(NULL);    XLowerWindow(dpy, wwin->client_win);    wSoundPlay(WSOUND_SHADE);#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);            XFlush(dpy);            if (time(NULL)-time0 > MAX_ANIMATION_TIME)                break;            if (SHADE_DELAY > 0) {                wusleep(SHADE_DELAY*1000L);            } else {                wusleep(10);            }            h-=s;            y-=s;        }        XMoveWindow(dpy, wwin->client_win, 0, wwin->frame->top_width);    }#endif  /* ANIMATIONS */    wwin->flags.skip_next_animation = 0;    wwin->flags.shaded = 1;    wwin->flags.mapped = 0;    /* prevent window withdrawal when getting UnmapNotify */    XSelectInput(dpy, wwin->client_win,                 wwin->event_mask & ~StructureNotifyMask);    XUnmapWindow(dpy, wwin->client_win);    XSelectInput(dpy, wwin->client_win, wwin->event_mask);    /* for the client it's just like iconification */    wFrameWindowResize(wwin->frame, wwin->frame->core->width,                       wwin->frame->top_width - 1);    wwin->client.y = wwin->frame_y - wwin->client.height        + wwin->frame->top_width;    wWindowSynthConfigureNotify(wwin);    /*     wClientSetState(wwin, IconicState, None);     */    WMPostNotificationName(WMNChangedState, wwin, "shade");#ifdef ANIMATIONS    if (!wwin->screen_ptr->flags.startup) {        /* Look at processEvents() for reason of this code. */        XSync(dpy, 0);        processEvents(XPending(dpy));    }#endif}