diff options
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 19 |
1 files changed, 15 insertions, 4 deletions
@@ -29,7 +29,7 @@ static int mx, my, mw, mh; | |||
29 | static int ret = 0; | 29 | static int ret = 0; |
30 | static int nitem = 0; | 30 | static int nitem = 0; |
31 | static unsigned int cmdw = 0; | 31 | static unsigned int cmdw = 0; |
32 | static Bool done = False; | 32 | static Bool running = True; |
33 | static Item *allitems = NULL; /* first of all items */ | 33 | static Item *allitems = NULL; /* first of all items */ |
34 | static Item *item = NULL; /* first of pattern matching items */ | 34 | static Item *item = NULL; /* first of pattern matching items */ |
35 | static Item *sel = NULL; | 35 | static Item *sel = NULL; |
@@ -219,11 +219,11 @@ kpress(XKeyEvent * e) | |||
219 | else if(text) | 219 | else if(text) |
220 | fprintf(stdout, "%s", text); | 220 | fprintf(stdout, "%s", text); |
221 | fflush(stdout); | 221 | fflush(stdout); |
222 | done = True; | 222 | running = False; |
223 | break; | 223 | break; |
224 | case XK_Escape: | 224 | case XK_Escape: |
225 | ret = 1; | 225 | ret = 1; |
226 | done = True; | 226 | running = False; |
227 | break; | 227 | break; |
228 | case XK_BackSpace: | 228 | case XK_BackSpace: |
229 | if((i = len)) { | 229 | if((i = len)) { |
@@ -290,6 +290,7 @@ int | |||
290 | main(int argc, char *argv[]) | 290 | main(int argc, char *argv[]) |
291 | { | 291 | { |
292 | char *maxname; | 292 | char *maxname; |
293 | Item *i; | ||
293 | XEvent ev; | 294 | XEvent ev; |
294 | XSetWindowAttributes wa; | 295 | XSetWindowAttributes wa; |
295 | 296 | ||
@@ -349,7 +350,7 @@ main(int argc, char *argv[]) | |||
349 | XSync(dpy, False); | 350 | XSync(dpy, False); |
350 | 351 | ||
351 | /* main event loop */ | 352 | /* main event loop */ |
352 | while(!done && !XNextEvent(dpy, &ev)) { | 353 | while(running && !XNextEvent(dpy, &ev)) { |
353 | switch (ev.type) { | 354 | switch (ev.type) { |
354 | case KeyPress: | 355 | case KeyPress: |
355 | kpress(&ev.xkey); | 356 | kpress(&ev.xkey); |
@@ -364,6 +365,16 @@ main(int argc, char *argv[]) | |||
364 | } | 365 | } |
365 | 366 | ||
366 | XUngrabKeyboard(dpy, CurrentTime); | 367 | XUngrabKeyboard(dpy, CurrentTime); |
368 | while(allitems) { | ||
369 | i = allitems->next; | ||
370 | free(allitems->text); | ||
371 | free(allitems); | ||
372 | allitems = i; | ||
373 | } | ||
374 | if(dc.font.set) | ||
375 | XFreeFontSet(dpy, dc.font.set); | ||
376 | else | ||
377 | XFreeFont(dpy, dc.font.xfont); | ||
367 | XFreePixmap(dpy, dc.drawable); | 378 | XFreePixmap(dpy, dc.drawable); |
368 | XFreeGC(dpy, dc.gc); | 379 | XFreeGC(dpy, dc.gc); |
369 | XDestroyWindow(dpy, win); | 380 | XDestroyWindow(dpy, win); |