summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorOkan Demirmen <okan@cvs.openbsd.org>2016-09-22 14:36:04 +0000
committerOkan Demirmen <okan@cvs.openbsd.org>2016-09-22 14:36:04 +0000
commite1214d93bf5b82e9127e10737fd325f08add0715 (patch)
treea7ece186bac7c535a18d5e6dc93741740cbf403b /app
parenta9acfb9be6d8934256468d8a8fdc8799c8027a37 (diff)
Continue merging kb and mouse functions: fold
mousefunc_menu_{client,cmd,group} into the respective kbfunc_menu_{client,cmd,group} functions; simply pass a flag down from config denoting mouse action behaviour.
Diffstat (limited to 'app')
-rw-r--r--app/cwm/calmwm.h6
-rw-r--r--app/cwm/conf.c11
-rw-r--r--app/cwm/kbfunc.c31
-rw-r--r--app/cwm/mousefunc.c79
4 files changed, 32 insertions, 95 deletions
diff --git a/app/cwm/calmwm.h b/app/cwm/calmwm.h
index 4c95018b9..ac32e9606 100644
--- a/app/cwm/calmwm.h
+++ b/app/cwm/calmwm.h
@@ -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,
diff --git a/app/cwm/conf.c b/app/cwm/conf.c
index bdf079c10..f414bb50d 100644
--- a/app/cwm/conf.c
+++ b/app/cwm/conf.c
@@ -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 {
diff --git a/app/cwm/kbfunc.c b/app/cwm/kbfunc.c
index 3d3234943..91d7a2aa8 100644
--- a/app/cwm/kbfunc.c
+++ b/app/cwm/kbfunc.c
@@ -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/app/cwm/mousefunc.c b/app/cwm/mousefunc.c
index f72416f9f..8fa3c82ea 100644
--- a/app/cwm/mousefunc.c
+++ b/app/cwm/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);
-}