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@
This commit is contained in:
okan 2008-05-19 17:11:19 +00:00
parent 43d6e147c2
commit d347aa3d9a
5 changed files with 21 additions and 28 deletions

View File

@ -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 *);

8
conf.c
View File

@ -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 },

6
cwm.1
View File

@ -15,7 +15,7 @@
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.\" The following requests are required for all man pages.
.Dd $Mdocdate: April 15 2008 $
.Dd $Mdocdate: May 19 2008 $
.Dt CWM 1
.Os
.Sh NAME
@ -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-=

15
group.c
View File

@ -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;

View File

@ -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