"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "resize.c" between
tmux-3.2.tar.gz and tmux-3.2a.tar.gz

About: tmux is a terminal multiplexer that lets you switch easily between several programs in one terminal.

resize.c  (tmux-3.2):resize.c  (tmux-3.2a)
skipping to change at line 111 skipping to change at line 111
TAILQ_FOREACH(loop, &clients, entry) { TAILQ_FOREACH(loop, &clients, entry) {
if (ignore_client_size(loop) || !session_has(loop->session, w)) if (ignore_client_size(loop) || !session_has(loop->session, w))
continue; continue;
if (++n > 1) if (++n > 1)
break; break;
} }
return (n); return (n);
} }
static int static int
clients_calculate_size(int type, int current, struct session *s, clients_calculate_size(int type, int current, struct client *c,
struct window *w, int (*skip_client)(struct client *, int, int, struct session *s, struct window *w, int (*skip_client)(struct client *,
struct session *, struct window *), u_int *sx, u_int *sy, u_int *xpixel, int, int, struct session *, struct window *), u_int *sx, u_int *sy,
u_int *ypixel) u_int *xpixel, u_int *ypixel)
{ {
struct client *loop; struct client *loop;
u_int cx, cy, n = 0; u_int cx, cy, n = 0;
/* Manual windows do not have their size changed based on a client. */ /* 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); return (0);
}
/* /*
* Start comparing with 0 for largest and UINT_MAX for smallest or * Start comparing with 0 for largest and UINT_MAX for smallest or
* latest. * latest.
*/ */
if (type == WINDOW_SIZE_LARGEST) if (type == WINDOW_SIZE_LARGEST)
*sx = *sy = 0; *sx = *sy = 0;
else else
*sx = *sy = UINT_MAX; *sx = *sy = UINT_MAX;
*xpixel = *ypixel = 0; *xpixel = *ypixel = 0;
/* /*
* For latest, count the number of clients with this window. We only * For latest, count the number of clients with this window. We only
* care if there is more than one. * care if there is more than one.
*/ */
if (type == WINDOW_SIZE_LATEST) if (type == WINDOW_SIZE_LATEST && w != NULL)
n = clients_with_window(w); n = clients_with_window(w);
/* Loop over the clients and work out the size. */ /* Loop over the clients and work out the size. */
TAILQ_FOREACH(loop, &clients, entry) { 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; 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; continue;
}
/* /*
* If there are multiple clients attached, only accept the * If there are multiple clients attached, only accept the
* latest client; otherwise let the only client be chosen as * latest client; otherwise let the only client be chosen as
* for smallest. * 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; continue;
}
/* Work out this client's size. */ /* Work out this client's size. */
cx = loop->tty.sx; cx = loop->tty.sx;
cy = loop->tty.sy - status_line_size(loop); cy = loop->tty.sy - status_line_size(loop);
/* /*
* If it is larger or smaller than the best so far, update the * If it is larger or smaller than the best so far, update the
* new size. * new size.
*/ */
if (type == WINDOW_SIZE_LARGEST) { if (type == WINDOW_SIZE_LARGEST) {
skipping to change at line 178 skipping to change at line 186
} else { } else {
if (cx < *sx) if (cx < *sx)
*sx = cx; *sx = cx;
if (cy < *sy) if (cy < *sy)
*sy = cy; *sy = cy;
} }
if (loop->tty.xpixel > *xpixel && loop->tty.ypixel > *ypixel) { if (loop->tty.xpixel > *xpixel && loop->tty.ypixel > *ypixel) {
*xpixel = loop->tty.xpixel; *xpixel = loop->tty.xpixel;
*ypixel = loop->tty.ypixel; *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. */ /* 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); 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); return (*sx != UINT_MAX && *sy != UINT_MAX);
} }
static int 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) __unused int current, struct session *s, struct window *w)
{ {
/* /*
* Latest checks separately, so do not check here. Otherwise only * Latest checks separately, so do not check here. Otherwise only
* include clients where the session contains the window or where the * include clients where the session contains the window or where the
* session is the given session. * session is the given session.
*/ */
if (type == WINDOW_SIZE_LATEST) if (type == WINDOW_SIZE_LATEST)
return (0); return (0);
if (w != NULL && !session_has(loop->session, w)) if (w != NULL && !session_has(loop->session, w))
skipping to change at line 224 skipping to change at line 240
/* /*
* Latest clients can use the given client if suitable. If there is no * Latest clients can use the given client if suitable. If there is no
* client and no window, use the default size as for manual type. * client and no window, use the default size as for manual type.
*/ */
if (type == WINDOW_SIZE_LATEST) { if (type == WINDOW_SIZE_LATEST) {
if (c != NULL && !ignore_client_size(c)) { if (c != NULL && !ignore_client_size(c)) {
*sx = c->tty.sx; *sx = c->tty.sx;
*sy = c->tty.sy - status_line_size(c); *sy = c->tty.sy - status_line_size(c);
*xpixel = c->tty.xpixel; *xpixel = c->tty.xpixel;
*ypixel = c->tty.ypixel; *ypixel = c->tty.ypixel;
log_debug("%s: using %ux%u from %s", __func__, *sx, *sy,
c->name);
goto done; goto done;
} }
if (w == NULL)
type = WINDOW_SIZE_MANUAL;
} }
/* /*
* Look for a client to base the size on. If none exists (or the type * Look for a client to base the size on. If none exists (or the type
* is manual), use the default-size option. * 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)) { default_window_size_skip_client, sx, sy, xpixel, ypixel)) {
value = options_get_string(s->options, "default-size"); value = options_get_string(s->options, "default-size");
if (sscanf(value, "%ux%u", sx, sy) != 2) { if (sscanf(value, "%ux%u", sx, sy) != 2) {
*sx = 80; *sx = 80;
*sy = 24; *sy = 24;
} }
log_debug("%s: using %ux%u from default-size", __func__, *sx,
*sy);
} }
done: done:
/* Make sure the limits are enforced. */ /* Make sure the limits are enforced. */
if (*sx < WINDOW_MINIMUM) if (*sx < WINDOW_MINIMUM)
*sx = WINDOW_MINIMUM; *sx = WINDOW_MINIMUM;
if (*sx > WINDOW_MAXIMUM) if (*sx > WINDOW_MAXIMUM)
*sx = WINDOW_MAXIMUM; *sx = WINDOW_MAXIMUM;
if (*sy < WINDOW_MINIMUM) if (*sy < WINDOW_MINIMUM)
*sy = WINDOW_MINIMUM; *sy = WINDOW_MINIMUM;
if (*sy > WINDOW_MAXIMUM) if (*sy > WINDOW_MAXIMUM)
*sy = WINDOW_MAXIMUM; *sy = WINDOW_MAXIMUM;
log_debug("%s: resulting size is %ux%u", __func__, *sx, *sy);
} }
static int static int
recalculate_size_skip_client(struct client *loop, __unused int type, recalculate_size_skip_client(struct client *loop, __unused int type,
int current, __unused struct session *s, struct window *w) int current, __unused struct session *s, struct window *w)
{ {
/* /*
* If the current flag is set, then skip any client where this window * If the current flag is set, then skip any client where this window
* is not the current window - this is used for aggressive-resize. * is not the current window - this is used for aggressive-resize.
* Otherwise skip any session that doesn't contain the window. * Otherwise skip any session that doesn't contain the window.
skipping to change at line 292 skipping to change at line 311
/* /*
* Type is manual, smallest, largest, latest. Current is the * Type is manual, smallest, largest, latest. Current is the
* aggressive-resize option (do not resize based on clients where the * aggressive-resize option (do not resize based on clients where the
* window is not the current window). * window is not the current window).
*/ */
type = options_get_number(w->options, "window-size"); type = options_get_number(w->options, "window-size");
current = options_get_number(w->options, "aggressive-resize"); current = options_get_number(w->options, "aggressive-resize");
/* Look for a suitable client and get the new size. */ /* 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); recalculate_size_skip_client, &sx, &sy, &xpixel, &ypixel);
/* /*
* Make sure the size has actually changed. If the window has already * Make sure the size has actually changed. If the window has already
* got a resize scheduled, then use the new size; otherwise the old. * got a resize scheduled, then use the new size; otherwise the old.
*/ */
if (w->flags & WINDOW_RESIZE) { if (w->flags & WINDOW_RESIZE) {
if (!now && changed && w->new_sx == sx && w->new_sy == sy) if (!now && changed && w->new_sx == sx && w->new_sy == sy)
changed = 0; changed = 0;
} else { } else {
 End of changes. 19 change blocks. 
15 lines changed or deleted 34 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)