mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
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.
This commit is contained in:
parent
3947f1268a
commit
57b2a6cf79
4
calmwm.h
4
calmwm.h
@ -508,10 +508,6 @@ void mousefunc_client_move(struct client_ctx *,
|
|||||||
union arg *);
|
union arg *);
|
||||||
void mousefunc_client_resize(struct client_ctx *,
|
void mousefunc_client_resize(struct client_ctx *,
|
||||||
union arg *);
|
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 *,
|
struct menu *menu_filter(struct screen_ctx *, struct menu_q *,
|
||||||
const char *, const char *, int,
|
const char *, const char *, int,
|
||||||
|
9
conf.c
9
conf.c
@ -485,9 +485,12 @@ static const struct {
|
|||||||
{ "window_resize", mousefunc_client_resize, CWM_CONTEXT_CLIENT, {0} },
|
{ "window_resize", mousefunc_client_resize, CWM_CONTEXT_CLIENT, {0} },
|
||||||
{ "window_grouptoggle", kbfunc_client_grouptoggle, CWM_CONTEXT_CLIENT,
|
{ "window_grouptoggle", kbfunc_client_grouptoggle, CWM_CONTEXT_CLIENT,
|
||||||
{.i = CWM_MOUSE} },
|
{.i = CWM_MOUSE} },
|
||||||
{ "menu_group", mousefunc_menu_group, CWM_CONTEXT_SCREEN, {0} },
|
{ "menu_group", kbfunc_menu_group, CWM_CONTEXT_SCREEN,
|
||||||
{ "menu_unhide", mousefunc_menu_client, CWM_CONTEXT_SCREEN, {0} },
|
{.i = CWM_MOUSE} },
|
||||||
{ "menu_cmd", mousefunc_menu_cmd, CWM_CONTEXT_SCREEN, {0} },
|
{ "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 {
|
static const struct {
|
||||||
|
29
kbfunc.c
29
kbfunc.c
@ -167,14 +167,22 @@ kbfunc_menu_client(struct client_ctx *cc, union arg *arg)
|
|||||||
struct client_ctx *old_cc;
|
struct client_ctx *old_cc;
|
||||||
struct menu *mi;
|
struct menu *mi;
|
||||||
struct menu_q menuq;
|
struct menu_q menuq;
|
||||||
|
int m = (arg->i == CWM_MOUSE);
|
||||||
|
|
||||||
old_cc = client_current();
|
old_cc = client_current();
|
||||||
|
|
||||||
TAILQ_INIT(&menuq);
|
TAILQ_INIT(&menuq);
|
||||||
TAILQ_FOREACH(cc, &sc->clientq, entry)
|
TAILQ_FOREACH(cc, &sc->clientq, entry) {
|
||||||
menuq_add(&menuq, cc, NULL);
|
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) {
|
search_match_client, search_print_client)) != NULL) {
|
||||||
cc = (struct client_ctx *)mi->ctx;
|
cc = (struct client_ctx *)mi->ctx;
|
||||||
if (cc->flags & CLIENT_HIDDEN)
|
if (cc->flags & CLIENT_HIDDEN)
|
||||||
@ -194,6 +202,7 @@ kbfunc_menu_cmd(struct client_ctx *cc, union arg *arg)
|
|||||||
struct cmd *cmd;
|
struct cmd *cmd;
|
||||||
struct menu *mi;
|
struct menu *mi;
|
||||||
struct menu_q menuq;
|
struct menu_q menuq;
|
||||||
|
int m = (arg->i == CWM_MOUSE);
|
||||||
|
|
||||||
TAILQ_INIT(&menuq);
|
TAILQ_INIT(&menuq);
|
||||||
TAILQ_FOREACH(cmd, &Conf.cmdq, entry) {
|
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);
|
menuq_add(&menuq, cmd, "%s", cmd->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((mi = menu_filter(sc, &menuq, "application", NULL, 0,
|
if ((mi = menu_filter(sc, &menuq,
|
||||||
search_match_text, search_print_cmd)) != NULL)
|
(m) ? NULL : "application", NULL,
|
||||||
u_spawn(((struct cmd *)mi->ctx)->path);
|
(m) ? CWM_MENU_LIST : 0,
|
||||||
|
search_match_text, search_print_cmd)) != NULL) {
|
||||||
|
cmd = (struct cmd *)mi->ctx;
|
||||||
|
u_spawn(cmd->path);
|
||||||
|
}
|
||||||
|
|
||||||
menuq_clear(&menuq);
|
menuq_clear(&menuq);
|
||||||
}
|
}
|
||||||
@ -218,6 +231,7 @@ kbfunc_menu_group(struct client_ctx *cc, union arg *arg)
|
|||||||
struct group_ctx *gc;
|
struct group_ctx *gc;
|
||||||
struct menu *mi;
|
struct menu *mi;
|
||||||
struct menu_q menuq;
|
struct menu_q menuq;
|
||||||
|
int m = (arg->i == CWM_MOUSE);
|
||||||
|
|
||||||
TAILQ_INIT(&menuq);
|
TAILQ_INIT(&menuq);
|
||||||
TAILQ_FOREACH(gc, &sc->groupq, entry) {
|
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);
|
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) {
|
search_match_text, search_print_group)) != NULL) {
|
||||||
gc = (struct group_ctx *)mi->ctx;
|
gc = (struct group_ctx *)mi->ctx;
|
||||||
(group_holds_only_hidden(gc)) ?
|
(group_holds_only_hidden(gc)) ?
|
||||||
|
77
mousefunc.c
77
mousefunc.c
@ -155,80 +155,3 @@ mousefunc_client_move(struct client_ctx *cc, union arg *arg)
|
|||||||
}
|
}
|
||||||
/* NOTREACHED */
|
/* 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);
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user