add: wMenuRemoveItem(switchmenu, i);
context: UpdateSwitchMenu(WScreen *scr, WWindow *wwin, int action){    WMenu *switchmenu = scr->switch_menu;    WMenuEntry *entry;    char title[MAX_MENU_TEXT_LENGTH+6];    int len = sizeof(title);    int i;    int checkVisibility = 0;    if (!wwin->screen_ptr->switch_menu)        return;    /*     *  This menu is updated under the following conditions:     *     *    1.  When a window is created.     *    2.  When a window is destroyed.     *     *    3.  When a window changes it's title.     * 	  4.  When a window changes its workspace.     */    if (action == ACTION_ADD) {        char *t;        int idx;        if (wwin->flags.internal_window || WFLAGP(wwin, skip_window_list))            return;        if (wwin->frame->title)            snprintf(title, len, "%s", wwin->frame->title);        else            snprintf(title, len, "%s", DEF_WINDOW_TITLE);        t = ShrinkString(scr->menu_entry_font, title, MAX_WINDOWLIST_WIDTH);        if (IS_OMNIPRESENT(wwin))            idx = -1;        else {            idx = menuIndexForWindow(switchmenu, wwin, -1);        }        entry = wMenuInsertCallback(switchmenu, idx, t, focusWindow, wwin);        wfree(t);        entry->flags.indicator = 1;        entry->rtext = wmalloc(MAX_WORKSPACENAME_WIDTH+8);        if (IS_OMNIPRESENT(wwin))            snprintf(entry->rtext, MAX_WORKSPACENAME_WIDTH, "[*]");        else            snprintf(entry->rtext, MAX_WORKSPACENAME_WIDTH, "[%s]",                     scr->workspaces[wwin->frame->workspace]->name);        if (wwin->flags.hidden) {            entry->flags.indicator_type = MI_HIDDEN;            entry->flags.indicator_on = 1;        } else if (wwin->flags.miniaturized) {            entry->flags.indicator_type = MI_MINIWINDOW;            entry->flags.indicator_on = 1;        } else if (wwin->flags.focused) {            entry->flags.indicator_type = MI_DIAMOND;            entry->flags.indicator_on = 1;        } else if (wwin->flags.shaded) {            entry->flags.indicator_type = MI_SHADED;            entry->flags.indicator_on = 1;        }        wMenuRealize(switchmenu);        checkVisibility = 1;    } else {        char *t;        for (i=0; i<switchmenu->entry_no; i++) {            entry = switchmenu->entries[i];            /* this is the entry that was changed */            if (entry->clientdata == wwin) {                switch (action) {                case ACTION_REMOVE:                    wMenuRemoveItem(switchmenu, i);                    wMenuRealize(switchmenu);                    checkVisibility = 1;                    break;                case ACTION_CHANGE:                    if (entry->text)                        wfree(entry->text);                    if (wwin->frame->title)                        snprintf(title, MAX_MENU_TEXT_LENGTH, "%s",                                 wwin->frame->title);                    else                        snprintf(title, MAX_MENU_TEXT_LENGTH, "%s",                                 DEF_WINDOW_TITLE);                    t = ShrinkString(scr->menu_entry_font, title, MAX_WINDOWLIST_WIDTH);                    entry->text = t;                    wMenuRealize(switchmenu);                    checkVisibility = 1;                    break;                case ACTION_CHANGE_WORKSPACE:                    if (entry->rtext) {                        int idx = -1;                        char *t, *rt;                        int it, ion;                        if (IS_OMNIPRESENT(wwin)) {                            snprintf(entry->rtext, MAX_WORKSPACENAME_WIDTH,                                     "[*]");                        } else {                            snprintf(entry->rtext, MAX_WORKSPACENAME_WIDTH,                                     "[%s]", scr->workspaces[wwin->frame->workspace]->name);                        }                        rt = entry->rtext;                        entry->rtext = NULL;                        t = entry->text;                        entry->text = NULL;                        it = entry->flags.indicator_type;                        ion = entry->flags.indicator_on;                        wMenuRemoveItem(switchmenu, i);                        if (!IS_OMNIPRESENT(wwin) && idx < 0) {                            idx = menuIndexForWindow(switchmenu, wwin, i);                        }                        entry = wMenuInsertCallback(switchmenu, idx, t,                                                    focusWindow, wwin);                        wfree(t);                        entry->rtext = rt;                        entry->flags.indicator = 1;                        entry->flags.indicator_type = it;                        entry->flags.indicator_on = ion;                    }                    wMenuRealize(switchmenu);                    checkVisibility = 1;                    break;                case ACTION_CHANGE_STATE:                    if (wwin->flags.hidden) {                        entry->flags.indicator_type = MI_HIDDEN;                        entry->flags.indicator_on = 1;                    } else if (wwin->flags.miniaturized) {                        entry->flags.indicator_type = MI_MINIWINDOW;                        entry->flags.indicator_on = 1;                    } else if (wwin->flags.shaded && !wwin->flags.focused) {                        entry->flags.indicator_type = MI_SHADED;                        entry->flags.indicator_on = 1;                    } else {                        entry->flags.indicator_on = wwin->flags.focused;                        entry->flags.indicator_type = MI_DIAMOND;                    }                    break;                }                break;            }        }    }    if (checkVisibility) {        int tmp;        tmp = switchmenu->frame->top_width + 5;        /* if menu got unreachable, bring it to a visible place */        if (switchmenu->frame_x < tmp - (int)switchmenu->frame->core->width) {            wMenuMove(switchmenu, tmp - (int)switchmenu->frame->core->width,                      switchmenu->frame_y, False);        }    }    wMenuPaint(switchmenu);}