diff options
author | okan <okan> | 2017-12-19 19:38:43 +0000 |
---|---|---|
committer | okan <okan> | 2017-12-19 19:38:43 +0000 |
commit | 18a53717aec5c3a9a30df6c45646561aff9d9c1a (patch) | |
tree | fa9b2291ef075dc88d1872fb758ce0588bb5e7bb | |
parent | bc5215f41a5a8084b2496b7a3477a4cdac7b4695 (diff) | |
download | cwm-18a53717aec5c3a9a30df6c45646561aff9d9c1a.tar.gz cwm-18a53717aec5c3a9a30df6c45646561aff9d9c1a.tar.xz cwm-18a53717aec5c3a9a30df6c45646561aff9d9c1a.zip |
Use a variable to keep track of flags for menu_filter().
-rw-r--r-- | kbfunc.c | 34 | ||||
-rw-r--r-- | menu.c | 5 |
2 files changed, 24 insertions, 15 deletions
diff --git a/kbfunc.c b/kbfunc.c index 6788bde..60e4b41 100644 --- a/kbfunc.c +++ b/kbfunc.c @@ -451,8 +451,11 @@ kbfunc_menu_client(void *ctx, struct cargs *cargs) struct client_ctx *cc, *old_cc; struct menu *mi; struct menu_q menuq; - int m = (cargs->xev == CWM_XEV_BTN); int all = (cargs->flag & CWM_MENU_WINDOW_ALL); + int mflags = 0; + + if (cargs->xev == CWM_XEV_BTN) + mflags |= CWM_MENU_LIST; old_cc = client_current(); @@ -465,8 +468,7 @@ kbfunc_menu_client(void *ctx, struct cargs *cargs) menuq_add(&menuq, cc, NULL); } - if ((mi = menu_filter(sc, &menuq, - "window", NULL, ((m) ? CWM_MENU_LIST : 0), + if ((mi = menu_filter(sc, &menuq, "window", NULL, mflags, search_match_client, search_print_client)) != NULL) { cc = (struct client_ctx *)mi->ctx; if (cc->flags & CLIENT_HIDDEN) @@ -488,7 +490,10 @@ kbfunc_menu_cmd(void *ctx, struct cargs *cargs) struct cmd_ctx *cmd; struct menu *mi; struct menu_q menuq; - int m = (cargs->xev == CWM_XEV_BTN); + int mflags = 0; + + if (cargs->xev == CWM_XEV_BTN) + mflags |= CWM_MENU_LIST; TAILQ_INIT(&menuq); TAILQ_FOREACH(cmd, &Conf.cmdq, entry) { @@ -498,8 +503,7 @@ kbfunc_menu_cmd(void *ctx, struct cargs *cargs) menuq_add(&menuq, cmd, NULL); } - if ((mi = menu_filter(sc, &menuq, - "application", NULL, ((m) ? CWM_MENU_LIST : 0), + if ((mi = menu_filter(sc, &menuq, "application", NULL, mflags, search_match_cmd, search_print_cmd)) != NULL) { cmd = (struct cmd_ctx *)mi->ctx; u_spawn(cmd->path); @@ -515,7 +519,10 @@ kbfunc_menu_group(void *ctx, struct cargs *cargs) struct group_ctx *gc; struct menu *mi; struct menu_q menuq; - int m = (cargs->xev == CWM_XEV_BTN); + int mflags = 0; + + if (cargs->xev == CWM_XEV_BTN) + mflags |= CWM_MENU_LIST; TAILQ_INIT(&menuq); TAILQ_FOREACH(gc, &sc->groupq, entry) { @@ -524,8 +531,7 @@ kbfunc_menu_group(void *ctx, struct cargs *cargs) menuq_add(&menuq, gc, NULL); } - if ((mi = menu_filter(sc, &menuq, - "group", NULL, ((m) ? CWM_MENU_LIST : 0), + if ((mi = menu_filter(sc, &menuq, "group", NULL, mflags, search_match_group, search_print_group)) != NULL) { gc = (struct group_ctx *)mi->ctx; (group_holds_only_hidden(gc)) ? @@ -549,6 +555,7 @@ kbfunc_menu_exec(void *ctx, struct cargs *cargs) struct menu *mi; struct menu_q menuq; int l, i, cmd = cargs->flag; + int mflags = (CWM_MENU_DUMMY | CWM_MENU_FILE); switch (cmd) { case CWM_MENU_EXEC_EXEC: @@ -600,8 +607,7 @@ kbfunc_menu_exec(void *ctx, struct cargs *cargs) } free(path); - if ((mi = menu_filter(sc, &menuq, label, NULL, - (CWM_MENU_DUMMY | CWM_MENU_FILE), + if ((mi = menu_filter(sc, &menuq, label, NULL, mflags, search_match_exec, search_print_text)) != NULL) { if (mi->text[0] == '\0') goto out; @@ -639,6 +645,7 @@ kbfunc_menu_ssh(void *ctx, struct cargs *cargs) int l; size_t len; ssize_t slen; + int mflags = (CWM_MENU_DUMMY); TAILQ_FOREACH(cmd, &Conf.cmdq, entry) { if (strcmp(cmd->name, "term") == 0) @@ -674,7 +681,7 @@ kbfunc_menu_ssh(void *ctx, struct cargs *cargs) err(1, "%s", path); (void)fclose(fp); menu: - if ((mi = menu_filter(sc, &menuq, "ssh", NULL, (CWM_MENU_DUMMY), + if ((mi = menu_filter(sc, &menuq, "ssh", NULL, mflags, search_match_text, search_print_text)) != NULL) { if (mi->text[0] == '\0') goto out; @@ -696,11 +703,12 @@ kbfunc_client_menu_label(void *ctx, struct cargs *cargs) struct client_ctx *cc = ctx; struct menu *mi; struct menu_q menuq; + int mflags = (CWM_MENU_DUMMY); TAILQ_INIT(&menuq); /* dummy is set, so this will always return */ - mi = menu_filter(cc->sc, &menuq, "label", cc->label, (CWM_MENU_DUMMY), + mi = menu_filter(cc->sc, &menuq, "label", cc->label, mflags, search_match_text, search_print_text); if (!mi->abort) { diff --git a/menu.c b/menu.c index 2e84970..e00e8a9 100644 --- a/menu.c +++ b/menu.c @@ -179,13 +179,14 @@ menu_complete_path(struct menu_ctx *mc) struct screen_ctx *sc = mc->sc; struct menu *mi, *mr; struct menu_q menuq; + int mflags = (CWM_MENU_DUMMY); mr = xcalloc(1, sizeof(*mr)); TAILQ_INIT(&menuq); - if ((mi = menu_filter(sc, &menuq, mc->searchstr, NULL, - (CWM_MENU_DUMMY), search_match_path, search_print_text)) != NULL) { + if ((mi = menu_filter(sc, &menuq, mc->searchstr, NULL, mflags, + search_match_path, search_print_text)) != NULL) { mr->abort = mi->abort; mr->dummy = mi->dummy; if (mi->text[0] != '\0') |