From 396ab2c5818d5fb12d474bbb4caa43c1f3be7fc5 Mon Sep 17 00:00:00 2001 From: okan Date: Sat, 3 Sep 2011 09:20:58 +0000 Subject: Add {r,}cycleingroup to cycle through clients belonging to the same group as the active client (as opposed to all unhidden clients); from Alexander Polakov, with a tiny tweak requested by oga. ok oga@ --- calmwm.h | 7 ++++--- client.c | 11 ++++++----- conf.c | 4 +++- cwmrc.5 | 8 ++++++-- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/calmwm.h b/calmwm.h index e9b284a..5156fa7 100644 --- a/calmwm.h +++ b/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.136 2011/09/03 09:17:16 okan Exp $ + * $OpenBSD: calmwm.h,v 1.137 2011/09/03 09:20:58 okan Exp $ */ #ifndef _CALMWM_H_ @@ -68,8 +68,9 @@ #define CWM_EXEC_WM 0x0002 /* cycle */ -#define CWM_CYCLE 0 -#define CWM_RCYCLE 1 +#define CWM_CYCLE 0x0001 +#define CWM_RCYCLE 0x0002 +#define CWM_INGROUP 0x0004 #define KBTOGROUP(X) ((X) - 1) diff --git a/client.c b/client.c index a946337..6359a35 100644 --- a/client.c +++ b/client.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: client.c,v 1.86 2011/07/14 11:39:53 okan Exp $ + * $OpenBSD: client.c,v 1.87 2011/09/03 09:20:58 okan Exp $ */ #include @@ -567,7 +567,7 @@ match: } void -client_cycle(struct screen_ctx *sc, int reverse) +client_cycle(struct screen_ctx *sc, int flags) { struct client_ctx *oldcc, *newcc; int again = 1; @@ -579,18 +579,19 @@ client_cycle(struct screen_ctx *sc, int reverse) return; if (oldcc == NULL) - oldcc = (reverse ? TAILQ_LAST(&sc->mruq, cycle_entry_q) : + oldcc = (flags & CWM_RCYCLE ? TAILQ_LAST(&sc->mruq, cycle_entry_q) : TAILQ_FIRST(&sc->mruq)); newcc = oldcc; while (again) { again = 0; - newcc = (reverse ? client_mruprev(newcc) : + newcc = (flags & CWM_RCYCLE ? client_mruprev(newcc) : client_mrunext(newcc)); /* Only cycle visible and non-ignored windows. */ - if (newcc->flags & (CLIENT_HIDDEN|CLIENT_IGNORE)) + if ((newcc->flags & (CLIENT_HIDDEN|CLIENT_IGNORE)) + || ((flags & CWM_INGROUP) && (newcc->group != oldcc->group))) again = 1; /* Is oldcc the only non-hidden window? */ diff --git a/conf.c b/conf.c index 656133e..190470f 100644 --- a/conf.c +++ b/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.92 2011/09/03 09:17:16 okan Exp $ + * $OpenBSD: conf.c,v 1.93 2011/09/03 09:20:58 okan Exp $ */ #include @@ -359,6 +359,8 @@ static struct { { "nogroup", kbfunc_client_nogroup, 0, {0} }, { "cyclegroup", kbfunc_client_cyclegroup, 0, {.i = CWM_CYCLE} }, { "rcyclegroup", kbfunc_client_cyclegroup, 0, {.i = CWM_RCYCLE} }, + { "cycleingroup", kbfunc_client_cycle, KBFLAG_NEEDCLIENT, {.i = CWM_CYCLE|CWM_INGROUP} }, + { "rcycleingroup", kbfunc_client_cycle, KBFLAG_NEEDCLIENT, {.i = CWM_RCYCLE|CWM_INGROUP} }, { "grouptoggle", kbfunc_client_grouptoggle, KBFLAG_NEEDCLIENT, {0}}, { "maximize", kbfunc_client_maximize, KBFLAG_NEEDCLIENT, {0} }, { "vmaximize", kbfunc_client_vmaximize, KBFLAG_NEEDCLIENT, {0} }, diff --git a/cwmrc.5 b/cwmrc.5 index f9dd9f5..5443dd5 100644 --- a/cwmrc.5 +++ b/cwmrc.5 @@ -1,4 +1,4 @@ -.\" $OpenBSD: cwmrc.5,v 1.38 2011/06/25 13:12:56 okan Exp $ +.\" $OpenBSD: cwmrc.5,v 1.39 2011/09/03 09:20:58 okan Exp $ .\" .\" Copyright (c) 2004,2005 Marius Aamodt Eriksen .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: June 25 2011 $ +.Dd $Mdocdate: September 3 2011 $ .Dt CWMRC 5 .Os .Sh NAME @@ -289,6 +289,10 @@ Reverse cycle through groups. Forward cycle through windows. .It rcycle Reverse cycle through windows. +.It cycleingroup +Forward cycle through windows in current group. +.It rcycleingroup +Reverse cycle through windows in current group. .It snapdist Minimum distance to snap-to adjacent edge. .It delete -- cgit v1.2.3-2-gb3c3