=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/layout-set.c,v retrieving revision 1.18 retrieving revision 1.19 diff -c -r1.18 -r1.19 *** src/usr.bin/tmux/layout-set.c 2017/05/15 14:57:29 1.18 --- src/usr.bin/tmux/layout-set.c 2017/11/15 19:59:27 1.19 *************** *** 1,4 **** ! /* $OpenBSD: layout-set.c,v 1.18 2017/05/15 14:57:29 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: layout-set.c,v 1.19 2017/11/15 19:59:27 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott *************** *** 115,125 **** } static void ! layout_set_even_h(struct window *w) { struct window_pane *wp; struct layout_cell *lc, *lcnew; ! u_int i, n, width, xoff; layout_print_cell(w->layout_root, __func__, 1); --- 115,125 ---- } static void ! layout_set_even(struct window *w, enum layout_type type) { struct window_pane *wp; struct layout_cell *lc, *lcnew; ! u_int n; layout_print_cell(w->layout_root, __func__, 1); *************** *** 128,163 **** if (n <= 1) return; - /* How many can we fit? */ - width = (w->sx - (n - 1)) / n; - if (width < PANE_MINIMUM) - width = PANE_MINIMUM; - /* 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); ! layout_make_node(lc, LAYOUT_LEFTRIGHT); /* Build new leaf cells. */ - i = xoff = 0; TAILQ_FOREACH(wp, &w->panes, entry) { - /* Create child cell. */ lcnew = layout_create_cell(lc); - layout_set_size(lcnew, width, w->sy, xoff, 0); layout_make_leaf(lcnew, wp); TAILQ_INSERT_TAIL(&lc->cells, lcnew, entry); - - i++; - xoff += width + 1; } ! /* Allocate any remaining space. */ ! if (w->sx > xoff - 1) { ! lc = TAILQ_LAST(&lc->cells, layout_cells); ! layout_resize_adjust(w, lc, LAYOUT_LEFTRIGHT, ! w->sx - (xoff - 1)); ! } /* Fix cell offsets. */ layout_fix_offsets(lc); --- 128,148 ---- if (n <= 1) return; /* 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); ! layout_make_node(lc, type); /* Build new leaf cells. */ TAILQ_FOREACH(wp, &w->panes, entry) { lcnew = layout_create_cell(lc); layout_make_leaf(lcnew, wp); TAILQ_INSERT_TAIL(&lc->cells, lcnew, entry); } ! /* Spread out cells. */ ! layout_spread_cell(w, lc); /* Fix cell offsets. */ layout_fix_offsets(lc); *************** *** 170,227 **** } static void ! layout_set_even_v(struct window *w) { ! struct window_pane *wp; ! struct layout_cell *lc, *lcnew; ! u_int i, n, height, yoff; ! layout_print_cell(w->layout_root, __func__, 1); ! ! /* Get number of panes. */ ! n = window_count_panes(w); ! if (n <= 1) ! return; ! ! /* How many can we fit? */ ! height = (w->sy - (n - 1)) / n; ! if (height < PANE_MINIMUM) ! height = PANE_MINIMUM; ! ! /* 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); ! layout_make_node(lc, LAYOUT_TOPBOTTOM); ! ! /* Build new leaf cells. */ ! i = yoff = 0; ! TAILQ_FOREACH(wp, &w->panes, entry) { ! /* Create child cell. */ ! lcnew = layout_create_cell(lc); ! layout_set_size(lcnew, w->sx, height, 0, yoff); ! layout_make_leaf(lcnew, wp); ! TAILQ_INSERT_TAIL(&lc->cells, lcnew, entry); ! ! i++; ! yoff += height + 1; ! } ! ! /* Allocate any remaining space. */ ! if (w->sy > yoff - 1) { ! lc = TAILQ_LAST(&lc->cells, layout_cells); ! layout_resize_adjust(w, lc, LAYOUT_TOPBOTTOM, ! w->sy - (yoff - 1)); ! } ! ! /* Fix cell offsets. */ ! layout_fix_offsets(lc); ! layout_fix_panes(w, w->sx, w->sy); ! ! layout_print_cell(w->layout_root, __func__, 1); ! ! notify_window("window-layout-changed", w); ! server_redraw_window(w); } static void --- 155,169 ---- } static void ! layout_set_even_h(struct window *w) { ! layout_set_even(w, LAYOUT_LEFTRIGHT); ! } ! static void ! layout_set_even_v(struct window *w) ! { ! layout_set_even(w, LAYOUT_TOPBOTTOM); } static void