Add a "latest" window-size option which tries to size windows based on

the most recently used client. From Tommie Gannert in GitHub issue 1869
based on earlier changes from me.
This commit is contained in:
nicm
2019-09-19 09:02:30 +00:00
parent d018477359
commit 647887b794
10 changed files with 147 additions and 74 deletions

View File

@ -996,6 +996,24 @@ server_client_assume_paste(struct session *s)
return (0);
}
/* Has the latest client changed? */
static void
server_client_update_latest(struct client *c)
{
struct window *w;
if (c->session == NULL)
return;
w = c->session->curw->window;
if (w->latest == c)
return;
w->latest = c;
if (options_get_number(w->options, "window-size") == WINDOW_SIZE_LATEST)
recalculate_size(w);
}
/*
* Handle data key input from client. This owns and can modify the key event it
* is given and is responsible for freeing it.
@ -1192,6 +1210,8 @@ forward_key:
window_pane_key(wp, c, s, wl, key, m);
out:
if (s != NULL)
server_client_update_latest(c);
free(event);
return (CMD_RETURN_NORMAL);
}
@ -1737,6 +1757,7 @@ server_client_dispatch(struct imsg *imsg, void *arg)
if (c->flags & CLIENT_CONTROL)
break;
server_client_update_latest(c);
server_client_clear_overlay(c);
tty_resize(&c->tty);
recalculate_sizes();