diff options
-rw-r--r-- | calmwm.h | 6 | ||||
-rw-r--r-- | conf.c | 11 | ||||
-rw-r--r-- | kbfunc.c | 31 | ||||
-rw-r--r-- | mousefunc.c | 79 |
4 files changed, 32 insertions, 95 deletions
@@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: calmwm.h,v 1.313 2016/09/20 19:11:19 okan Exp $ + * $OpenBSD: calmwm.h,v 1.314 2016/09/22 14:36:03 okan Exp $ */ #ifndef _CALMWM_H_ @@ -508,10 +508,6 @@ void mousefunc_client_move(struct client_ctx *, union arg *); void mousefunc_client_resize(struct client_ctx *, union arg *); -void mousefunc_menu_client(struct client_ctx *, - union arg *); -void mousefunc_menu_cmd(struct client_ctx *, union arg *); -void mousefunc_menu_group(struct client_ctx *, union arg *); struct menu *menu_filter(struct screen_ctx *, struct menu_q *, const char *, const char *, int, @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: conf.c,v 1.205 2016/09/12 13:47:00 okan Exp $ + * $OpenBSD: conf.c,v 1.206 2016/09/22 14:36:03 okan Exp $ */ #include <sys/types.h> @@ -485,9 +485,12 @@ static const struct { { "window_resize", mousefunc_client_resize, CWM_CONTEXT_CLIENT, {0} }, { "window_grouptoggle", kbfunc_client_grouptoggle, CWM_CONTEXT_CLIENT, {.i = CWM_MOUSE} }, - { "menu_group", mousefunc_menu_group, CWM_CONTEXT_SCREEN, {0} }, - { "menu_unhide", mousefunc_menu_client, CWM_CONTEXT_SCREEN, {0} }, - { "menu_cmd", mousefunc_menu_cmd, CWM_CONTEXT_SCREEN, {0} }, + { "menu_group", kbfunc_menu_group, CWM_CONTEXT_SCREEN, + {.i = CWM_MOUSE} }, + { "menu_unhide", kbfunc_menu_client, CWM_CONTEXT_SCREEN, + {.i = CWM_MOUSE} }, + { "menu_cmd", kbfunc_menu_cmd, CWM_CONTEXT_SCREEN, + {.i = CWM_MOUSE} }, }; static const struct { @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: kbfunc.c,v 1.126 2015/11/17 14:32:38 okan Exp $ + * $OpenBSD: kbfunc.c,v 1.127 2016/09/22 14:36:03 okan Exp $ */ #include <sys/types.h> @@ -167,14 +167,22 @@ kbfunc_menu_client(struct client_ctx *cc, union arg *arg) struct client_ctx *old_cc; struct menu *mi; struct menu_q menuq; + int m = (arg->i == CWM_MOUSE); old_cc = client_current(); TAILQ_INIT(&menuq); - TAILQ_FOREACH(cc, &sc->clientq, entry) - menuq_add(&menuq, cc, NULL); + TAILQ_FOREACH(cc, &sc->clientq, entry) { + if (m) { + if (cc->flags & CLIENT_HIDDEN) + menuq_add(&menuq, cc, NULL); + } else + menuq_add(&menuq, cc, NULL); + } - if ((mi = menu_filter(sc, &menuq, "window", NULL, 0, + if ((mi = menu_filter(sc, &menuq, + (m) ? NULL : "window", NULL, + (m) ? CWM_MENU_LIST : 0, search_match_client, search_print_client)) != NULL) { cc = (struct client_ctx *)mi->ctx; if (cc->flags & CLIENT_HIDDEN) @@ -194,6 +202,7 @@ kbfunc_menu_cmd(struct client_ctx *cc, union arg *arg) struct cmd *cmd; struct menu *mi; struct menu_q menuq; + int m = (arg->i == CWM_MOUSE); TAILQ_INIT(&menuq); TAILQ_FOREACH(cmd, &Conf.cmdq, entry) { @@ -204,9 +213,13 @@ kbfunc_menu_cmd(struct client_ctx *cc, union arg *arg) menuq_add(&menuq, cmd, "%s", cmd->name); } - if ((mi = menu_filter(sc, &menuq, "application", NULL, 0, - search_match_text, search_print_cmd)) != NULL) - u_spawn(((struct cmd *)mi->ctx)->path); + if ((mi = menu_filter(sc, &menuq, + (m) ? NULL : "application", NULL, + (m) ? CWM_MENU_LIST : 0, + search_match_text, search_print_cmd)) != NULL) { + cmd = (struct cmd *)mi->ctx; + u_spawn(cmd->path); + } menuq_clear(&menuq); } @@ -218,6 +231,7 @@ kbfunc_menu_group(struct client_ctx *cc, union arg *arg) struct group_ctx *gc; struct menu *mi; struct menu_q menuq; + int m = (arg->i == CWM_MOUSE); TAILQ_INIT(&menuq); TAILQ_FOREACH(gc, &sc->groupq, entry) { @@ -226,7 +240,8 @@ kbfunc_menu_group(struct client_ctx *cc, union arg *arg) menuq_add(&menuq, gc, "%d %s", gc->num, gc->name); } - if ((mi = menu_filter(sc, &menuq, "group", NULL, CWM_MENU_LIST, + if ((mi = menu_filter(sc, &menuq, + (m) ? NULL : "group", NULL, CWM_MENU_LIST, search_match_text, search_print_group)) != NULL) { gc = (struct group_ctx *)mi->ctx; (group_holds_only_hidden(gc)) ? diff --git a/mousefunc.c b/mousefunc.c index f72416f..8fa3c82 100644 --- a/mousefunc.c +++ b/mousefunc.c @@ -16,7 +16,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: mousefunc.c,v 1.104 2016/09/13 13:42:28 okan Exp $ + * $OpenBSD: mousefunc.c,v 1.105 2016/09/22 14:36:03 okan Exp $ */ #include <sys/types.h> @@ -155,80 +155,3 @@ mousefunc_client_move(struct client_ctx *cc, union arg *arg) } /* NOTREACHED */ } - -void -mousefunc_menu_group(struct client_ctx *cc, union arg *arg) -{ - struct screen_ctx *sc = cc->sc; - struct group_ctx *gc; - struct menu *mi; - struct menu_q menuq; - - TAILQ_INIT(&menuq); - TAILQ_FOREACH(gc, &sc->groupq, entry) { - if (group_holds_only_sticky(gc)) - continue; - menuq_add(&menuq, gc, "%d %s", gc->num, gc->name); - } - - if ((mi = menu_filter(sc, &menuq, NULL, NULL, CWM_MENU_LIST, - NULL, search_print_group)) != NULL) { - gc = (struct group_ctx *)mi->ctx; - (group_holds_only_hidden(gc)) ? - group_show(gc) : group_hide(gc); - } - - menuq_clear(&menuq); -} - -void -mousefunc_menu_client(struct client_ctx *cc, union arg *arg) -{ - struct screen_ctx *sc = cc->sc; - struct client_ctx *old_cc; - struct menu *mi; - struct menu_q menuq; - - old_cc = client_current(); - - TAILQ_INIT(&menuq); - TAILQ_FOREACH(cc, &sc->clientq, entry) { - if (cc->flags & CLIENT_HIDDEN) { - menuq_add(&menuq, cc, NULL); - } - } - - if ((mi = menu_filter(sc, &menuq, NULL, NULL, CWM_MENU_LIST, - NULL, search_print_client)) != NULL) { - cc = (struct client_ctx *)mi->ctx; - client_unhide(cc); - if (old_cc != NULL) - client_ptrsave(old_cc); - client_ptrwarp(cc); - } - - menuq_clear(&menuq); -} - -void -mousefunc_menu_cmd(struct client_ctx *cc, union arg *arg) -{ - struct screen_ctx *sc = cc->sc; - struct cmd *cmd; - struct menu *mi; - struct menu_q menuq; - - TAILQ_INIT(&menuq); - TAILQ_FOREACH(cmd, &Conf.cmdq, entry) { - if ((strcmp(cmd->name, "lock") == 0) || - (strcmp(cmd->name, "term") == 0)) - continue; - menuq_add(&menuq, cmd, NULL); - } - - if ((mi = menu_filter(sc, &menuq, NULL, NULL, CWM_MENU_LIST, - NULL, search_print_cmd)) != NULL) - u_spawn(((struct cmd *)mi->ctx)->path); - - menuq_clear(&menuq); -} |