rem: XSync(dpy, 0); processEvents(XPending(dpy));
add: ProcessPendingEvents();
context: wDeiconifyWindow(WWindow  *wwin){    wWindowChangeWorkspace(wwin, wwin->screen_ptr->current_workspace);    if (!wwin->flags.miniaturized)        return;    if (wwin->transient_for != None        && wwin->transient_for != wwin->screen_ptr->root_win) {        WWindow *owner = recursiveTransientFor(wwin);        if (owner && owner->flags.miniaturized) {            wDeiconifyWindow(owner);            wSetFocusTo(wwin->screen_ptr, wwin);            wRaiseFrame(wwin->frame->core);            return;        }    }    wwin->flags.miniaturized = 0;    if (!wwin->flags.shaded)        wwin->flags.mapped = 1;    if (!wPreferences.disable_miniwindows && wwin->icon != NULL) {        if (wwin->icon->selected)            wIconSelect(wwin->icon);        XUnmapWindow(dpy, wwin->icon->core->window);    }    wSoundPlay(WSOUND_DEICONIFY);    /* if the window is in another workspace, do it silently */#ifdef ANIMATIONS    if (!wwin->screen_ptr->flags.startup && !wPreferences.no_animations        && !wwin->flags.skip_next_animation && wwin->icon != NULL) {        int ix, iy, iw, ih;        if (!wPreferences.disable_miniwindows) {            ix = wwin->icon_x;            iy = wwin->icon_y;            iw = wwin->icon->core->width;            ih = wwin->icon->core->height;        } else {#ifdef KWM_HINTS            WArea area;            if (wKWMGetIconGeometry(wwin, &area)) {                ix = area.x1;                iy = area.y1;                iw = area.x2 - ix;                ih = area.y2 - iy;            } else#endif /* KWM_HINTS */            {                ix = 0;                iy = 0;                iw = wwin->screen_ptr->scr_width;                ih = wwin->screen_ptr->scr_height;            }        }        animateResize(wwin->screen_ptr, ix, iy, iw, ih,                      wwin->frame_x, wwin->frame_y,                      wwin->frame->core->width, wwin->frame->core->height,                      False);    }#endif /* ANIMATIONS */    wwin->flags.skip_next_animation = 0;    XGrabServer(dpy);    if (!wwin->flags.shaded) {        XMapWindow(dpy, wwin->client_win);    }    XMapWindow(dpy, wwin->frame->core->window);    wRaiseFrame(wwin->frame->core);    if (!wwin->flags.shaded) {        wClientSetState(wwin, NormalState, None);    }    mapTransientsFor(wwin);    if (!wPreferences.disable_miniwindows && wwin->icon != NULL) {        RemoveFromStackList(wwin->icon->core);        /*    removeIconGrabs(wwin->icon);*/        wIconDestroy(wwin->icon);        wwin->icon = NULL;    }    XUngrabServer(dpy);    wSetFocusTo(wwin->screen_ptr, wwin);#ifdef ANIMATIONS    if (!wwin->screen_ptr->flags.startup) {        Window clientwin = wwin->client_win;        XSync(dpy, 0);        processEvents(XPending(dpy));        if (!wWindowFor(clientwin))            return;    }#endif    if (wPreferences.auto_arrange_icons) {        wArrangeIcons(wwin->screen_ptr, True);    }    WMPostNotificationName(WMNChangedState, wwin, "iconify");    /* In case we were shaded and iconified, also unshade */    wUnshadeWindow(wwin);}