mirror of
https://github.com/tmux/tmux.git
synced 2026-06-20 17:25:57 +00:00
Fixed tiled cell detection and removed dead guard.
This commit is contained in:
47
layout.c
47
layout.c
@@ -30,8 +30,9 @@
|
|||||||
* a cell which contains a list of cells, and 'leaf' to refer to a cell that
|
* a cell which contains a list of cells, and 'leaf' to refer to a cell that
|
||||||
* contains a window pane. A leaf is considered to be 'tiled' if it is to be
|
* contains a window pane. A leaf is considered to be 'tiled' if it is to be
|
||||||
* drawn as a part of the tiled layout. A 'neighbour' is a sibling that is also
|
* drawn as a part of the tiled layout. A 'neighbour' is a sibling that is also
|
||||||
* tiled. A cell's 'split' size refers to the side that is shortened when
|
* tiled or a node that contains a tiled leaf in a subtree. A cell's 'split'
|
||||||
* splitting it, determined by the parent's type.
|
* size refers to the side that is shortened when splitting it, determined by
|
||||||
|
* the parent's type.
|
||||||
*
|
*
|
||||||
* Each window has a pointer to the root of its layout tree (containing its
|
* Each window has a pointer to the root of its layout tree (containing its
|
||||||
* panes), every pane has a pointer back to the cell containing it, and each
|
* panes), every pane has a pointer back to the cell containing it, and each
|
||||||
@@ -306,6 +307,27 @@ layout_cell_is_first_tiled(struct layout_cell *lc)
|
|||||||
return (lcchild == lc);
|
return (lcchild == lc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct layout_cell *
|
||||||
|
layout_cell_get_first_tiled(struct layout_cell *lc)
|
||||||
|
{
|
||||||
|
struct layout_cell *lcchild, *lcchild2;
|
||||||
|
|
||||||
|
if (layout_cell_is_tiled(lc))
|
||||||
|
return (lc);
|
||||||
|
if (lc->type == LAYOUT_WINDOWPANE)
|
||||||
|
return (NULL);
|
||||||
|
|
||||||
|
TAILQ_FOREACH(lcchild, &lc->cells, entry) {
|
||||||
|
if (layout_cell_is_tiled(lcchild))
|
||||||
|
return (lcchild);
|
||||||
|
if (lcchild->type != LAYOUT_WINDOWPANE) {
|
||||||
|
lcchild2 = layout_cell_get_first_tiled(lcchild);
|
||||||
|
if (lcchild2 != NULL)
|
||||||
|
return (lcchild2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (NULL);
|
||||||
|
}
|
||||||
|
|
||||||
/* Fix cell offsets for a child cell. */
|
/* Fix cell offsets for a child cell. */
|
||||||
static void
|
static void
|
||||||
@@ -1734,8 +1756,7 @@ layout_remove_tile(struct window *w, struct layout_cell *lc)
|
|||||||
int
|
int
|
||||||
layout_insert_tile(struct window *w, struct layout_cell *lc)
|
layout_insert_tile(struct window *w, struct layout_cell *lc)
|
||||||
{
|
{
|
||||||
struct window_pane *wp;
|
struct layout_cell *lcneighbour, *lctiled, *lcparent = lc->parent;
|
||||||
struct layout_cell *lcneighbour, *lcparent = lc->parent;
|
|
||||||
enum layout_type type;
|
enum layout_type type;
|
||||||
u_int size1, size2, saved_size;
|
u_int size1, size2, saved_size;
|
||||||
|
|
||||||
@@ -1766,18 +1787,11 @@ layout_insert_tile(struct window *w, struct layout_cell *lc)
|
|||||||
layout_resize_set_size(w, lc, type, size1);
|
layout_resize_set_size(w, lc, type, size1);
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
* In order to determine if there is enough space to retile the
|
* If the neighbour is a node, a tiled child in the subtree of
|
||||||
* pane, information is needed from window and window pane
|
* the neighbour is needed to check for space.
|
||||||
* options. First get a neightbour window pane...
|
|
||||||
*/
|
*/
|
||||||
if (~lcneighbour->type & LAYOUT_WINDOWPANE)
|
lctiled = layout_cell_get_first_tiled(lcneighbour);
|
||||||
wp = TAILQ_FIRST(&lcneighbour->cells)->wp;
|
if (!layout_split_check_space(lctiled->wp, lcneighbour, type))
|
||||||
else
|
|
||||||
wp = lcneighbour->wp;
|
|
||||||
/*
|
|
||||||
* ...and then check if there is enough room to tile.
|
|
||||||
*/
|
|
||||||
if (!layout_split_check_space(wp, lcneighbour, type))
|
|
||||||
return (0);
|
return (0);
|
||||||
|
|
||||||
layout_split_sizes(lcneighbour, -1, 0, type, &size1, &size2,
|
layout_split_sizes(lcneighbour, -1, 0, type, &size1, &size2,
|
||||||
@@ -1787,7 +1801,6 @@ layout_insert_tile(struct window *w, struct layout_cell *lc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Setting opposite of the 'split' size to that of the parent. */
|
/* Setting opposite of the 'split' size to that of the parent. */
|
||||||
if (lcparent != NULL) {
|
|
||||||
if (lcparent->type == LAYOUT_LEFTRIGHT) {
|
if (lcparent->type == LAYOUT_LEFTRIGHT) {
|
||||||
size1 = lcparent->sy;
|
size1 = lcparent->sy;
|
||||||
type = LAYOUT_TOPBOTTOM;
|
type = LAYOUT_TOPBOTTOM;
|
||||||
@@ -1796,6 +1809,6 @@ layout_insert_tile(struct window *w, struct layout_cell *lc)
|
|||||||
type = LAYOUT_LEFTRIGHT;
|
type = LAYOUT_LEFTRIGHT;
|
||||||
}
|
}
|
||||||
layout_resize_set_size(w, lc, type, size1);
|
layout_resize_set_size(w, lc, type, size1);
|
||||||
}
|
|
||||||
return (1);
|
return (1);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user