diff options
author | Okan Demirmen <okan@cvs.openbsd.org> | 2019-03-07 14:28:18 +0000 |
---|---|---|
committer | Okan Demirmen <okan@cvs.openbsd.org> | 2019-03-07 14:28:18 +0000 |
commit | 02d346dbe6173831a2733249aa5d5a2fba31fa66 (patch) | |
tree | d515e6a7b2050c4698fe4b0f36995e2098a0a105 /app/cwm | |
parent | ee68fee17adee06c92046570937fc4cfe6bc792e (diff) |
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 'app/cwm')
-rw-r--r-- | app/cwm/calmwm.h | 4 | ||||
-rw-r--r-- | app/cwm/client.c | 19 | ||||
-rw-r--r-- | app/cwm/kbfunc.c | 4 | ||||
-rw-r--r-- | app/cwm/xevents.c | 12 |
4 files changed, 23 insertions, 16 deletions
diff --git a/app/cwm/calmwm.h b/app/cwm/calmwm.h index ef622a74c..864f4f4d2 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. * - * $OpenBSD: calmwm.h,v 1.370 2019/03/07 13:14:41 okan Exp $ + * $OpenBSD: calmwm.h,v 1.371 2019/03/07 14:28:17 okan Exp $ */ #ifndef _CALMWM_H_ @@ -394,7 +394,7 @@ __dead void usage(void); void client_applysizehints(struct client_ctx *); void client_config(struct client_ctx *); -struct client_ctx *client_current(void); +struct client_ctx *client_current(struct screen_ctx *); void client_cycle(struct screen_ctx *, int); void client_remove(struct client_ctx *); void client_draw_border(struct client_ctx *); diff --git a/app/cwm/client.c b/app/cwm/client.c index 0c4bd3d07..8c381e590 100644 --- a/app/cwm/client.c +++ b/app/cwm/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.254 2019/03/07 13:24:44 okan Exp $ + * $OpenBSD: client.c,v 1.255 2019/03/07 14:28:17 okan Exp $ */ #include <sys/types.h> @@ -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) : diff --git a/app/cwm/kbfunc.c b/app/cwm/kbfunc.c index 9ae59f143..57f21809d 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. * - * $OpenBSD: kbfunc.c,v 1.164 2019/03/07 12:54:21 okan Exp $ + * $OpenBSD: kbfunc.c,v 1.165 2019/03/07 14:28:17 okan Exp $ */ #include <sys/types.h> @@ -470,7 +470,7 @@ kbfunc_menu_client(void *ctx, struct cargs *cargs) if (cargs->xev == CWM_XEV_BTN) mflags |= CWM_MENU_LIST; - old_cc = client_current(); + old_cc = client_current(sc); TAILQ_INIT(&menuq); TAILQ_FOREACH(cc, &sc->clientq, entry) { diff --git a/app/cwm/xevents.c b/app/cwm/xevents.c index fa2d4c1ed..4a452b9c5 100644 --- a/app/cwm/xevents.c +++ b/app/cwm/xevents.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: xevents.c,v 1.138 2019/03/06 13:32:19 okan Exp $ + * $OpenBSD: xevents.c,v 1.139 2019/03/07 14:28:17 okan Exp $ */ /* @@ -79,7 +79,7 @@ xev_handle_maprequest(XEvent *ee) LOG_DEBUG3("window: 0x%lx", e->window); - if ((old_cc = client_current()) != NULL) + if ((old_cc = client_current(NULL)) != NULL) client_ptrsave(old_cc); if ((cc = client_find(e->window)) == NULL) @@ -249,7 +249,7 @@ xev_handle_buttonpress(XEvent *ee) switch (mb->context) { case CWM_CONTEXT_CC: if (((cc = client_find(e->window)) == NULL) && - (cc = client_current()) == NULL) + (cc = client_current(NULL)) == NULL) return; (*mb->callback)(cc, mb->cargs); break; @@ -318,7 +318,7 @@ xev_handle_keypress(XEvent *ee) switch (kb->context) { case CWM_CONTEXT_CC: if (((cc = client_find(e->window)) == NULL) && - (cc = client_current()) == NULL) + (cc = client_current(NULL)) == NULL) return; (*kb->callback)(cc, kb->cargs); break; @@ -353,7 +353,7 @@ xev_handle_keyrelease(XEvent *ee) keysym = XkbKeycodeToKeysym(X_Dpy, e->keycode, 0, 0); for (i = 0; i < nitems(modkeys); i++) { if (keysym == modkeys[i]) { - if ((cc = client_current()) != NULL) { + if ((cc = client_current(NULL)) != NULL) { if (sc->cycling) { sc->cycling = 0; client_mtf(cc); @@ -389,7 +389,7 @@ xev_handle_clientmessage(XEvent *ee) } } else if (e->message_type == ewmh[_NET_ACTIVE_WINDOW]) { if ((cc = client_find(e->window)) != NULL) { - if ((old_cc = client_current()) != NULL) + if ((old_cc = client_current(NULL)) != NULL) client_ptrsave(old_cc); client_show(cc); client_ptrwarp(cc); |