diff options
author | okan <okan> | 2019-03-07 14:28:17 +0000 |
---|---|---|
committer | okan <okan> | 2019-03-07 14:28:17 +0000 |
commit | 7c45b87622c069a176359df3c632086540a7fe3f (patch) | |
tree | 9b515d87072ce60074e2ab985383acc3f8f28fae /client.c | |
parent | 01be5b4e4a04e5f454d0e685c71c8023c7c0b731 (diff) | |
download | cwm-7c45b87622c069a176359df3c632086540a7fe3f.tar.gz cwm-7c45b87622c069a176359df3c632086540a7fe3f.tar.xz cwm-7c45b87622c069a176359df3c632086540a7fe3f.zip |
Teach client_current() to use a screen to find the current client instead of
iterating over all (fallback if no screen provided for now). Initially convert trivial uses of client_current().
Diffstat (limited to 'client.c')
-rw-r--r-- | client.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/client.c b/client.c index 94f295a..0187f4e 100644 --- a/client.c +++ b/client.c @@ -218,7 +218,7 @@ client_setactive(struct client_ctx *cc) if (cc->flags & CLIENT_WM_TAKE_FOCUS) client_msg(cc, cwmh[WM_TAKE_FOCUS], Last_Event_Time); - if ((oldcc = client_current()) != NULL) { + if ((oldcc = client_current(sc)) != NULL) { oldcc->flags &= ~CLIENT_ACTIVE; client_draw_border(oldcc); } @@ -235,16 +235,23 @@ client_setactive(struct client_ctx *cc) } struct client_ctx * -client_current(void) +client_current(struct screen_ctx *sc) { - struct screen_ctx *sc; + struct screen_ctx *_sc; struct client_ctx *cc; - TAILQ_FOREACH(sc, &Screenq, entry) { + if (sc) { TAILQ_FOREACH(cc, &sc->clientq, entry) { if (cc->flags & CLIENT_ACTIVE) return(cc); } + } else { + TAILQ_FOREACH(_sc, &Screenq, entry) { + TAILQ_FOREACH(cc, &_sc->clientq, entry) { + if (cc->flags & CLIENT_ACTIVE) + return(cc); + } + } } return(NULL); } @@ -679,7 +686,7 @@ client_cycle(struct screen_ctx *sc, int flags) return; prevcc = TAILQ_FIRST(&sc->clientq); - oldcc = client_current(); + oldcc = client_current(sc); if (oldcc == NULL) oldcc = (flags & CWM_CYCLE_REVERSE) ? TAILQ_LAST(&sc->clientq, client_q) : |