diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2021-06-10 07:24:46 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2021-06-10 07:24:46 +0000 |
commit | dfd1a17d6f795f1ede2e1b1fc62eeff4adbd1fe3 (patch) | |
tree | 275c8f949cf4a31a771a865634dc6dd61df32135 /usr.bin/tmux | |
parent | aa63b0eb78b8c80916e5ad0252326c5361dbe3ac (diff) |
Include current client in size calculation for new sessions, GitHub
issue 2662.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r-- | usr.bin/tmux/cmd-new-session.c | 3 | ||||
-rw-r--r-- | usr.bin/tmux/resize.c | 49 | ||||
-rw-r--r-- | usr.bin/tmux/status.c | 4 | ||||
-rw-r--r-- | usr.bin/tmux/window.c | 4 |
4 files changed, 42 insertions, 18 deletions
diff --git a/usr.bin/tmux/cmd-new-session.c b/usr.bin/tmux/cmd-new-session.c index 85b91949f9a..4129872feac 100644 --- a/usr.bin/tmux/cmd-new-session.c +++ b/usr.bin/tmux/cmd-new-session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-new-session.c,v 1.135 2020/06/01 09:43:01 nicm Exp $ */ +/* $OpenBSD: cmd-new-session.c,v 1.136 2021/06/10 07:24:45 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -269,6 +269,7 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item) memset(&sc, 0, sizeof sc); sc.item = item; sc.s = s; + sc.tc = c; sc.name = args_get(args, 'n'); sc.argc = args->argc; diff --git a/usr.bin/tmux/resize.c b/usr.bin/tmux/resize.c index 13776b8c398..5941b9865ea 100644 --- a/usr.bin/tmux/resize.c +++ b/usr.bin/tmux/resize.c @@ -1,4 +1,4 @@ -/* $OpenBSD: resize.c,v 1.42 2020/10/05 10:00:51 nicm Exp $ */ +/* $OpenBSD: resize.c,v 1.43 2021/06/10 07:24:45 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -108,17 +108,19 @@ clients_with_window(struct window *w) } static int -clients_calculate_size(int type, int current, struct session *s, - struct window *w, int (*skip_client)(struct client *, int, int, - struct session *, struct window *), u_int *sx, u_int *sy, u_int *xpixel, - u_int *ypixel) +clients_calculate_size(int type, int current, struct client *c, + struct session *s, struct window *w, int (*skip_client)(struct client *, + int, int, struct session *, struct window *), u_int *sx, u_int *sy, + u_int *xpixel, u_int *ypixel) { struct client *loop; u_int cx, cy, n = 0; /* Manual windows do not have their size changed based on a client. */ - if (type == WINDOW_SIZE_MANUAL) + if (type == WINDOW_SIZE_MANUAL) { + log_debug("%s: type is manual", __func__); return (0); + } /* * Start comparing with 0 for largest and UINT_MAX for smallest or @@ -139,18 +141,24 @@ clients_calculate_size(int type, int current, struct session *s, /* Loop over the clients and work out the size. */ TAILQ_FOREACH(loop, &clients, entry) { - if (ignore_client_size(loop)) + if (loop != c && ignore_client_size(loop)) { + log_debug("%s: ignoring %s", __func__, loop->name); continue; - if (skip_client(loop, type, current, s, w)) + } + if (loop != c && skip_client(loop, type, current, s, w)) { + log_debug("%s: skipping %s", __func__, loop->name); continue; + } /* * If there are multiple clients attached, only accept the * latest client; otherwise let the only client be chosen as * for smallest. */ - if (type == WINDOW_SIZE_LATEST && n > 1 && loop != w->latest) + if (type == WINDOW_SIZE_LATEST && n > 1 && loop != w->latest) { + log_debug("%s: %s is not latest", __func__, loop->name); continue; + } /* Work out this client's size. */ cx = loop->tty.sx; @@ -175,16 +183,24 @@ clients_calculate_size(int type, int current, struct session *s, *xpixel = loop->tty.xpixel; *ypixel = loop->tty.ypixel; } + log_debug("%s: after %s (%ux%u), size is %ux%u", __func__, + loop->name, cx, cy, *sx, *sy); } /* Return whether a suitable size was found. */ - if (type == WINDOW_SIZE_LARGEST) + if (type == WINDOW_SIZE_LARGEST) { + log_debug("%s: type is largest", __func__); return (*sx != 0 && *sy != 0); + } + if (type == WINDOW_SIZE_LATEST) + log_debug("%s: type is latest", __func__); + else + log_debug("%s: type is smallest", __func__); return (*sx != UINT_MAX && *sy != UINT_MAX); } static int -default_window_size_skip_client (struct client *loop, int type, +default_window_size_skip_client(struct client *loop, int type, __unused int current, struct session *s, struct window *w) { /* @@ -221,23 +237,25 @@ default_window_size(struct client *c, struct session *s, struct window *w, *sy = c->tty.sy - status_line_size(c); *xpixel = c->tty.xpixel; *ypixel = c->tty.ypixel; + log_debug("%s: using %ux%u from %s", __func__, *sx, *sy, + c->name); goto done; } - if (w == NULL) - type = WINDOW_SIZE_MANUAL; } /* * Look for a client to base the size on. If none exists (or the type * is manual), use the default-size option. */ - if (!clients_calculate_size(type, 0, s, w, + if (!clients_calculate_size(type, 0, c, s, w, default_window_size_skip_client, sx, sy, xpixel, ypixel)) { value = options_get_string(s->options, "default-size"); if (sscanf(value, "%ux%u", sx, sy) != 2) { *sx = 80; *sy = 24; } + log_debug("%s: using %ux%u from default-size", __func__, *sx, + *sy); } done: @@ -250,6 +268,7 @@ done: *sy = WINDOW_MINIMUM; if (*sy > WINDOW_MAXIMUM) *sy = WINDOW_MAXIMUM; + log_debug("%s: resulting size is %ux%u", __func__, *sx, *sy); } static int @@ -289,7 +308,7 @@ recalculate_size(struct window *w, int now) current = options_get_number(w->options, "aggressive-resize"); /* Look for a suitable client and get the new size. */ - changed = clients_calculate_size(type, current, NULL, w, + changed = clients_calculate_size(type, current, NULL, NULL, w, recalculate_size_skip_client, &sx, &sy, &xpixel, &ypixel); /* diff --git a/usr.bin/tmux/status.c b/usr.bin/tmux/status.c index f94820d4786..7e3a22f3ae0 100644 --- a/usr.bin/tmux/status.c +++ b/usr.bin/tmux/status.c @@ -1,4 +1,4 @@ -/* $OpenBSD: status.c,v 1.221 2021/04/12 09:36:12 nicm Exp $ */ +/* $OpenBSD: status.c,v 1.222 2021/06/10 07:24:45 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -226,6 +226,8 @@ status_line_size(struct client *c) if (c->flags & (CLIENT_STATUSOFF|CLIENT_CONTROL)) return (0); + if (s == NULL) + return (options_get_number(global_s_options, "status")); return (s->statuslines); } diff --git a/usr.bin/tmux/window.c b/usr.bin/tmux/window.c index fdede321808..d0c4e2d2051 100644 --- a/usr.bin/tmux/window.c +++ b/usr.bin/tmux/window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window.c,v 1.270 2021/03/11 06:31:05 nicm Exp $ */ +/* $OpenBSD: window.c,v 1.271 2021/06/10 07:24:45 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -331,6 +331,8 @@ window_create(u_int sx, u_int sy, u_int xpixel, u_int ypixel) window_update_activity(w); + log_debug("%s: @%u create %ux%u (%ux%u)", __func__, w->id, sx, sy, + w->xpixel, w->ypixel); return (w); } |