summary refs log tree commit diff
diff options
context:
space:
mode:
authorokan <okan>2019-02-25 16:40:49 +0000
committerokan <okan>2019-02-25 16:40:49 +0000
commita5ba9aa9da9567244d1c3d1d8ccacfdb51b044de (patch)
treec79190375cd8f32a840bdc7978dfea10a0c65959
parent43cd19378ed244f9bd9f86e51bca0f3905055bdf (diff)
downloadcwm-a5ba9aa9da9567244d1c3d1d8ccacfdb51b044de.tar.gz
cwm-a5ba9aa9da9567244d1c3d1d8ccacfdb51b044de.tar.xz
cwm-a5ba9aa9da9567244d1c3d1d8ccacfdb51b044de.zip
Add 'group-close-[n]' action to close all windows within specified group.
heavily based on a diff from Nam Nguyen.
-rw-r--r--calmwm.h2
-rw-r--r--conf.c9
-rw-r--r--cwmrc.52
-rw-r--r--group.c17
-rw-r--r--kbfunc.c6
5 files changed, 36 insertions, 0 deletions
diff --git a/calmwm.h b/calmwm.h
index 44d7f62..15dd247 100644
--- a/calmwm.h
+++ b/calmwm.h
@@ -451,6 +451,7 @@ int			 group_holds_only_sticky(struct group_ctx *);
 void			 group_init(struct screen_ctx *, int);
 void			 group_movetogroup(struct client_ctx *, int);
 void			 group_only(struct screen_ctx *, int);
+void			 group_close(struct screen_ctx *, int);
 int			 group_restore(struct client_ctx *);
 void			 group_show(struct group_ctx *);
 void			 group_toggle_membership(struct client_ctx *);
@@ -508,6 +509,7 @@ void			 kbfunc_client_toggle_group(void *, struct cargs *);
 void			 kbfunc_client_movetogroup(void *, struct cargs *);
 void			 kbfunc_group_toggle(void *, struct cargs *);
 void			 kbfunc_group_only(void *, struct cargs *);
+void			 kbfunc_group_close(void *, struct cargs *);
 void			 kbfunc_group_cycle(void *, struct cargs *);
 void			 kbfunc_group_alltoggle(void *, struct cargs *);
 void			 kbfunc_menu_client(void *, struct cargs *);
diff --git a/conf.c b/conf.c
index 5d75bac..e54f96a 100644
--- a/conf.c
+++ b/conf.c
@@ -143,6 +143,15 @@ static const struct {
 	{ FUNC_SC(group-only-7, group_only, 7) },
 	{ FUNC_SC(group-only-8, group_only, 8) },
 	{ FUNC_SC(group-only-9, group_only, 9) },
+	{ FUNC_SC(group-close-1, group_close, 1) },
+	{ FUNC_SC(group-close-2, group_close, 2) },
+	{ FUNC_SC(group-close-3, group_close, 3) },
+	{ FUNC_SC(group-close-4, group_close, 4) },
+	{ FUNC_SC(group-close-5, group_close, 5) },
+	{ FUNC_SC(group-close-6, group_close, 6) },
+	{ FUNC_SC(group-close-7, group_close, 7) },
+	{ FUNC_SC(group-close-8, group_close, 8) },
+	{ FUNC_SC(group-close-9, group_close, 9) },
 
 	{ FUNC_SC(pointer-move-up, ptrmove, (CWM_UP)) },
 	{ FUNC_SC(pointer-move-down, ptrmove, (CWM_DOWN)) },
diff --git a/cwmrc.5 b/cwmrc.5
index 609202e..7434d66 100644
--- a/cwmrc.5
+++ b/cwmrc.5
@@ -288,6 +288,8 @@ menu.
 Toggle visibility of group n, where n is 1-9.
 .It group-only-[n]
 Show only group n, where n is 1-9, hiding other groups.
+.It group-close-[n]
+Close all windows in group n, where n is 1-9.
 .It group-toggle-all
 Toggle visibility of all groups.
 .It window-group
diff --git a/group.c b/group.c
index 4c25bcc..30fe718 100644
--- a/group.c
+++ b/group.c
@@ -250,6 +250,23 @@ group_only(struct screen_ctx *sc, int idx)
 }
 
 void
+group_close(struct screen_ctx *sc, int idx)
+{
+	struct group_ctx	*gc;
+	struct client_ctx	*cc;
+
+	if (idx < 0 || idx >= Conf.ngroups)
+		return;
+
+	TAILQ_FOREACH(gc, &sc->groupq, entry) {
+		if (gc->num == idx) {
+			TAILQ_FOREACH(cc, &gc->clientq, group_entry)
+				client_close(cc);
+		}
+	}
+}
+
+void
 group_cycle(struct screen_ctx *sc, int flags)
 {
 	struct group_ctx	*newgc, *oldgc, *showgroup = NULL;
diff --git a/kbfunc.c b/kbfunc.c
index 55d206d..35b9b22 100644
--- a/kbfunc.c
+++ b/kbfunc.c
@@ -441,6 +441,12 @@ kbfunc_group_only(void *ctx, struct cargs *cargs)
 }
 
 void
+kbfunc_group_close(void *ctx, struct cargs *cargs)
+{
+	group_close(ctx, cargs->flag);
+}
+
+void
 kbfunc_group_cycle(void *ctx, struct cargs *cargs)
 {
 	group_cycle(ctx, cargs->flag);