mirror of
https://github.com/tmux/tmux.git
synced 2025-01-12 03:08:46 +00:00
Merge a number of fixes from master for layouts, mostly prompted by testing by
Thomas Sattler.
This commit is contained in:
parent
73b54a0e5f
commit
bba1809eac
@ -135,6 +135,7 @@ cmd_select_layout_exec(struct cmd *self, struct cmdq_item *item)
|
|||||||
|
|
||||||
changed:
|
changed:
|
||||||
free(oldlayout);
|
free(oldlayout);
|
||||||
|
recalculate_sizes();
|
||||||
server_redraw_window(w);
|
server_redraw_window(w);
|
||||||
notify_window("window-layout-changed", w);
|
notify_window("window-layout-changed", w);
|
||||||
return (CMD_RETURN_NORMAL);
|
return (CMD_RETURN_NORMAL);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# configure.ac
|
# configure.ac
|
||||||
|
|
||||||
AC_INIT([tmux], 2.9-rc2)
|
AC_INIT([tmux], 2.9-rc3)
|
||||||
AC_PREREQ([2.60])
|
AC_PREREQ([2.60])
|
||||||
|
|
||||||
AC_CONFIG_AUX_DIR(etc)
|
AC_CONFIG_AUX_DIR(etc)
|
||||||
|
275
layout-set.c
275
layout-set.c
@ -119,7 +119,7 @@ layout_set_even(struct window *w, enum layout_type type)
|
|||||||
{
|
{
|
||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
struct layout_cell *lc, *lcnew;
|
struct layout_cell *lc, *lcnew;
|
||||||
u_int n;
|
u_int n, sx, sy;
|
||||||
|
|
||||||
layout_print_cell(w->layout_root, __func__, 1);
|
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. */
|
/* Free the old root and construct a new. */
|
||||||
layout_free(w);
|
layout_free(w);
|
||||||
lc = w->layout_root = layout_create_cell(NULL);
|
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);
|
layout_make_node(lc, type);
|
||||||
|
|
||||||
/* Build new leaf cells. */
|
/* 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);
|
layout_print_cell(w->layout_root, __func__, 1);
|
||||||
|
|
||||||
|
window_resize(w, lc->sx, lc->sy);
|
||||||
notify_window("window-layout-changed", w);
|
notify_window("window-layout-changed", w);
|
||||||
server_redraw_window(w);
|
server_redraw_window(w);
|
||||||
}
|
}
|
||||||
@ -172,9 +184,8 @@ static void
|
|||||||
layout_set_main_h(struct window *w)
|
layout_set_main_h(struct window *w)
|
||||||
{
|
{
|
||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
struct layout_cell *lc, *lcmain, *lcrow, *lcchild;
|
struct layout_cell *lc, *lcmain, *lcother, *lcchild;
|
||||||
u_int n, mainheight, otherheight, width, height;
|
u_int n, mainh, otherh, sx;
|
||||||
u_int used, i, j, columns, rows, totalrows;
|
|
||||||
|
|
||||||
layout_print_cell(w->layout_root, __func__, 1);
|
layout_print_cell(w->layout_root, __func__, 1);
|
||||||
|
|
||||||
@ -184,103 +195,57 @@ layout_set_main_h(struct window *w)
|
|||||||
return;
|
return;
|
||||||
n--; /* take off main pane */
|
n--; /* take off main pane */
|
||||||
|
|
||||||
/* How many rows and columns will be needed, not counting main? */
|
/* Get the main pane height and work out the other pane height. */
|
||||||
columns = (w->sx + 1) / (PANE_MINIMUM + 1); /* maximum columns */
|
mainh = options_get_number(w->options, "main-pane-height");
|
||||||
if (columns == 0)
|
if (mainh + PANE_MINIMUM + 1 >= w->sy) {
|
||||||
columns = 1;
|
if (w->sy <= PANE_MINIMUM + 1 + PANE_MINIMUM)
|
||||||
rows = 1 + (n - 1) / columns;
|
mainh = PANE_MINIMUM;
|
||||||
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;
|
|
||||||
else
|
else
|
||||||
mainheight = w->sy - totalrows;
|
mainh = w->sy - (PANE_MINIMUM + 1);
|
||||||
height = PANE_MINIMUM;
|
otherh = PANE_MINIMUM;
|
||||||
} else
|
} else {
|
||||||
height = (w->sy - mainheight - (rows - 1)) / rows;
|
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. */
|
/* Free old tree and create a new root. */
|
||||||
layout_free(w);
|
layout_free(w);
|
||||||
lc = w->layout_root = layout_create_cell(NULL);
|
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);
|
layout_make_node(lc, LAYOUT_TOPBOTTOM);
|
||||||
|
|
||||||
/* Create the main pane. */
|
/* Create the main pane. */
|
||||||
lcmain = layout_create_cell(lc);
|
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));
|
layout_make_leaf(lcmain, TAILQ_FIRST(&w->panes));
|
||||||
TAILQ_INSERT_TAIL(&lc->cells, lcmain, entry);
|
TAILQ_INSERT_TAIL(&lc->cells, lcmain, entry);
|
||||||
|
|
||||||
/* Create a grid of the remaining cells. */
|
/* Create the other pane. */
|
||||||
wp = TAILQ_NEXT(TAILQ_FIRST(&w->panes), entry);
|
lcother = layout_create_cell(lc);
|
||||||
for (j = 0; j < rows; j++) {
|
layout_set_size(lcother, sx, otherh, 0, 0);
|
||||||
/* If this is the last cell, all done. */
|
layout_make_node(lcother, LAYOUT_LEFTRIGHT);
|
||||||
if (wp == NULL)
|
TAILQ_INSERT_TAIL(&lc->cells, lcother, entry);
|
||||||
break;
|
|
||||||
|
|
||||||
/* Create the new row. */
|
/* Add the remaining panes as children. */
|
||||||
lcrow = layout_create_cell(lc);
|
TAILQ_FOREACH(wp, &w->panes, entry) {
|
||||||
layout_set_size(lcrow, w->sx, height, 0, 0);
|
if (wp == TAILQ_FIRST(&w->panes))
|
||||||
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;
|
continue;
|
||||||
}
|
lcchild = layout_create_cell(lc);
|
||||||
|
layout_set_size(lcchild, PANE_MINIMUM, otherh, 0, 0);
|
||||||
/* Add in the columns. */
|
layout_make_leaf(lcchild, wp);
|
||||||
layout_make_node(lcrow, LAYOUT_LEFTRIGHT);
|
TAILQ_INSERT_TAIL(&lcother->cells, lcchild, entry);
|
||||||
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);
|
|
||||||
|
|
||||||
/* 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)
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
layout_spread_cell(w, lcother);
|
||||||
|
|
||||||
/* Fix cell offsets. */
|
/* Fix cell offsets. */
|
||||||
layout_fix_offsets(lc);
|
layout_fix_offsets(lc);
|
||||||
@ -288,6 +253,7 @@ layout_set_main_h(struct window *w)
|
|||||||
|
|
||||||
layout_print_cell(w->layout_root, __func__, 1);
|
layout_print_cell(w->layout_root, __func__, 1);
|
||||||
|
|
||||||
|
window_resize(w, lc->sx, lc->sy);
|
||||||
notify_window("window-layout-changed", w);
|
notify_window("window-layout-changed", w);
|
||||||
server_redraw_window(w);
|
server_redraw_window(w);
|
||||||
}
|
}
|
||||||
@ -296,9 +262,8 @@ static void
|
|||||||
layout_set_main_v(struct window *w)
|
layout_set_main_v(struct window *w)
|
||||||
{
|
{
|
||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
struct layout_cell *lc, *lcmain, *lccolumn, *lcchild;
|
struct layout_cell *lc, *lcmain, *lcother, *lcchild;
|
||||||
u_int n, mainwidth, otherwidth, width, height;
|
u_int n, mainw, otherw, sy;
|
||||||
u_int used, i, j, columns, rows, totalcolumns;
|
|
||||||
|
|
||||||
layout_print_cell(w->layout_root, __func__, 1);
|
layout_print_cell(w->layout_root, __func__, 1);
|
||||||
|
|
||||||
@ -308,103 +273,57 @@ layout_set_main_v(struct window *w)
|
|||||||
return;
|
return;
|
||||||
n--; /* take off main pane */
|
n--; /* take off main pane */
|
||||||
|
|
||||||
/* How many rows and columns will be needed, not counting main? */
|
/* Get the main pane width and work out the other pane width. */
|
||||||
rows = (w->sy + 1) / (PANE_MINIMUM + 1); /* maximum rows */
|
mainw = options_get_number(w->options, "main-pane-width");
|
||||||
if (rows == 0)
|
if (mainw + PANE_MINIMUM + 1 >= w->sx) {
|
||||||
rows = 1;
|
if (w->sx <= PANE_MINIMUM + 1 + PANE_MINIMUM)
|
||||||
columns = 1 + (n - 1) / rows;
|
mainw = PANE_MINIMUM;
|
||||||
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;
|
|
||||||
else
|
else
|
||||||
mainwidth = w->sx - totalcolumns;
|
mainw = w->sx - (PANE_MINIMUM + 1);
|
||||||
width = PANE_MINIMUM;
|
otherw = PANE_MINIMUM;
|
||||||
} else
|
} else {
|
||||||
width = (w->sx - mainwidth - (columns - 1)) / columns;
|
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. */
|
/* Free old tree and create a new root. */
|
||||||
layout_free(w);
|
layout_free(w);
|
||||||
lc = w->layout_root = layout_create_cell(NULL);
|
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);
|
layout_make_node(lc, LAYOUT_LEFTRIGHT);
|
||||||
|
|
||||||
/* Create the main pane. */
|
/* Create the main pane. */
|
||||||
lcmain = layout_create_cell(lc);
|
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));
|
layout_make_leaf(lcmain, TAILQ_FIRST(&w->panes));
|
||||||
TAILQ_INSERT_TAIL(&lc->cells, lcmain, entry);
|
TAILQ_INSERT_TAIL(&lc->cells, lcmain, entry);
|
||||||
|
|
||||||
/* Create a grid of the remaining cells. */
|
/* Create the other pane. */
|
||||||
wp = TAILQ_NEXT(TAILQ_FIRST(&w->panes), entry);
|
lcother = layout_create_cell(lc);
|
||||||
for (j = 0; j < columns; j++) {
|
layout_set_size(lcother, otherw, sy, 0, 0);
|
||||||
/* If this is the last cell, all done. */
|
layout_make_node(lcother, LAYOUT_TOPBOTTOM);
|
||||||
if (wp == NULL)
|
TAILQ_INSERT_TAIL(&lc->cells, lcother, entry);
|
||||||
break;
|
|
||||||
|
|
||||||
/* Create the new column. */
|
/* Add the remaining panes as children. */
|
||||||
lccolumn = layout_create_cell(lc);
|
TAILQ_FOREACH(wp, &w->panes, entry) {
|
||||||
layout_set_size(lccolumn, width, w->sy, 0, 0);
|
if (wp == TAILQ_FIRST(&w->panes))
|
||||||
TAILQ_INSERT_TAIL(&lc->cells, lccolumn, entry);
|
|
||||||
|
|
||||||
/* If only one row, just use the row directly. */
|
|
||||||
if (rows == 1) {
|
|
||||||
layout_make_leaf(lccolumn, wp);
|
|
||||||
wp = TAILQ_NEXT(wp, entry);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
lcchild = layout_create_cell(lc);
|
||||||
|
layout_set_size(lcchild, otherw, PANE_MINIMUM, 0, 0);
|
||||||
/* Add in the rows. */
|
layout_make_leaf(lcchild, wp);
|
||||||
layout_make_node(lccolumn, LAYOUT_TOPBOTTOM);
|
TAILQ_INSERT_TAIL(&lcother->cells, lcchild, entry);
|
||||||
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)
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
layout_spread_cell(w, lcother);
|
||||||
|
|
||||||
/* Fix cell offsets. */
|
/* Fix cell offsets. */
|
||||||
layout_fix_offsets(lc);
|
layout_fix_offsets(lc);
|
||||||
@ -412,6 +331,7 @@ layout_set_main_v(struct window *w)
|
|||||||
|
|
||||||
layout_print_cell(w->layout_root, __func__, 1);
|
layout_print_cell(w->layout_root, __func__, 1);
|
||||||
|
|
||||||
|
window_resize(w, lc->sx, lc->sy);
|
||||||
notify_window("window-layout-changed", w);
|
notify_window("window-layout-changed", w);
|
||||||
server_redraw_window(w);
|
server_redraw_window(w);
|
||||||
}
|
}
|
||||||
@ -421,7 +341,7 @@ layout_set_tiled(struct window *w)
|
|||||||
{
|
{
|
||||||
struct window_pane *wp;
|
struct window_pane *wp;
|
||||||
struct layout_cell *lc, *lcrow, *lcchild;
|
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;
|
u_int i, j, columns, rows;
|
||||||
|
|
||||||
layout_print_cell(w->layout_root, __func__, 1);
|
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. */
|
/* Free old tree and create a new root. */
|
||||||
layout_free(w);
|
layout_free(w);
|
||||||
lc = w->layout_root = layout_create_cell(NULL);
|
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);
|
layout_make_node(lc, LAYOUT_TOPBOTTOM);
|
||||||
|
|
||||||
/* Create a grid of the cells. */
|
/* Create a grid of the cells. */
|
||||||
@ -514,6 +440,7 @@ layout_set_tiled(struct window *w)
|
|||||||
|
|
||||||
layout_print_cell(w->layout_root, __func__, 1);
|
layout_print_cell(w->layout_root, __func__, 1);
|
||||||
|
|
||||||
|
window_resize(w, lc->sx, lc->sy);
|
||||||
notify_window("window-layout-changed", w);
|
notify_window("window-layout-changed", w);
|
||||||
server_redraw_window(w);
|
server_redraw_window(w);
|
||||||
}
|
}
|
||||||
|
33
layout.c
33
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
|
* out proportionately - this should leave the layout fitting the new
|
||||||
* window size.
|
* window size.
|
||||||
*/
|
*/
|
||||||
xchange = sx - w->sx;
|
xchange = sx - lc->sx;
|
||||||
xlimit = layout_resize_check(w, lc, LAYOUT_LEFTRIGHT);
|
xlimit = layout_resize_check(w, lc, LAYOUT_LEFTRIGHT);
|
||||||
if (xchange < 0 && xchange < -xlimit)
|
if (xchange < 0 && xchange < -xlimit)
|
||||||
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);
|
layout_resize_adjust(w, lc, LAYOUT_LEFTRIGHT, xchange);
|
||||||
|
|
||||||
/* Adjust vertically in a similar fashion. */
|
/* Adjust vertically in a similar fashion. */
|
||||||
ychange = sy - w->sy;
|
ychange = sy - lc->sy;
|
||||||
ylimit = layout_resize_check(w, lc, LAYOUT_TOPBOTTOM);
|
ylimit = layout_resize_check(w, lc, LAYOUT_TOPBOTTOM);
|
||||||
if (ychange < 0 && ychange < -ylimit)
|
if (ychange < 0 && ychange < -ylimit)
|
||||||
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)
|
int insert_before, int full_size)
|
||||||
{
|
{
|
||||||
struct layout_cell *lc, *lcparent, *lcnew, *lc1, *lc2;
|
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;
|
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
|
* 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;
|
lc = wp->window->layout_root;
|
||||||
else
|
else
|
||||||
lc = wp->layout_cell;
|
lc = wp->layout_cell;
|
||||||
|
status = options_get_number(wp->window->options, "pane-border-status");
|
||||||
|
|
||||||
/* Copy the old cell size. */
|
/* Copy the old cell size. */
|
||||||
sx = lc->sx;
|
sx = lc->sx;
|
||||||
@ -859,7 +861,10 @@ layout_split_pane(struct window_pane *wp, enum layout_type type, int size,
|
|||||||
return (NULL);
|
return (NULL);
|
||||||
break;
|
break;
|
||||||
case LAYOUT_TOPBOTTOM:
|
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);
|
return (NULL);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -1011,22 +1016,29 @@ int
|
|||||||
layout_spread_cell(struct window *w, struct layout_cell *parent)
|
layout_spread_cell(struct window *w, struct layout_cell *parent)
|
||||||
{
|
{
|
||||||
struct layout_cell *lc;
|
struct layout_cell *lc;
|
||||||
u_int number, each, size;
|
u_int number, each, size, this;
|
||||||
int change, changed;
|
int change, changed, status;
|
||||||
|
|
||||||
number = 0;
|
number = 0;
|
||||||
TAILQ_FOREACH (lc, &parent->cells, entry)
|
TAILQ_FOREACH (lc, &parent->cells, entry)
|
||||||
number++;
|
number++;
|
||||||
if (number <= 1)
|
if (number <= 1)
|
||||||
return (0);
|
return (0);
|
||||||
|
status = options_get_number(w->options, "pane-border-status");
|
||||||
|
|
||||||
if (parent->type == LAYOUT_LEFTRIGHT)
|
if (parent->type == LAYOUT_LEFTRIGHT)
|
||||||
size = parent->sx;
|
size = parent->sx;
|
||||||
else if (parent->type == LAYOUT_TOPBOTTOM)
|
else if (parent->type == LAYOUT_TOPBOTTOM) {
|
||||||
size = parent->sy;
|
size = parent->sy;
|
||||||
else
|
if (status != 0)
|
||||||
|
size -= layout_need_status(parent, status == 1);
|
||||||
|
} else
|
||||||
|
return (0);
|
||||||
|
if (size < number - 1)
|
||||||
return (0);
|
return (0);
|
||||||
each = (size - (number - 1)) / number;
|
each = (size - (number - 1)) / number;
|
||||||
|
if (each == 0)
|
||||||
|
return (0);
|
||||||
|
|
||||||
changed = 0;
|
changed = 0;
|
||||||
TAILQ_FOREACH (lc, &parent->cells, entry) {
|
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;
|
change = each - (int)lc->sx;
|
||||||
layout_resize_adjust(w, lc, LAYOUT_LEFTRIGHT, change);
|
layout_resize_adjust(w, lc, LAYOUT_LEFTRIGHT, change);
|
||||||
} else if (parent->type == LAYOUT_TOPBOTTOM) {
|
} 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);
|
layout_resize_adjust(w, lc, LAYOUT_TOPBOTTOM, change);
|
||||||
}
|
}
|
||||||
if (change != 0)
|
if (change != 0)
|
||||||
|
2
resize.c
2
resize.c
@ -51,6 +51,8 @@ resize_window(struct window *w, u_int sx, u_int sy)
|
|||||||
if (sy < w->layout_root->sy)
|
if (sy < w->layout_root->sy)
|
||||||
sy = w->layout_root->sy;
|
sy = w->layout_root->sy;
|
||||||
window_resize(w, sx, 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. */
|
/* Restore the window zoom state. */
|
||||||
if (zoomed)
|
if (zoomed)
|
||||||
|
@ -290,7 +290,10 @@ screen_redraw_make_pane_status(struct client *c, struct window *w,
|
|||||||
format_defaults(ft, c, NULL, NULL, wp);
|
format_defaults(ft, c, NULL, NULL, wp);
|
||||||
|
|
||||||
expanded = format_expand_time(ft, fmt);
|
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);
|
memcpy(&old, &wp->status_screen, sizeof old);
|
||||||
screen_init(&wp->status_screen, width, 1, 0);
|
screen_init(&wp->status_screen, width, 1, 0);
|
||||||
|
3
tty.c
3
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;
|
lines = 0;
|
||||||
|
|
||||||
if (xoff + nx <= ctx->ox || xoff >= ctx->ox + ctx->sx ||
|
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 (0);
|
||||||
}
|
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user