mirror of
https://github.com/tmux/tmux.git
synced 2026-10-07 02:04:22 +00:00
Change layout sets to build the layout using the new mechanics, from
Dane Jensen.
This commit is contained in:
37
layout.c
37
layout.c
@@ -88,20 +88,24 @@ layout_create_cell(struct layout_cell *lcparent)
|
||||
|
||||
/* Free a layout cell. */
|
||||
void
|
||||
layout_free_cell(struct layout_cell *lc)
|
||||
layout_free_cell(struct layout_cell *lc, int only_nodes)
|
||||
{
|
||||
struct layout_cell *lcchild;
|
||||
struct layout_cell *lcchild, *lcnext;
|
||||
|
||||
if (lc == NULL)
|
||||
if (lc == NULL || (only_nodes && lc->type == LAYOUT_WINDOWPANE))
|
||||
return;
|
||||
|
||||
switch (lc->type) {
|
||||
case LAYOUT_LEFTRIGHT:
|
||||
case LAYOUT_TOPBOTTOM:
|
||||
while (!TAILQ_EMPTY(&lc->cells)) {
|
||||
lcchild = TAILQ_FIRST(&lc->cells);
|
||||
TAILQ_REMOVE(&lc->cells, lcchild, entry);
|
||||
layout_free_cell(lcchild);
|
||||
lcchild = TAILQ_FIRST(&lc->cells);
|
||||
while (lcchild != NULL) {
|
||||
lcnext = TAILQ_NEXT(lcchild, entry);
|
||||
if (!only_nodes || lcchild->type != LAYOUT_WINDOWPANE) {
|
||||
TAILQ_REMOVE(&lc->cells, lcchild, entry);
|
||||
layout_free_cell(lcchild, only_nodes);
|
||||
}
|
||||
lcchild = lcnext;
|
||||
}
|
||||
break;
|
||||
case LAYOUT_WINDOWPANE:
|
||||
@@ -255,7 +259,7 @@ layout_fix_zindexes(struct window *w, struct layout_cell *lc)
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
int
|
||||
layout_cell_is_tiled(struct layout_cell *lc)
|
||||
{
|
||||
int is_leaf = lc->type == LAYOUT_WINDOWPANE;
|
||||
@@ -699,13 +703,13 @@ layout_destroy_cell(struct window *w, struct layout_cell *lc,
|
||||
if (lcparent == NULL) {
|
||||
if (lc->wp != NULL)
|
||||
*lcroot = NULL;
|
||||
layout_free_cell(lc);
|
||||
layout_free_cell(lc, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!layout_cell_is_tiled(lc)) {
|
||||
TAILQ_REMOVE(&lcparent->cells, lc, entry);
|
||||
layout_free_cell(lc);
|
||||
layout_free_cell(lc, 0);
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -721,7 +725,7 @@ layout_destroy_cell(struct window *w, struct layout_cell *lc,
|
||||
|
||||
/* Remove this from the parent's list. */
|
||||
TAILQ_REMOVE(&lcparent->cells, lc, entry);
|
||||
layout_free_cell(lc);
|
||||
layout_free_cell(lc, 0);
|
||||
|
||||
out:
|
||||
/*
|
||||
@@ -742,7 +746,7 @@ out:
|
||||
} else
|
||||
TAILQ_REPLACE(&lc->parent->cells, lcparent, lc, entry);
|
||||
|
||||
layout_free_cell(lcparent);
|
||||
layout_free_cell(lcparent, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -760,9 +764,9 @@ layout_init(struct window *w, struct window_pane *wp)
|
||||
|
||||
/* Free layout for pane. */
|
||||
void
|
||||
layout_free(struct window *w)
|
||||
layout_free(struct window *w, int only_nodes)
|
||||
{
|
||||
layout_free_cell(w->layout_root);
|
||||
layout_free_cell(w->layout_root, only_nodes);
|
||||
}
|
||||
|
||||
/* Resize the entire layout after window resize. */
|
||||
@@ -1507,7 +1511,8 @@ layout_spread_cell(struct window *w, struct layout_cell *parent)
|
||||
|
||||
number = 0;
|
||||
TAILQ_FOREACH (lc, &parent->cells, entry)
|
||||
number++;
|
||||
if (layout_cell_is_tiled(lc))
|
||||
number++;
|
||||
if (number <= 1)
|
||||
return (0);
|
||||
status = window_get_pane_status(w);
|
||||
@@ -1535,6 +1540,8 @@ layout_spread_cell(struct window *w, struct layout_cell *parent)
|
||||
|
||||
changed = 0;
|
||||
TAILQ_FOREACH (lc, &parent->cells, entry) {
|
||||
if (!layout_cell_is_tiled(lc))
|
||||
continue;
|
||||
change = 0;
|
||||
if (parent->type == LAYOUT_LEFTRIGHT) {
|
||||
change = each - (int)lc->sx;
|
||||
|
||||
Reference in New Issue
Block a user