From 7f3adeacc740bfe47f45a7c16bb7f2e242e0e8aa Mon Sep 17 00:00:00 2001 From: okan Date: Mon, 19 May 2008 17:11:19 +0000 Subject: [PATCH] as done with cycle/rcycle, make prev/next group switching one kbfuncs and use a flag; adjusted to match and rename to {r,}cycle. "ok, since i came up with the same thing" oga@ --- app/cwm/calmwm.h | 12 +++++++----- app/cwm/conf.c | 10 +++++----- app/cwm/cwm.1 | 6 +++--- app/cwm/group.c | 17 +++++++---------- app/cwm/kbfunc.c | 12 +++--------- 5 files changed, 25 insertions(+), 32 deletions(-) diff --git a/app/cwm/calmwm.h b/app/cwm/calmwm.h index 78c0268aa..2d1463789 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. * - * $Id: calmwm.h,v 1.43 2008/05/19 15:17:50 oga Exp $ + * $Id: calmwm.h,v 1.44 2008/05/19 17:11:19 okan Exp $ */ #ifndef _CALMWM_H_ @@ -221,9 +221,12 @@ TAILQ_HEAD(winmatch_q, winmatch); /* for cwm_exec */ #define CWM_EXEC_PROGRAM 0x1 #define CWM_EXEC_WM 0x2 -/* For alt-tab */ +/* for alt-tab */ #define CWM_CYCLE 0x0 #define CWM_RCYCLE 0x1 +/* for group cycle */ +#define CWM_CYCLEGROUP 0x0 +#define CWM_RCYCLEGROUP 0x1 #define KBFLAG_NEEDCLIENT 0x01 @@ -434,8 +437,7 @@ void kbfunc_cmdexec(struct client_ctx *, void *); void kbfunc_client_label(struct client_ctx *, void *); void kbfunc_client_delete(struct client_ctx *, void *); void kbfunc_client_group(struct client_ctx *, void *); -void kbfunc_client_nextgroup(struct client_ctx *, void *); -void kbfunc_client_prevgroup(struct client_ctx *, void *); +void kbfunc_client_cyclegroup(struct client_ctx *, void *); void kbfunc_client_nogroup(struct client_ctx *, void *); void kbfunc_client_grouptoggle(struct client_ctx *, void *); void kbfunc_client_maximize(struct client_ctx *, void *); @@ -463,7 +465,7 @@ void search_match_exec(struct menu_q *, struct menu_q *, void group_init(void); void group_hidetoggle(int); -void group_slide(int); +void group_cycle(int); void group_sticky(struct client_ctx *); void group_client_delete(struct client_ctx *); void group_menu(XButtonEvent *); diff --git a/app/cwm/conf.c b/app/cwm/conf.c index 3c4adb9f1..35f3577d0 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. * - * $Id: conf.c,v 1.33 2008/05/19 15:17:50 oga Exp $ + * $Id: conf.c,v 1.34 2008/05/19 17:11:19 okan Exp $ */ #include "headers.h" @@ -115,8 +115,8 @@ conf_init(struct conf *c) conf_bindname(c, "CM-7", "group7"); conf_bindname(c, "CM-8", "group8"); conf_bindname(c, "CM-9", "group9"); - conf_bindname(c, "M-Right", "nextgroup"); - conf_bindname(c, "M-Left", "prevgroup"); + conf_bindname(c, "M-Right", "cyclegroup"); + conf_bindname(c, "M-Left", "rcyclegroup"); conf_bindname(c, "CM-g", "grouptoggle"); conf_bindname(c, "CM-f", "maximize"); conf_bindname(c, "CM-equal", "vmaximize"); @@ -223,8 +223,8 @@ struct { { "group8", kbfunc_client_group, 0, (void *)8 }, { "group9", kbfunc_client_group, 0, (void *)9 }, { "nogroup", kbfunc_client_nogroup, 0, 0 }, - { "nextgroup", kbfunc_client_nextgroup, 0, 0 }, - { "prevgroup", kbfunc_client_prevgroup, 0, 0 }, + { "cyclegroup", kbfunc_client_cyclegroup, 0, (void *)CWM_CYCLEGROUP }, + { "rcyclegroup", kbfunc_client_cyclegroup, 0, (void *)CWM_RCYCLEGROUP }, { "grouptoggle", kbfunc_client_grouptoggle, KBFLAG_NEEDCLIENT, 0}, { "maximize", kbfunc_client_maximize, KBFLAG_NEEDCLIENT, 0 }, { "vmaximize", kbfunc_client_vmaximize, KBFLAG_NEEDCLIENT, 0 }, diff --git a/app/cwm/cwm.1 b/app/cwm/cwm.1 index 6eaad75e9..00f74ad63 100644 --- a/app/cwm/cwm.1 +++ b/app/cwm/cwm.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: cwm.1,v 1.28 2008/05/19 12:56:58 okan Exp $ +.\" $OpenBSD: cwm.1,v 1.29 2008/05/19 17:11:19 okan Exp $ .\" .\" Copyright (c) 2004,2005 Marius Aamodt Eriksen .\" @@ -86,9 +86,9 @@ Select all groups. .It Ic C-M-g Toggle a window's membership in the current group. .It Ic M-Right -Switch to next group. +Cycle through active groups. .It Ic M-Left -Switch to previous group. +Reverse cycle through active groups. .It Ic C-M-f Toggle full-screen size of window. .It Ic C-M-= diff --git a/app/cwm/group.c b/app/cwm/group.c index dd190afef..f96e8f1fe 100644 --- a/app/cwm/group.c +++ b/app/cwm/group.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. * - * $Id: group.c,v 1.14 2008/05/18 20:00:16 okan Exp $ + * $Id: group.c,v 1.15 2008/05/19 17:11:19 okan Exp $ */ #include "headers.h" @@ -195,15 +195,11 @@ group_hidetoggle(int idx) } } -#define GROUP_NEXT(gc, fwd) (fwd) ? \ - TAILQ_NEXT(gc, entry) : TAILQ_PREV(gc, group_ctx_q, entry) - /* - * Jump to the next/previous active group. If none exist, then just - * stay put. + * Cycle through active groups. If none exist, then just stay put. */ void -group_slide(int fwd) +group_cycle(int reverse) { struct group_ctx *gc, *showgroup = NULL; @@ -211,10 +207,11 @@ group_slide(int fwd) gc = Group_active; for (;;) { - gc = GROUP_NEXT(gc, fwd); + gc = reverse ? TAILQ_PREV(gc, group_ctx_q, entry) : + TAILQ_NEXT(gc, entry); if (gc == NULL) - gc = fwd ? TAILQ_FIRST(&Groupq) : - TAILQ_LAST(&Groupq, group_ctx_q); + gc = reverse ? TAILQ_LAST(&Groupq, group_ctx_q) : + TAILQ_FIRST(&Groupq); if (gc == Group_active) break; diff --git a/app/cwm/kbfunc.c b/app/cwm/kbfunc.c index 7c98c379e..e4a3574de 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. * - * $Id: kbfunc.c,v 1.24 2008/05/19 15:17:50 oga Exp $ + * $Id: kbfunc.c,v 1.25 2008/05/19 17:11:19 okan Exp $ */ #include @@ -412,15 +412,9 @@ kbfunc_client_group(struct client_ctx *cc, void *arg) } void -kbfunc_client_nextgroup(struct client_ctx *cc, void *arg) +kbfunc_client_cyclegroup(struct client_ctx *cc, void *arg) { - group_slide(1); -} - -void -kbfunc_client_prevgroup(struct client_ctx *cc, void *arg) -{ - group_slide(0); + group_cycle((int)arg); } void