aboutsummaryrefslogtreecommitdiffstats
path: root/client.c
diff options
context:
space:
mode:
authorokan2019-03-07 14:28:17 +0000
committerokan2019-03-07 14:28:17 +0000
commit74a07e98a76678714e28c1085f0068d7abe7b9db (patch)
treeb26c527b3826c0c4bfe7ccd682135b2b6a578c1d /client.c
parentd68bdd9253084b00edebefeae250d710c235b9dc (diff)
downloadcwm-74a07e98a76678714e28c1085f0068d7abe7b9db.tar.gz
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.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/client.c b/client.c
index 0c4bd3d..8c381e5 100644
--- a/client.c
+++ b/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) :