diff options
author | nicm <nicm> | 2019-04-04 10:25:35 +0000 |
---|---|---|
committer | nicm <nicm> | 2019-04-04 10:25:35 +0000 |
commit | f4aefb738ec1444842b476f98c45068bfef6f460 (patch) | |
tree | 393a5ee01aa8d688778c97c44650a9bb42f7517f | |
parent | f6c54f3f03353c415cfc59a65118f570972d51ff (diff) | |
download | rtmux-f4aefb738ec1444842b476f98c45068bfef6f460.tar.gz rtmux-f4aefb738ec1444842b476f98c45068bfef6f460.tar.bz2 rtmux-f4aefb738ec1444842b476f98c45068bfef6f460.zip |
Fix size check for splitw -f and top level pane size for tiled layout,
problems reported by Thomas Sattler.
-rw-r--r-- | layout-set.c | 3 | ||||
-rw-r--r-- | layout.c | 19 |
2 files changed, 14 insertions, 8 deletions
diff --git a/layout-set.c b/layout-set.c index b9769ed5..d99453c2 100644 --- a/layout-set.c +++ b/layout-set.c @@ -450,8 +450,7 @@ 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, (width + 1) * columns - 1, - (height + 1) * rows - 1, 0, 0); + layout_set_size(lc, w->sx, w->sy, 0, 0); layout_make_node(lc, LAYOUT_TOPBOTTOM); /* Create a grid of the cells. */ @@ -722,7 +722,7 @@ layout_set_size_check(struct window *w, struct layout_cell *lc, enum layout_type type, int size) { struct layout_cell *lcchild; - u_int new_size, available, previous, count, idx; + u_int new_size, available, previous, count, idx; /* Cells with no children must just be bigger than minimum. */ if (lc->type == LAYOUT_WINDOWPANE) @@ -736,6 +736,9 @@ layout_set_size_check(struct window *w, struct layout_cell *lc, /* Check new size will work for each child. */ if (lc->type == type) { + if (available < (count * 2) - 1) + return (0); + if (type == LAYOUT_LEFTRIGHT) previous = lc->sx; else @@ -745,13 +748,17 @@ layout_set_size_check(struct window *w, struct layout_cell *lc, TAILQ_FOREACH(lcchild, &lc->cells, entry) { new_size = layout_new_pane_size(w, previous, lcchild, type, size, count - idx, available); - if (new_size > available) - return (0); - - available -= (new_size + 1); + if (idx == count - 1) { + if (new_size > available) + return (0); + available -= new_size; + } else { + if (new_size + 1 > available) + return (0); + available -= new_size + 1; + } if (!layout_set_size_check(w, lcchild, type, new_size)) return (0); - idx++; } } else { |