From cb900def7f4da5216d567a27a04429d3dac85ae8 Mon Sep 17 00:00:00 2001 From: okan Date: Wed, 1 Jul 2015 14:36:42 +0000 Subject: style --- mousefunc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'mousefunc.c') diff --git a/mousefunc.c b/mousefunc.c index d709a3f..958fee2 100644 --- a/mousefunc.c +++ b/mousefunc.c @@ -43,8 +43,8 @@ mousefunc_sweep_calc(struct client_ctx *cc, int x, int y, int mx, int my) client_applysizehints(cc); - cc->geom.x = x <= mx ? x : x - cc->geom.w; - cc->geom.y = y <= my ? y : y - cc->geom.h; + cc->geom.x = (x <= mx) ? x : x - cc->geom.w; + cc->geom.y = (y <= my) ? y : y - cc->geom.h; } static void @@ -183,7 +183,7 @@ mousefunc_menu_group(struct client_ctx *cc, union arg *arg) if (group_holds_only_sticky(gc)) continue; menuq_add(&menuq, gc, - group_holds_only_hidden(gc) ? "%d: [%s]" : "%d: %s", + (group_holds_only_hidden(gc)) ? "%d: [%s]" : "%d: %s", gc->num, gc->name); } -- cgit 1.4.1 From 0d13b7c2205bd40d9fd4db016c8cf96f620c4f8d Mon Sep 17 00:00:00 2001 From: okan Date: Sun, 12 Jul 2015 14:31:47 +0000 Subject: introduce 'groupsearch' for group menu search; matches on either group number/shortcut and/or name. --- calmwm.h | 2 ++ conf.c | 1 + cwmrc.5 | 2 ++ kbfunc.c | 25 +++++++++++++++++++++++++ mousefunc.c | 6 ++---- search.c | 10 ++++++++++ 6 files changed, 42 insertions(+), 4 deletions(-) (limited to 'mousefunc.c') diff --git a/calmwm.h b/calmwm.h index 32cf00f..19c0a96 100644 --- a/calmwm.h +++ b/calmwm.h @@ -450,6 +450,7 @@ void search_match_text(struct menu_q *, struct menu_q *, char *); void search_print_client(struct menu *, int); void search_print_cmd(struct menu *, int); +void search_print_group(struct menu *, int); struct geom screen_apply_gap(struct screen_ctx *, struct geom); struct screen_ctx *screen_find(Window); @@ -496,6 +497,7 @@ void kbfunc_cwm_status(struct client_ctx *, union arg *); void kbfunc_exec(struct client_ctx *, union arg *); void kbfunc_lock(struct client_ctx *, union arg *); void kbfunc_menu_cmd(struct client_ctx *, union arg *); +void kbfunc_menu_group(struct client_ctx *, union arg *); void kbfunc_ssh(struct client_ctx *, union arg *); void kbfunc_term(struct client_ctx *, union arg *); void kbfunc_tile(struct client_ctx *, union arg *); diff --git a/conf.c b/conf.c index d0956a1..38c8c8c 100644 --- a/conf.c +++ b/conf.c @@ -360,6 +360,7 @@ static const struct { { "raise", kbfunc_client_raise, CWM_WIN, {0} }, { "search", kbfunc_client_search, 0, {0} }, { "menusearch", kbfunc_menu_cmd, 0, {0} }, + { "groupsearch", kbfunc_menu_group, 0, {0} }, { "hide", kbfunc_client_hide, CWM_WIN, {0} }, { "cycle", kbfunc_client_cycle, 0, {.i = CWM_CYCLE} }, { "rcycle", kbfunc_client_cycle, 0, {.i = CWM_RCYCLE} }, diff --git a/cwmrc.5 b/cwmrc.5 index 093060b..ee8dd78 100644 --- a/cwmrc.5 +++ b/cwmrc.5 @@ -251,6 +251,8 @@ Lock the screen. Launch window search menu. .It menusearch Launch application search menu. +.It groupsearch +Launch group search menu. .It exec Launch .Dq exec program diff --git a/kbfunc.c b/kbfunc.c index a107b95..ef4c49a 100644 --- a/kbfunc.c +++ b/kbfunc.c @@ -187,6 +187,31 @@ kbfunc_menu_cmd(struct client_ctx *cc, union arg *arg) menuq_clear(&menuq); } +void +kbfunc_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, "group", NULL, CWM_MENU_LIST, + search_match_text, 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 kbfunc_client_cycle(struct client_ctx *cc, union arg *arg) { diff --git a/mousefunc.c b/mousefunc.c index 958fee2..aef5b04 100644 --- a/mousefunc.c +++ b/mousefunc.c @@ -182,13 +182,11 @@ mousefunc_menu_group(struct client_ctx *cc, union arg *arg) TAILQ_FOREACH(gc, &sc->groupq, entry) { if (group_holds_only_sticky(gc)) continue; - menuq_add(&menuq, gc, - (group_holds_only_hidden(gc)) ? "%d: [%s]" : "%d: %s", - gc->num, gc->name); + menuq_add(&menuq, gc, "%d %s", gc->num, gc->name); } if ((mi = menu_filter(sc, &menuq, NULL, NULL, CWM_MENU_LIST, - NULL, NULL)) != NULL) { + NULL, search_print_group)) != NULL) { gc = (struct group_ctx *)mi->ctx; (group_holds_only_hidden(gc)) ? group_show(gc) : group_hide(gc); diff --git a/search.c b/search.c index 6526072..a960076 100644 --- a/search.c +++ b/search.c @@ -137,6 +137,16 @@ search_print_cmd(struct menu *mi, int i) (special) ? "[%s]" : "%s", cmd->name); } +void +search_print_group(struct menu *mi, int i) +{ + struct group_ctx *gc = (struct group_ctx *)mi->ctx; + + (void)snprintf(mi->print, sizeof(mi->print), + (group_holds_only_hidden(gc)) ? "%d: [%s]" : "%d: %s", + gc->num, gc->name); +} + void search_print_client(struct menu *mi, int list) { -- cgit 1.4.1