tmp_win2 = tmp_win; for (i=0;i<WindowNameCount;i++)
WindowNames = (TwmWindow **)malloc(sizeof(TwmWindow *)*WindowNameCount); WindowNames[0] = Scr->TwmRoot.next; for(tmp_win = Scr->TwmRoot.next->next , WindowNameCount=1; tmp_win != NULL; tmp_win = tmp_win->next,WindowNameCount++)
PopUpMenu (menu, x, y, center)    MenuRoot *menu;    int x, y;    Bool center;{    int WindowNameOffset, WindowNameCount;    TwmWindow **WindowNames;    TwmWindow *tmp_win2,*tmp_win3;    int i;    int (*compar)(const char *, const char *) =       (Scr->CaseSensitive ? strcmp : XmuCompareISOLatin1);    if (!menu) return False;    InstallRootColormap();    if (menu == Scr->Windows)    {	TwmWindow *tmp_win;	/* this is the twm windows menu,  let's go ahead and build it */	DestroyMenu (menu);	menu->first = NULL;	menu->last = NULL;	menu->items = 0;	menu->width = 0;	menu->mapped = NEVER_MAPPED;  	AddToMenu(menu, "TWM Windows", NULLSTR, NULL, F_TITLE,NULLSTR,NULLSTR);          WindowNameOffset=(char *)Scr->TwmRoot.next->name -                               (char *)Scr->TwmRoot.next;        for(tmp_win = Scr->TwmRoot.next , WindowNameCount=0;            tmp_win != NULL;            tmp_win = tmp_win->next)          WindowNameCount++;        WindowNames =          (TwmWindow **)malloc(sizeof(TwmWindow *)*WindowNameCount);        WindowNames[0] = Scr->TwmRoot.next;        for(tmp_win = Scr->TwmRoot.next->next , WindowNameCount=1;            tmp_win != NULL;            tmp_win = tmp_win->next,WindowNameCount++)        {            tmp_win2 = tmp_win;            for (i=0;i<WindowNameCount;i++)            {                if ((*compar)(tmp_win2->name,WindowNames[i]->name) < 0)                {                    tmp_win3 = tmp_win2;                    tmp_win2 = WindowNames[i];                    WindowNames[i] = tmp_win3;                }            }            WindowNames[WindowNameCount] = tmp_win2;        }        for (i=0; i<WindowNameCount; i++)        {            AddToMenu(menu, WindowNames[i]->name, (char *)WindowNames[i],                      NULL, F_POPUP,NULL,NULL);        }        free(WindowNames);	MakeMenu(menu);    }    if (menu->w == None || menu->items == 0) return False;    /* Prevent recursively bringing up menus. */    if (menu->mapped == MAPPED) return False;    /*     * Dynamically set the parent;  this allows pull-ups to also be main     * menus, or to be brought up from more than one place.     */    menu->prev = ActiveMenu;    XGrabPointer(dpy, Scr->Root, True,	ButtonPressMask | ButtonReleaseMask |	ButtonMotionMask | PointerMotionHintMask,	GrabModeAsync, GrabModeAsync,	Scr->Root, Scr->MenuCursor, CurrentTime);    ActiveMenu = menu;    menu->mapped = MAPPED;    menu->entered = FALSE;    if (center) {	x -= (menu->width / 2);	y -= (Scr->EntryHeight / 2);	/* sticky menus would be nice here */    }    /*     * clip to screen     */    if (x + menu->width > Scr->MyDisplayWidth) {	x = Scr->MyDisplayWidth - menu->width;    }    if (x < 0) x = 0;    if (y + menu->height > Scr->MyDisplayHeight) {	y = Scr->MyDisplayHeight - menu->height;    }    if (y < 0) y = 0;    MenuOrigins[MenuDepth].x = x;    MenuOrigins[MenuDepth].y = y;    MenuDepth++;    XMoveWindow(dpy, menu->w, x, y);    if (Scr->Shadow) {	XMoveWindow (dpy, menu->shadow, x + SHADOWWIDTH, y + SHADOWWIDTH);    }    if (Scr->Shadow) {	XRaiseWindow (dpy, menu->shadow);    }    XMapRaised(dpy, menu->w);    if (Scr->Shadow) {	XMapWindow (dpy, menu->shadow);    }    XSync(dpy, 0);    return True;}