static int ret = 0;
static int nitem = 0;
static unsigned int cmdw = 0;
-static Bool done = False;
+static Bool running = True;
static Item *allitems = NULL; /* first of all items */
static Item *item = NULL; /* first of pattern matching items */
static Item *sel = NULL;
else if(text)
fprintf(stdout, "%s", text);
fflush(stdout);
- done = True;
+ running = False;
break;
case XK_Escape:
ret = 1;
- done = True;
+ running = False;
break;
case XK_BackSpace:
if((i = len)) {
main(int argc, char *argv[])
{
char *maxname;
+ Item *i;
XEvent ev;
XSetWindowAttributes wa;
/* pixmap */
dc.drawable = XCreatePixmap(dpy, root, mw, mh, DefaultDepth(dpy, screen));
dc.gc = XCreateGC(dpy, root, 0, 0);
+ XSetLineAttributes(dpy, dc.gc, 1, LineSolid, CapButt, JoinMiter);
if(maxname)
cmdw = textw(maxname);
XSync(dpy, False);
/* main event loop */
- while(!done && !XNextEvent(dpy, &ev)) {
+ while(running && !XNextEvent(dpy, &ev)) {
switch (ev.type) {
case KeyPress:
kpress(&ev.xkey);
}
XUngrabKeyboard(dpy, CurrentTime);
+ while(allitems) {
+ i = allitems->next;
+ free(allitems->text);
+ free(allitems);
+ allitems = i;
+ }
+ if(dc.font.set)
+ XFreeFontSet(dpy, dc.font.set);
+ else
+ XFreeFont(dpy, dc.font.xfont);
XFreePixmap(dpy, dc.drawable);
XFreeGC(dpy, dc.gc);
XDestroyWindow(dpy, win);