rem: x = (x < -width) ? 0 : x; x = (x > scr->scr_width) ? scr->scr_width - width : x; y = (y < 0) ? 0 : y; y = (y > scr->scr_height) ? scr->scr_height - height : y;
add: if (x < rect.pos.x - width) x = rect.pos.x; if (x > rect.pos.x + rect.size.width) x = rect.pos.x + rect.size.width - width; if (y < rect.pos.y) y = rect.pos.y; if (y > rect.pos.y + rect.size.height) y = rect.pos.y + rect.size.height - height;
context: restoreMenuRecurs(WScreen *scr, WMPropList *menus, WMenu *menu, char *path){    WMPropList *key, *entry;    char buffer[512];    int i, x, y, res;    Bool lowered;    if (strlen(path) + strlen(menu->frame->title) > 510)        return False;    snprintf(buffer, sizeof(buffer), "%s\\%s", path, menu->frame->title);    key = WMCreatePLString(buffer);    entry = WMGetFromPLDictionary(menus, key);    res = False;    if (entry && getMenuInfo(entry, &x, &y, &lowered)) {        if (!menu->flags.mapped) {            int width = MENUW(menu);            int height = MENUH(menu);            wMenuMapAt(menu, x, y, False);            if (menu->parent) {                /* make parent map the copy in place of the original */                for (i=0; i<menu->parent->cascade_no; i++) {                    if (menu->parent->cascades[i] == menu) {                        menu->parent->cascades[i] = menu->brother;                        break;                    }                }            }            if (lowered) {                changeMenuLevels(menu, True);            }            x = (x < -width) ? 0 : x;            x = (x > scr->scr_width) ? scr->scr_width - width : x;            y = (y < 0) ? 0 : y;            y = (y > scr->scr_height) ? scr->scr_height - height : y;            wMenuMove(menu, x, y, True);            menu->flags.buttoned = 1;            wFrameWindowShowButton(menu->frame, WFF_RIGHT_BUTTON);            res = True;        }    }    WMReleasePropList(key);    for (i=0; i<menu->cascade_no; i++) {        if (restoreMenuRecurs(scr, menus, menu->cascades[i], buffer) != False)            res = True;    }    return res;}