From 24350879cdfb9ef23dee0da409b621e9830d8baf Mon Sep 17 00:00:00 2001 From: nicm Date: Tue, 28 Jan 2020 08:06:11 +0000 Subject: [PATCH] Add a define for flags meaning a client is not attached, and fix unattached counter, reported by Thomas Sattler. --- resize.c | 5 +++-- server-client.c | 4 ++-- tmux.h | 4 ++++ window-client.c | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/resize.c b/resize.c index 054b025f..b4142a70 100644 --- a/resize.c +++ b/resize.c @@ -363,14 +363,15 @@ recalculate_sizes(void) * client. */ TAILQ_FOREACH(c, &clients, entry) { + s = c->session; + if (s != NULL && !(c->flags & CLIENT_UNATTACHEDFLAGS)) + s->attached++; if (ignore_client_size(c)) continue; - s = c->session; if (c->tty.sy <= s->statuslines || (c->flags & CLIENT_CONTROL)) c->flags |= CLIENT_STATUSOFF; else c->flags &= ~CLIENT_STATUSOFF; - s->attached++; } /* Walk each window and adjust the size. */ diff --git a/server-client.c b/server-client.c index ee7b4c70..12e07327 100644 --- a/server-client.c +++ b/server-client.c @@ -1034,7 +1034,7 @@ server_client_key_callback(struct cmdq_item *item, void *data) key_code key0; /* Check the client is good to accept input. */ - if (s == NULL || (c->flags & (CLIENT_DEAD|CLIENT_SUSPENDED)) != 0) + if (s == NULL || (c->flags & CLIENT_UNATTACHEDFLAGS)) goto out; wl = s->curw; @@ -1221,7 +1221,7 @@ server_client_handle_key(struct client *c, struct key_event *event) struct cmdq_item *item; /* Check the client is good to accept input. */ - if (s == NULL || (c->flags & (CLIENT_DEAD|CLIENT_SUSPENDED)) != 0) + if (s == NULL || (c->flags & CLIENT_UNATTACHEDFLAGS)) return (0); /* diff --git a/tmux.h b/tmux.h index 093f17a4..d56c5fea 100644 --- a/tmux.h +++ b/tmux.h @@ -1582,6 +1582,10 @@ struct client { CLIENT_REDRAWSTATUSALWAYS| \ CLIENT_REDRAWBORDERS| \ CLIENT_REDRAWOVERLAY) +#define CLIENT_UNATTACHEDFLAGS \ + (CLIENT_DEAD| \ + CLIENT_SUSPENDED| \ + CLIENT_DETACHING) #define CLIENT_NOSIZEFLAGS \ (CLIENT_DEAD| \ CLIENT_SUSPENDED| \ diff --git a/window-client.c b/window-client.c index 22a0f2e2..4688cbf3 100644 --- a/window-client.c +++ b/window-client.c @@ -210,7 +210,7 @@ window_client_draw(__unused void *modedata, void *itemdata, struct window_pane *wp; u_int cx = s->cx, cy = s->cy, lines, at; - if (c->session == NULL || (c->flags & (CLIENT_DEAD|CLIENT_DETACHING))) + if (c->session == NULL || (c->flags & CLIENT_UNATTACHEDFLAGS)) return; wp = c->session->curw->window->active;