mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
create and use menuq_clear() helper; from Tiago Cunha
This commit is contained in:
parent
d651c1cc3b
commit
3a3e0383b2
1
calmwm.h
1
calmwm.h
@ -431,6 +431,7 @@ struct menu *menu_filter(struct screen_ctx *, struct menu_q *,
|
||||
void (*)(struct menu_q *, struct menu_q *, char *),
|
||||
void (*)(struct menu *, int));
|
||||
void menu_init(struct screen_ctx *);
|
||||
void menuq_clear(struct menu_q *);
|
||||
|
||||
int parse_config(const char *, struct conf *);
|
||||
|
||||
|
5
group.c
5
group.c
@ -385,10 +385,7 @@ group_menu(XButtonEvent *e)
|
||||
(gc->hidden) ? group_show(sc, gc) : group_hide(sc, gc);
|
||||
|
||||
cleanup:
|
||||
while ((mi = TAILQ_FIRST(&menuq)) != NULL) {
|
||||
TAILQ_REMOVE(&menuq, mi, entry);
|
||||
free(mi);
|
||||
}
|
||||
menuq_clear(&menuq);
|
||||
}
|
||||
|
||||
void
|
||||
|
20
kbfunc.c
20
kbfunc.c
@ -168,10 +168,7 @@ kbfunc_client_search(struct client_ctx *cc, union arg *arg)
|
||||
client_ptrwarp(cc);
|
||||
}
|
||||
|
||||
while ((mi = TAILQ_FIRST(&menuq)) != NULL) {
|
||||
TAILQ_REMOVE(&menuq, mi, entry);
|
||||
free(mi);
|
||||
}
|
||||
menuq_clear(&menuq);
|
||||
}
|
||||
|
||||
void
|
||||
@ -195,10 +192,7 @@ kbfunc_menu_search(struct client_ctx *cc, union arg *arg)
|
||||
search_match_text, NULL)) != NULL)
|
||||
u_spawn(((struct cmd *)mi->ctx)->image);
|
||||
|
||||
while ((mi = TAILQ_FIRST(&menuq)) != NULL) {
|
||||
TAILQ_REMOVE(&menuq, mi, entry);
|
||||
free(mi);
|
||||
}
|
||||
menuq_clear(&menuq);
|
||||
}
|
||||
|
||||
void
|
||||
@ -320,10 +314,7 @@ kbfunc_exec(struct client_ctx *cc, union arg *arg)
|
||||
out:
|
||||
if (mi != NULL && mi->dummy)
|
||||
free(mi);
|
||||
while ((mi = TAILQ_FIRST(&menuq)) != NULL) {
|
||||
TAILQ_REMOVE(&menuq, mi, entry);
|
||||
free(mi);
|
||||
}
|
||||
menuq_clear(&menuq);
|
||||
}
|
||||
|
||||
void
|
||||
@ -390,10 +381,7 @@ kbfunc_ssh(struct client_ctx *cc, union arg *arg)
|
||||
out:
|
||||
if (mi != NULL && mi->dummy)
|
||||
free(mi);
|
||||
while ((mi = TAILQ_FIRST(&menuq)) != NULL) {
|
||||
TAILQ_REMOVE(&menuq, mi, entry);
|
||||
free(mi);
|
||||
}
|
||||
menuq_clear(&menuq);
|
||||
}
|
||||
|
||||
void
|
||||
|
16
menu.c
16
menu.c
@ -215,10 +215,7 @@ menu_complete_path(struct menu_ctx *mc)
|
||||
strlcpy(path, mi->text, sizeof(mi->text));
|
||||
}
|
||||
|
||||
while ((mi = TAILQ_FIRST(&menuq)) != NULL) {
|
||||
TAILQ_REMOVE(&menuq, mi, entry);
|
||||
free(mi);
|
||||
}
|
||||
menuq_clear(&menuq);
|
||||
|
||||
if (path[0] != '\0')
|
||||
snprintf(mr->text, sizeof(mr->text), "%s \"%s\"",
|
||||
@ -632,3 +629,14 @@ menu_keycode(XKeyEvent *ev, enum ctltype *ctl, char *chr)
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
menuq_clear(struct menu_q *mq)
|
||||
{
|
||||
struct menu *mi;
|
||||
|
||||
while ((mi = TAILQ_FIRST(mq)) != NULL) {
|
||||
TAILQ_REMOVE(mq, mi, entry);
|
||||
free(mi);
|
||||
}
|
||||
}
|
||||
|
13
mousefunc.c
13
mousefunc.c
@ -250,12 +250,8 @@ mousefunc_menu_unhide(struct client_ctx *cc, void *arg)
|
||||
if (old_cc != NULL)
|
||||
client_ptrsave(old_cc);
|
||||
client_ptrwarp(cc);
|
||||
} else {
|
||||
while ((mi = TAILQ_FIRST(&menuq)) != NULL) {
|
||||
TAILQ_REMOVE(&menuq, mi, entry);
|
||||
free(mi);
|
||||
}
|
||||
}
|
||||
} else
|
||||
menuq_clear(&menuq);
|
||||
}
|
||||
|
||||
void
|
||||
@ -280,8 +276,5 @@ mousefunc_menu_cmd(struct client_ctx *cc, void *arg)
|
||||
if (mi != NULL)
|
||||
u_spawn(((struct cmd *)mi->ctx)->image);
|
||||
else
|
||||
while ((mi = TAILQ_FIRST(&menuq)) != NULL) {
|
||||
TAILQ_REMOVE(&menuq, mi, entry);
|
||||
free(mi);
|
||||
}
|
||||
menuq_clear(&menuq);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user