static void parsestdin(void);
static void run(void);
static void freewindow(struct Menu *menu);
-static void cleanupexit(void);
+static void cleanup(void);
static void usage(void);
/* X variables */
/* run event loop */
run();
- return 1; /* UNREACHABLE */
+ cleanup();
+
+ return 0;
}
/* get color from color string */
lcamenu = menu;
}
+ /* unmap menus from currmenu (inclusive) until lcamenu (exclusive) */
for (menu = currmenu; menu != lcamenu; menu = menu->parent) {
XUnmapWindow(dpy, menu->win);
}
currmenu = currmenu_new;
+ /* map menus from currmenu (inclusive) until lcamenu (exclusive) */
item = NULL;
for (menu = currmenu; menu != lcamenu; menu = menu->parent) {
XMapWindow(dpy, menu->win);
struct Item *previtem = NULL;
XEvent ev;
- setcurrmenu(rootmenu);
-
while (!XNextEvent(dpy, &ev)) {
switch(ev.type) {
case Expose:
setcurrmenu(item->submenu);
} else {
printf("%s\n", item->output);
- cleanupexit();
+ return;
}
drawmenu();
} else {
- cleanupexit();
+ return;
}
break;
case LeaveNotify:
/* cleanup and exit */
static void
-cleanupexit(void)
+cleanup(void)
{
freewindow(rootmenu);
XFreeFont(dpy, dc.font);
XFreeGC(dpy, dc.gc);
XCloseDisplay(dpy);
- exit(0);
}
/* show usage */
static void
usage(void)
{
- (void)fprintf(stderr, "usage: xmenu [-w] menuname\n");
+ (void)fprintf(stderr, "usage: xmenu [-w]\n");
exit(1);
}