mirror of
https://github.com/leahneukirchen/cwm.git
synced 2023-08-10 21:13:12 +03:00
Bring group and client cycle closer together.
This commit is contained in:
parent
54bbd88e51
commit
871c9f24ba
22
client.c
22
client.c
@ -647,7 +647,7 @@ match:
|
|||||||
void
|
void
|
||||||
client_cycle(struct screen_ctx *sc, int flags)
|
client_cycle(struct screen_ctx *sc, int flags)
|
||||||
{
|
{
|
||||||
struct client_ctx *oldcc, *newcc;
|
struct client_ctx *newcc, *oldcc;
|
||||||
int again = 1;
|
int again = 1;
|
||||||
|
|
||||||
if (TAILQ_EMPTY(&sc->clientq))
|
if (TAILQ_EMPTY(&sc->clientq))
|
||||||
@ -655,16 +655,16 @@ client_cycle(struct screen_ctx *sc, int flags)
|
|||||||
|
|
||||||
oldcc = client_current();
|
oldcc = client_current();
|
||||||
if (oldcc == NULL)
|
if (oldcc == NULL)
|
||||||
oldcc = ((flags & CWM_RCYCLE) ?
|
oldcc = (flags & CWM_RCYCLE) ?
|
||||||
TAILQ_LAST(&sc->clientq, client_ctx_q) :
|
TAILQ_LAST(&sc->clientq, client_ctx_q) :
|
||||||
TAILQ_FIRST(&sc->clientq));
|
TAILQ_FIRST(&sc->clientq);
|
||||||
|
|
||||||
newcc = oldcc;
|
newcc = oldcc;
|
||||||
while (again) {
|
while (again) {
|
||||||
again = 0;
|
again = 0;
|
||||||
|
|
||||||
newcc = ((flags & CWM_RCYCLE) ? client_prev(newcc) :
|
newcc = (flags & CWM_RCYCLE) ? client_prev(newcc) :
|
||||||
client_next(newcc));
|
client_next(newcc);
|
||||||
|
|
||||||
/* Only cycle visible and non-ignored windows. */
|
/* Only cycle visible and non-ignored windows. */
|
||||||
if ((newcc->flags & (CLIENT_HIDDEN|CLIENT_IGNORE))
|
if ((newcc->flags & (CLIENT_HIDDEN|CLIENT_IGNORE))
|
||||||
@ -705,20 +705,20 @@ static struct client_ctx *
|
|||||||
client_next(struct client_ctx *cc)
|
client_next(struct client_ctx *cc)
|
||||||
{
|
{
|
||||||
struct screen_ctx *sc = cc->sc;
|
struct screen_ctx *sc = cc->sc;
|
||||||
struct client_ctx *ccc;
|
struct client_ctx *newcc;
|
||||||
|
|
||||||
return(((ccc = TAILQ_NEXT(cc, entry)) != NULL) ?
|
return(((newcc = TAILQ_NEXT(cc, entry)) != NULL) ?
|
||||||
ccc : TAILQ_FIRST(&sc->clientq));
|
newcc : TAILQ_FIRST(&sc->clientq));
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct client_ctx *
|
static struct client_ctx *
|
||||||
client_prev(struct client_ctx *cc)
|
client_prev(struct client_ctx *cc)
|
||||||
{
|
{
|
||||||
struct screen_ctx *sc = cc->sc;
|
struct screen_ctx *sc = cc->sc;
|
||||||
struct client_ctx *ccc;
|
struct client_ctx *newcc;
|
||||||
|
|
||||||
return(((ccc = TAILQ_PREV(cc, client_ctx_q, entry)) != NULL) ?
|
return(((newcc = TAILQ_PREV(cc, client_ctx_q, entry)) != NULL) ?
|
||||||
ccc : TAILQ_LAST(&sc->clientq, client_ctx_q));
|
newcc : TAILQ_LAST(&sc->clientq, client_ctx_q));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
54
group.c
54
group.c
@ -32,6 +32,8 @@
|
|||||||
|
|
||||||
#include "calmwm.h"
|
#include "calmwm.h"
|
||||||
|
|
||||||
|
static struct group_ctx *group_next(struct group_ctx *);
|
||||||
|
static struct group_ctx *group_prev(struct group_ctx *);
|
||||||
static void group_assign(struct group_ctx *, struct client_ctx *);
|
static void group_assign(struct group_ctx *, struct client_ctx *);
|
||||||
static void group_restack(struct group_ctx *);
|
static void group_restack(struct group_ctx *);
|
||||||
static void group_setactive(struct group_ctx *);
|
static void group_setactive(struct group_ctx *);
|
||||||
@ -255,36 +257,28 @@ group_only(struct screen_ctx *sc, int idx)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Cycle through active groups. If none exist, then just stay put.
|
|
||||||
*/
|
|
||||||
void
|
void
|
||||||
group_cycle(struct screen_ctx *sc, int flags)
|
group_cycle(struct screen_ctx *sc, int flags)
|
||||||
{
|
{
|
||||||
struct group_ctx *gc, *showgroup = NULL;
|
struct group_ctx *newgc, *oldgc, *showgroup = NULL;
|
||||||
|
|
||||||
if (((gc = sc->group_active)) == NULL)
|
oldgc = sc->group_active;
|
||||||
errx(1, "group_cycle: no active group");
|
|
||||||
|
|
||||||
|
newgc = oldgc;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
gc = (flags & CWM_RCYCLE) ? TAILQ_PREV(gc, group_ctx_q,
|
newgc = (flags & CWM_RCYCLE) ? group_prev(newgc) :
|
||||||
entry) : TAILQ_NEXT(gc, entry);
|
group_next(newgc);
|
||||||
if (gc == NULL)
|
|
||||||
gc = (flags & CWM_RCYCLE) ? TAILQ_LAST(&sc->groupq,
|
if (newgc == oldgc)
|
||||||
group_ctx_q) : TAILQ_FIRST(&sc->groupq);
|
|
||||||
if (gc == sc->group_active)
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (!group_holds_only_sticky(gc) && showgroup == NULL)
|
if (!group_holds_only_sticky(newgc) && showgroup == NULL)
|
||||||
showgroup = gc;
|
showgroup = newgc;
|
||||||
else if (!group_holds_only_hidden(gc))
|
else if (!group_holds_only_hidden(newgc))
|
||||||
group_hide(gc);
|
group_hide(newgc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (showgroup == NULL)
|
group_hide(oldgc);
|
||||||
return;
|
|
||||||
|
|
||||||
group_hide(sc->group_active);
|
|
||||||
|
|
||||||
if (group_holds_only_hidden(showgroup))
|
if (group_holds_only_hidden(showgroup))
|
||||||
group_show(showgroup);
|
group_show(showgroup);
|
||||||
@ -292,6 +286,26 @@ group_cycle(struct screen_ctx *sc, int flags)
|
|||||||
group_setactive(showgroup);
|
group_setactive(showgroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct group_ctx *
|
||||||
|
group_next(struct group_ctx *gc)
|
||||||
|
{
|
||||||
|
struct screen_ctx *sc = gc->sc;
|
||||||
|
struct group_ctx *newgc;
|
||||||
|
|
||||||
|
return(((newgc = TAILQ_NEXT(gc, entry)) != NULL) ?
|
||||||
|
newgc : TAILQ_FIRST(&sc->groupq));
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct group_ctx *
|
||||||
|
group_prev(struct group_ctx *gc)
|
||||||
|
{
|
||||||
|
struct screen_ctx *sc = gc->sc;
|
||||||
|
struct group_ctx *newgc;
|
||||||
|
|
||||||
|
return(((newgc = TAILQ_PREV(gc, group_ctx_q, entry)) != NULL) ?
|
||||||
|
newgc : TAILQ_LAST(&sc->groupq, group_ctx_q));
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
group_alltoggle(struct screen_ctx *sc)
|
group_alltoggle(struct screen_ctx *sc)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user