If a window appears in only one attached session, there is no point in

worrying about which is the latest client (there is only one).
This commit is contained in:
nicm 2019-11-29 16:04:07 +00:00
parent c5d74b1deb
commit 67d995d100
2 changed files with 24 additions and 4 deletions

View File

@ -127,6 +127,7 @@ cmd_attach_session(struct cmdq_item *item, const char *tflag, int dflag,
gettimeofday(&s->last_attached_time, NULL); gettimeofday(&s->last_attached_time, NULL);
server_redraw_client(c); server_redraw_client(c);
s->curw->flags &= ~WINLINK_ALERTFLAGS; s->curw->flags &= ~WINLINK_ALERTFLAGS;
s->curw->window->latest = c;
} else { } else {
if (server_client_open(c, &cause) != 0) { if (server_client_open(c, &cause) != 0) {
cmdq_error(item, "open terminal failed: %s", cause); cmdq_error(item, "open terminal failed: %s", cause);
@ -159,6 +160,7 @@ cmd_attach_session(struct cmdq_item *item, const char *tflag, int dflag,
gettimeofday(&s->last_attached_time, NULL); gettimeofday(&s->last_attached_time, NULL);
server_redraw_client(c); server_redraw_client(c);
s->curw->flags &= ~WINLINK_ALERTFLAGS; s->curw->flags &= ~WINLINK_ALERTFLAGS;
s->curw->window->latest = c;
if (~c->flags & CLIENT_CONTROL) if (~c->flags & CLIENT_CONTROL)
proc_send(c->peer, MSG_READY, -1, NULL, 0); proc_send(c->peer, MSG_READY, -1, NULL, 0);

View File

@ -80,7 +80,7 @@ default_window_size(struct client *c, struct session *s, struct window *w,
u_int *sx, u_int *sy, u_int *xpixel, u_int *ypixel, int type) u_int *sx, u_int *sy, u_int *xpixel, u_int *ypixel, int type)
{ {
struct client *loop; struct client *loop;
u_int cx, cy; u_int cx, cy, n;
const char *value; const char *value;
if (type == -1) if (type == -1)
@ -149,12 +149,22 @@ default_window_size(struct client *c, struct session *s, struct window *w,
*xpixel = c->tty.xpixel; *xpixel = c->tty.xpixel;
*ypixel = c->tty.ypixel; *ypixel = c->tty.ypixel;
} else { } else {
if (w == NULL)
goto manual;
n = 0;
TAILQ_FOREACH(loop, &clients, entry) {
if (!ignore_client_size(loop) &&
session_has(loop->session, w)) {
if (++n > 1)
break;
}
}
*sx = *sy = UINT_MAX; *sx = *sy = UINT_MAX;
*xpixel = *ypixel = 0; *xpixel = *ypixel = 0;
TAILQ_FOREACH(loop, &clients, entry) { TAILQ_FOREACH(loop, &clients, entry) {
if (ignore_client_size(loop)) if (ignore_client_size(loop))
continue; continue;
if (w != NULL && loop != w->latest) if (n > 1 && loop != w->latest)
continue; continue;
s = loop->session; s = loop->session;
@ -204,7 +214,7 @@ recalculate_size(struct window *w)
{ {
struct session *s; struct session *s;
struct client *c; struct client *c;
u_int sx, sy, cx, cy, xpixel = 0, ypixel = 0; u_int sx, sy, cx, cy, xpixel = 0, ypixel = 0, n;
int type, current, has, changed; int type, current, has, changed;
if (w->active == NULL) if (w->active == NULL)
@ -277,11 +287,19 @@ recalculate_size(struct window *w)
changed = 0; changed = 0;
break; break;
case WINDOW_SIZE_LATEST: case WINDOW_SIZE_LATEST:
n = 0;
TAILQ_FOREACH(c, &clients, entry) {
if (!ignore_client_size(c) &&
session_has(c->session, w)) {
if (++n > 1)
break;
}
}
sx = sy = UINT_MAX; sx = sy = UINT_MAX;
TAILQ_FOREACH(c, &clients, entry) { TAILQ_FOREACH(c, &clients, entry) {
if (ignore_client_size(c)) if (ignore_client_size(c))
continue; continue;
if (c != w->latest) if (n > 1 && c != w->latest)
continue; continue;
s = c->session; s = c->session;