summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2019-04-11 09:26:34 +0100
committerNicholas Marriott <nicholas.marriott@gmail.com>2019-04-11 09:26:34 +0100
commitbba1809eac7eda21842fef1aab8723d9bfb56c8f (patch)
tree0ae79f9e42ddc9d3a0f8eb67be8b853b74492d0b
parent73b54a0e5fa14736d1b7fbac997dd5b12c6940fb (diff)
Merge a number of fixes from master for layouts, mostly prompted by testing by
Thomas Sattler.
-rw-r--r--cmd-select-layout.c1
-rw-r--r--configure.ac2
-rw-r--r--layout-set.c275
-rw-r--r--layout.c33
-rw-r--r--resize.c2
-rw-r--r--screen-redraw.c5
-rw-r--r--tty.c3
7 files changed, 134 insertions, 187 deletions
diff --git a/cmd-select-layout.c b/cmd-select-layout.c
index d8fc1aeb..775d32c5 100644
--- a/cmd-select-layout.c
+++ b/cmd-select-layout.c
@@ -135,6 +135,7 @@ cmd_select_layout_exec(struct cmd *self, struct cmdq_item *item)
changed:
free(oldlayout);
+ recalculate_sizes();
server_redraw_window(w);
notify_window("window-layout-changed", w);
return (CMD_RETURN_NORMAL);
diff --git a/configure.ac b/configure.ac
index 79e3ba8c..f04ae14d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,6 +1,6 @@
# configure.ac
-AC_INIT([tmux], 2.9-rc2)
+AC_INIT([tmux], 2.9-rc3)
AC_PREREQ([2.60])
AC_CONFIG_AUX_DIR(etc)
diff --git a/layout-set.c b/layout-set.c
index d99453c2..504d9630 100644
--- a/layout-set.c
+++ b/layout-set.c
@@ -119,7 +119,7 @@ layout_set_even(struct window *w, enum layout_type type)
{
struct window_pane *wp;
struct layout_cell *lc, *lcnew;
- u_int n;
+ u_int n, sx, sy;
layout_print_cell(w->layout_root, __func__, 1);
@@ -131,7 +131,18 @@ layout_set_even(struct window *w, enum layout_type type)
/* Free the old root and construct a new. */
layout_free(w);
lc = w->layout_root = layout_create_cell(NULL);
- layout_set_size(lc, w->sx, w->sy, 0, 0);
+ if (type == LAYOUT_LEFTRIGHT) {
+ sx = (n * (PANE_MINIMUM + 1)) - 1;
+ if (sx < w->sx)
+ sx = w->sx;
+ sy = w->sy;
+ } else {
+ sy = (n * (PANE_MINIMUM + 1)) - 1;
+ if (sy < w->sy)
+ sy = w->sy;
+ sx = w->sx;
+ }
+ layout_set_size(lc, sx, sy, 0, 0);
layout_make_node(lc, type);
/* Build new leaf cells. */
@@ -152,6 +163,7 @@ layout_set_even(struct window *w, enum layout_type type)
layout_print_cell(w->layout_root, __func__, 1);
+ window_resize(w, lc->sx, lc->sy);
notify_window("window-layout-changed", w);
server_redraw_window(w);
}
@@ -172,9 +184,8 @@ static void
layout_set_main_h(struct window *w)
{
struct window_pane *wp;
- struct layout_cell *lc, *lcmain, *lcrow, *lcchild;
- u_int n, mainheight, otherheight, width, height;
- u_int used, i, j, columns, rows, totalrows;
+ struct layout_cell *lc, *lcmain, *lcother, *lcchild;
+ u_int n, mainh, otherh, sx;
layout_print_cell(w->layout_root, __func__, 1);
@@ -184,103 +195,57 @@ layout_set_main_h(struct window *w)
return;
n--; /* take off main pane */
- /* How many rows and columns will be needed, not counting main? */
- columns = (w->sx + 1) / (PANE_MINIMUM + 1); /* maximum columns */
- if (columns == 0)
- columns = 1;
- rows = 1 + (n - 1) / columns;
- columns = 1 + (n - 1) / rows;
- width = (w->sx - (n - 1)) / columns;
-
- /* Get the main pane height and add one for separator line. */
- mainheight = options_get_number(w->options, "main-pane-height") + 1;
-
- /* Get the optional other pane height and add one for separator line. */
- otherheight = options_get_number(w->options, "other-pane-height") + 1;
-
- /*
- * If an other pane height was specified, honour it so long as it
- * doesn't shrink the main height to less than the main-pane-height
- */
- if (otherheight > 1 && w->sy - otherheight > mainheight)
- mainheight = w->sy - otherheight;
- if (mainheight < PANE_MINIMUM + 1)
- mainheight = PANE_MINIMUM + 1;
-
- /* Try and make everything fit. */
- totalrows = rows * (PANE_MINIMUM + 1) - 1;
- if (mainheight + totalrows > w->sy) {
- if (totalrows + PANE_MINIMUM + 1 > w->sy)
- mainheight = PANE_MINIMUM + 2;
+ /* Get the main pane height and work out the other pane height. */
+ mainh = options_get_number(w->options, "main-pane-height");
+ if (mainh + PANE_MINIMUM + 1 >= w->sy) {
+ if (w->sy <= PANE_MINIMUM + 1 + PANE_MINIMUM)
+ mainh = PANE_MINIMUM;
else
- mainheight = w->sy - totalrows;
- height = PANE_MINIMUM;
- } else
- height = (w->sy - mainheight - (rows - 1)) / rows;
+ mainh = w->sy - (PANE_MINIMUM + 1);
+ otherh = PANE_MINIMUM;
+ } else {
+ otherh = options_get_number(w->options, "other-pane-height");
+ if (otherh == 0)
+ otherh = w->sy - mainh;
+ else if (otherh > w->sy || w->sy - otherh < mainh)
+ otherh = w->sy - mainh;
+ else
+ mainh = w->sy - otherh;
+ }
+
+ /* Work out what height is needed. */
+ sx = (n * (PANE_MINIMUM + 1)) - 1;
+ if (sx < w->sx)
+ sx = w->sx;
/* Free old tree and create a new root. */
layout_free(w);
lc = w->layout_root = layout_create_cell(NULL);
- layout_set_size(lc, w->sx, mainheight + rows * (height + 1) - 1, 0, 0);
+ layout_set_size(lc, sx, mainh + otherh + 1, 0, 0);
layout_make_node(lc, LAYOUT_TOPBOTTOM);
/* Create the main pane. */
lcmain = layout_create_cell(lc);
- layout_set_size(lcmain, w->sx, mainheight - 1, 0, 0);
+ layout_set_size(lcmain, sx, mainh, 0, 0);
layout_make_leaf(lcmain, TAILQ_FIRST(&w->panes));
TAILQ_INSERT_TAIL(&lc->cells, lcmain, entry);
- /* Create a grid of the remaining cells. */
- wp = TAILQ_NEXT(TAILQ_FIRST(&w->panes), entry);
- for (j = 0; j < rows; j++) {
- /* If this is the last cell, all done. */
- if (wp == NULL)
- break;
-
- /* Create the new row. */
- lcrow = layout_create_cell(lc);
- layout_set_size(lcrow, w->sx, height, 0, 0);
- TAILQ_INSERT_TAIL(&lc->cells, lcrow, entry);
-
- /* If only one column, just use the row directly. */
- if (columns == 1) {
- layout_make_leaf(lcrow, wp);
- wp = TAILQ_NEXT(wp, entry);
- continue;
- }
-
- /* Add in the columns. */
- layout_make_node(lcrow, LAYOUT_LEFTRIGHT);
- for (i = 0; i < columns; i++) {
- /* Create and add a pane cell. */
- lcchild = layout_create_cell(lcrow);
- layout_set_size(lcchild, width, height, 0, 0);
- layout_make_leaf(lcchild, wp);
- TAILQ_INSERT_TAIL(&lcrow->cells, lcchild, entry);
+ /* Create the other pane. */
+ lcother = layout_create_cell(lc);
+ layout_set_size(lcother, sx, otherh, 0, 0);
+ layout_make_node(lcother, LAYOUT_LEFTRIGHT);
+ TAILQ_INSERT_TAIL(&lc->cells, lcother, entry);
- /* Move to the next cell. */
- if ((wp = TAILQ_NEXT(wp, entry)) == NULL)
- break;
- }
-
- /* Adjust the row to fit the full width if necessary. */
- if (i == columns)
- i--;
- used = ((i + 1) * (width + 1)) - 1;
- if (w->sx <= used)
+ /* Add the remaining panes as children. */
+ TAILQ_FOREACH(wp, &w->panes, entry) {
+ if (wp == TAILQ_FIRST(&w->panes))
continue;
- lcchild = TAILQ_LAST(&lcrow->cells, layout_cells);
- layout_resize_adjust(w, lcchild, LAYOUT_LEFTRIGHT,
- w->sx - used);
- }
-
- /* Adjust the last row height to fit if necessary. */
- used = mainheight + (rows * height) + rows - 1;
- if (w->sy > used) {
- lcrow = TAILQ_LAST(&lc->cells, layout_cells);
- layout_resize_adjust(w, lcrow, LAYOUT_TOPBOTTOM,
- w->sy - used);
+ lcchild = layout_create_cell(lc);
+ layout_set_size(lcchild, PANE_MINIMUM, otherh, 0, 0);
+ layout_make_leaf(lcchild, wp);
+ TAILQ_INSERT_TAIL(&lcother->cells, lcchild, entry);
}
+ layout_spread_cell(w, lcother);
/* Fix cell offsets. */
layout_fix_offsets(lc);
@@ -288,6 +253,7 @@ layout_set_main_h(struct window *w)
layout_print_cell(w->layout_root, __func__, 1);
+ window_resize(w, lc->sx, lc->sy);
notify_window("window-layout-changed", w);
server_redraw_window(w);
}
@@ -296,9 +262,8 @@ static void
layout_set_main_v(struct window *w)
{
struct window_pane *wp;
- struct layout_cell *lc, *lcmain, *lccolumn, *lcchild;
- u_int n, mainwidth, otherwidth, width, height;
- u_int used, i, j, columns, rows, totalcolumns;
+ struct layout_cell *lc, *lcmain, *lcother, *lcchild;
+ u_int n, mainw, otherw, sy;
layout_print_cell(w->layout_root, __func__, 1);
@@ -308,103 +273,57 @@ layout_set_main_v(struct window *w)
return;
n--; /* take off main pane */
- /* How many rows and columns will be needed, not counting main? */
- rows = (w->sy + 1) / (PANE_MINIMUM + 1); /* maximum rows */
- if (rows == 0)
- rows = 1;
- columns = 1 + (n - 1) / rows;
- rows = 1 + (n - 1) / columns;
- height = (w->sy - (n - 1)) / rows;
-
- /* Get the main pane width and add one for separator line. */
- mainwidth = options_get_number(w->options, "main-pane-width") + 1;
-
- /* Get the optional other pane width and add one for separator line. */
- otherwidth = options_get_number(w->options, "other-pane-width") + 1;
-
- /*
- * If an other pane width was specified, honour it so long as it
- * doesn't shrink the main width to less than the main-pane-width
- */
- if (otherwidth > 1 && w->sx - otherwidth > mainwidth)
- mainwidth = w->sx - otherwidth;
- if (mainwidth < PANE_MINIMUM + 1)
- mainwidth = PANE_MINIMUM + 1;
-
- /* Try and make everything fit. */
- totalcolumns = columns * (PANE_MINIMUM + 1) - 1;
- if (mainwidth + totalcolumns > w->sx) {
- if (totalcolumns + PANE_MINIMUM + 1 > w->sx)
- mainwidth = PANE_MINIMUM + 2;
+ /* Get the main pane width and work out the other pane width. */
+ mainw = options_get_number(w->options, "main-pane-width");
+ if (mainw + PANE_MINIMUM + 1 >= w->sx) {
+ if (w->sx <= PANE_MINIMUM + 1 + PANE_MINIMUM)
+ mainw = PANE_MINIMUM;
else
- mainwidth = w->sx - totalcolumns;
- width = PANE_MINIMUM;
- } else
- width = (w->sx - mainwidth - (columns - 1)) / columns;
+ mainw = w->sx - (PANE_MINIMUM + 1);
+ otherw = PANE_MINIMUM;
+ } else {
+ otherw = options_get_number(w->options, "other-pane-width");
+ if (otherw == 0)
+ otherw = w->sx - mainw;
+ else if (otherw > w->sx || w->sx - otherw < mainw)
+ otherw = w->sx - mainw;
+ else
+ mainw = w->sx - otherw;
+ }
+
+ /* Work out what height is needed. */
+ sy = (n * (PANE_MINIMUM + 1)) - 1;
+ if (sy < w->sy)
+ sy = w->sy;
/* Free old tree and create a new root. */
layout_free(w);
lc = w->layout_root = layout_create_cell(NULL);
- layout_set_size(lc, mainwidth + columns * (width + 1) - 1, w->sy, 0, 0);
+ layout_set_size(lc, mainw + otherw + 1, sy, 0, 0);
layout_make_node(lc, LAYOUT_LEFTRIGHT);
/* Create the main pane. */
lcmain = layout_create_cell(lc);
- layout_set_size(lcmain, mainwidth - 1, w->sy, 0, 0);
+ layout_set_size(lcmain, mainw, sy, 0, 0);
layout_make_leaf(lcmain, TAILQ_FIRST(&w->panes));
TAILQ_INSERT_TAIL(&lc->cells, lcmain, entry);
- /* Create a grid of the remaining cells. */
- wp = TAILQ_NEXT(TAILQ_FIRST(&w->panes), entry);
- for (j = 0; j < columns; j++) {
- /* If this is the last cell, all done. */
- if (wp == NULL)
- break;
-
- /* Create the new column. */
- lccolumn = layout_create_cell(lc);
- layout_set_size(lccolumn, width, w->sy, 0, 0);
- TAILQ_INSERT_TAIL(&lc->cells, lccolumn, entry);
+ /* Create the other pane. */
+ lcother = layout_create_cell(lc);
+ layout_set_size(lcother, otherw, sy, 0, 0);
+ layout_make_node(lcother, LAYOUT_TOPBOTTOM);
+ TAILQ_INSERT_TAIL(&lc->cells, lcother, entry);
- /* If only one row, just use the row directly. */
- if (rows == 1) {
- layout_make_leaf(lccolumn, wp);
- wp = TAILQ_NEXT(wp, entry);
- continue;
- }
-
- /* Add in the rows. */
- layout_make_node(lccolumn, LAYOUT_TOPBOTTOM);
- for (i = 0; i < rows; i++) {
- /* Create and add a pane cell. */
- lcchild = layout_create_cell(lccolumn);
- layout_set_size(lcchild, width, height, 0, 0);
- layout_make_leaf(lcchild, wp);
- TAILQ_INSERT_TAIL(&lccolumn->cells, lcchild, entry);
-
- /* Move to the next cell. */
- if ((wp = TAILQ_NEXT(wp, entry)) == NULL)
- break;
- }
-
- /* Adjust the column to fit the full height if necessary. */
- if (i == rows)
- i--;
- used = ((i + 1) * (height + 1)) - 1;
- if (w->sy <= used)
+ /* Add the remaining panes as children. */
+ TAILQ_FOREACH(wp, &w->panes, entry) {
+ if (wp == TAILQ_FIRST(&w->panes))
continue;
- lcchild = TAILQ_LAST(&lccolumn->cells, layout_cells);
- layout_resize_adjust(w, lcchild, LAYOUT_TOPBOTTOM,
- w->sy - used);
- }
-
- /* Adjust the last column width to fit if necessary. */
- used = mainwidth + (columns * width) + columns - 1;
- if (w->sx > used) {
- lccolumn = TAILQ_LAST(&lc->cells, layout_cells);
- layout_resize_adjust(w, lccolumn, LAYOUT_LEFTRIGHT,
- w->sx - used);
+ lcchild = layout_create_cell(lc);
+ layout_set_size(lcchild, otherw, PANE_MINIMUM, 0, 0);
+ layout_make_leaf(lcchild, wp);
+ TAILQ_INSERT_TAIL(&lcother->cells, lcchild, entry);
}
+ layout_spread_cell(w, lcother);
/* Fix cell offsets. */
layout_fix_offsets(lc);
@@ -412,6 +331,7 @@ layout_set_main_v(struct window *w)
layout_print_cell(w->layout_root, __func__, 1);
+ window_resize(w, lc->sx, lc->sy);
notify_window("window-layout-changed", w);
server_redraw_window(w);
}
@@ -421,7 +341,7 @@ layout_set_tiled(struct window *w)
{
struct window_pane *wp;
struct layout_cell *lc, *lcrow, *lcchild;
- u_int n, width, height, used;
+ u_int n, width, height, used, sx, sy;
u_int i, j, columns, rows;
layout_print_cell(w->layout_root, __func__, 1);
@@ -450,7 +370,13 @@ layout_set_tiled(struct window *w)
/* Free old tree and create a new root. */
layout_free(w);
lc = w->layout_root = layout_create_cell(NULL);
- layout_set_size(lc, w->sx, w->sy, 0, 0);
+ sx = ((width + 1) * columns) - 1;
+ if (sx < w->sx)
+ sx = w->sx;
+ sy = ((height + 1) * rows) - 1;
+ if (sy < w->sy)
+ sy = w->sy;
+ layout_set_size(lc, sx, sy, 0, 0);
layout_make_node(lc, LAYOUT_TOPBOTTOM);
/* Create a grid of the cells. */
@@ -514,6 +440,7 @@ layout_set_tiled(struct window *w)
layout_print_cell(w->layout_root, __func__, 1);
+ window_resize(w, lc->sx, lc->sy);
notify_window("window-layout-changed", w);
server_redraw_window(w);
}
diff --git a/layout.c b/layout.c
index 7093c607..fa6f0613 100644
--- a/layout.c
+++ b/layout.c
@@ -479,7 +479,7 @@ layout_resize(struct window *w, u_int sx, u_int sy)
* out proportionately - this should leave the layout fitting the new
* window size.
*/
- xchange = sx - w->sx;
+ xchange = sx - lc->sx;
xlimit = layout_resize_check(w, lc, LAYOUT_LEFTRIGHT);
if (xchange < 0 && xchange < -xlimit)
xchange = -xlimit;
@@ -493,7 +493,7 @@ layout_resize(struct window *w, u_int sx, u_int sy)
layout_resize_adjust(w, lc, LAYOUT_LEFTRIGHT, xchange);
/* Adjust vertically in a similar fashion. */
- ychange = sy - w->sy;
+ ychange = sy - lc->sy;
ylimit = layout_resize_check(w, lc, LAYOUT_TOPBOTTOM);
if (ychange < 0 && ychange < -ylimit)
ychange = -ylimit;
@@ -834,8 +834,9 @@ layout_split_pane(struct window_pane *wp, enum layout_type type, int size,
int insert_before, int full_size)
{
struct layout_cell *lc, *lcparent, *lcnew, *lc1, *lc2;
- u_int sx, sy, xoff, yoff, size1, size2;
+ u_int sx, sy, xoff, yoff, size1, size2, minimum;
u_int new_size, saved_size, resize_first = 0;
+ int status;
/*
* If full_size is specified, add a new cell at the top of the window
@@ -845,6 +846,7 @@ layout_split_pane(struct window_pane *wp, enum layout_type type, int size,
lc = wp->window->layout_root;
else
lc = wp->layout_cell;
+ status = options_get_number(wp->window->options, "pane-border-status");
/* Copy the old cell size. */
sx = lc->sx;
@@ -859,7 +861,10 @@ layout_split_pane(struct window_pane *wp, enum layout_type type, int size,
return (NULL);
break;
case LAYOUT_TOPBOTTOM:
- if (sy < PANE_MINIMUM * 2 + 1)
+ minimum = PANE_MINIMUM * 2 + 1;
+ if (status != 0)
+ minimum += layout_need_status(lc, status == 1);
+ if (sy < minimum)
return (NULL);
break;
default:
@@ -1011,22 +1016,29 @@ int
layout_spread_cell(struct window *w, struct layout_cell *parent)
{
struct layout_cell *lc;
- u_int number, each, size;
- int change, changed;
+ u_int number, each, size, this;
+ int change, changed, status;
number = 0;
TAILQ_FOREACH (lc, &parent->cells, entry)
number++;
if (number <= 1)
return (0);
+ status = options_get_number(w->options, "pane-border-status");
if (parent->type == LAYOUT_LEFTRIGHT)
size = parent->sx;
- else if (parent->type == LAYOUT_TOPBOTTOM)
+ else if (parent->type == LAYOUT_TOPBOTTOM) {
size = parent->sy;
- else
+ if (status != 0)
+ size -= layout_need_status(parent, status == 1);
+ } else
+ return (0);
+ if (size < number - 1)
return (0);
each = (size - (number - 1)) / number;
+ if (each == 0)
+ return (0);
changed = 0;
TAILQ_FOREACH (lc, &parent->cells, entry) {
@@ -1037,7 +1049,10 @@ layout_spread_cell(struct window *w, struct layout_cell *parent)
change = each - (int)lc->sx;
layout_resize_adjust(w, lc, LAYOUT_LEFTRIGHT, change);
} else if (parent->type == LAYOUT_TOPBOTTOM) {
- change = each - (int)lc->sy;
+ this = each;
+ if (status != 0)
+ this += layout_need_status(lc, status == 1);
+ change = this - (int)lc->sy;
layout_resize_adjust(w, lc, LAYOUT_TOPBOTTOM, change);
}
if (change != 0)
diff --git a/resize.c b/resize.c
index 868ddac8..caac74ba 100644
--- a/resize.c
+++ b/resize.c
@@ -51,6 +51,8 @@ resize_window(struct window *w, u_int sx, u_int sy)
if (sy < w->layout_root->sy)
sy = w->layout_root->sy;
window_resize(w, sx, sy);
+ log_debug("%s: @%u resized to %u,%u; layout %u,%u", __func__, w->id,
+ sx, sy, w->layout_root->sx, w->layout_root->sy);
/* Restore the window zoom state. */
if (zoomed)
diff --git a/screen-redraw.c b/screen-redraw.c
index 691b2194..0ce3374d 100644
--- a/screen-redraw.c
+++ b/screen-redraw.c
@@ -290,7 +290,10 @@ screen_redraw_make_pane_status(struct client *c, struct window *w,
format_defaults(ft, c, NULL, NULL, wp);
expanded = format_expand_time(ft, fmt);
- wp->status_size = width = wp->sx - 4;
+ if (wp->sx < 4)
+ wp->status_size = width = 0;
+ else
+ wp->status_size = width = wp->sx - 4;
memcpy(&old, &wp->status_screen, sizeof old);
screen_init(&wp->status_screen, width, 1, 0);
diff --git a/tty.c b/tty.c
index 855f8e6a..9ed2b3a9 100644
--- a/tty.c
+++ b/tty.c
@@ -907,9 +907,8 @@ tty_is_visible(struct tty *tty, const struct tty_ctx *ctx, u_int px, u_int py,
lines = 0;
if (xoff + nx <= ctx->ox || xoff >= ctx->ox + ctx->sx ||
- yoff + ny <= ctx->oy || yoff >= lines + ctx->oy + ctx->sy) {
+ yoff + ny <= ctx->oy || yoff >= lines + ctx->oy + ctx->sy)
return (0);
- }
return (1);
}