mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 00:56:10 +00:00 
			
		
		
		
	Merge branch 'obsd-master'
This commit is contained in:
		@@ -165,7 +165,7 @@ layout_parse(struct window *w, const char *layout)
 | 
			
		||||
	layout_assign(&wp, lc);
 | 
			
		||||
 | 
			
		||||
	/* Update pane offsets and sizes. */
 | 
			
		||||
	layout_fix_offsets(lc);
 | 
			
		||||
	layout_fix_offsets(w);
 | 
			
		||||
	layout_fix_panes(w);
 | 
			
		||||
	recalculate_sizes();
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -158,7 +158,7 @@ layout_set_even(struct window *w, enum layout_type type)
 | 
			
		||||
	layout_spread_cell(w, lc);
 | 
			
		||||
 | 
			
		||||
	/* Fix cell offsets. */
 | 
			
		||||
	layout_fix_offsets(lc);
 | 
			
		||||
	layout_fix_offsets(w);
 | 
			
		||||
	layout_fix_panes(w);
 | 
			
		||||
 | 
			
		||||
	layout_print_cell(w->layout_root, __func__, 1);
 | 
			
		||||
@@ -257,7 +257,7 @@ layout_set_main_h(struct window *w)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Fix cell offsets. */
 | 
			
		||||
	layout_fix_offsets(lc);
 | 
			
		||||
	layout_fix_offsets(w);
 | 
			
		||||
	layout_fix_panes(w);
 | 
			
		||||
 | 
			
		||||
	layout_print_cell(w->layout_root, __func__, 1);
 | 
			
		||||
@@ -344,7 +344,7 @@ layout_set_main_v(struct window *w)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Fix cell offsets. */
 | 
			
		||||
	layout_fix_offsets(lc);
 | 
			
		||||
	layout_fix_offsets(w);
 | 
			
		||||
	layout_fix_panes(w);
 | 
			
		||||
 | 
			
		||||
	layout_print_cell(w->layout_root, __func__, 1);
 | 
			
		||||
@@ -453,7 +453,7 @@ layout_set_tiled(struct window *w)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Fix cell offsets. */
 | 
			
		||||
	layout_fix_offsets(lc);
 | 
			
		||||
	layout_fix_offsets(w);
 | 
			
		||||
	layout_fix_panes(w);
 | 
			
		||||
 | 
			
		||||
	layout_print_cell(w->layout_root, __func__, 1);
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										137
									
								
								layout.c
									
									
									
									
									
								
							
							
						
						
									
										137
									
								
								layout.c
									
									
									
									
									
								
							@@ -39,7 +39,6 @@ static int	layout_resize_pane_grow(struct window *, struct layout_cell *,
 | 
			
		||||
		    enum layout_type, int, int);
 | 
			
		||||
static int	layout_resize_pane_shrink(struct window *, struct layout_cell *,
 | 
			
		||||
		    enum layout_type, int);
 | 
			
		||||
static int	layout_need_status(struct layout_cell *, int);
 | 
			
		||||
static u_int	layout_new_pane_size(struct window *, u_int,
 | 
			
		||||
		    struct layout_cell *, enum layout_type, u_int, u_int,
 | 
			
		||||
		    u_int);
 | 
			
		||||
@@ -199,9 +198,9 @@ layout_make_node(struct layout_cell *lc, enum layout_type type)
 | 
			
		||||
	lc->wp = NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Fix cell offsets based on their sizes. */
 | 
			
		||||
void
 | 
			
		||||
layout_fix_offsets(struct layout_cell *lc)
 | 
			
		||||
/* Fix cell offsets for a child cell. */
 | 
			
		||||
static void
 | 
			
		||||
layout_fix_offsets1(struct layout_cell *lc)
 | 
			
		||||
{
 | 
			
		||||
	struct layout_cell	*lcchild;
 | 
			
		||||
	u_int			 xoff, yoff;
 | 
			
		||||
@@ -212,7 +211,7 @@ layout_fix_offsets(struct layout_cell *lc)
 | 
			
		||||
			lcchild->xoff = xoff;
 | 
			
		||||
			lcchild->yoff = lc->yoff;
 | 
			
		||||
			if (lcchild->type != LAYOUT_WINDOWPANE)
 | 
			
		||||
				layout_fix_offsets(lcchild);
 | 
			
		||||
				layout_fix_offsets1(lcchild);
 | 
			
		||||
			xoff += lcchild->sx + 1;
 | 
			
		||||
		}
 | 
			
		||||
	} else {
 | 
			
		||||
@@ -221,61 +220,92 @@ layout_fix_offsets(struct layout_cell *lc)
 | 
			
		||||
			lcchild->xoff = lc->xoff;
 | 
			
		||||
			lcchild->yoff = yoff;
 | 
			
		||||
			if (lcchild->type != LAYOUT_WINDOWPANE)
 | 
			
		||||
				layout_fix_offsets(lcchild);
 | 
			
		||||
				layout_fix_offsets1(lcchild);
 | 
			
		||||
			yoff += lcchild->sy + 1;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Returns 1 if we need to reserve space for the pane status line. This is the
 | 
			
		||||
 * case for the most upper panes only.
 | 
			
		||||
 */
 | 
			
		||||
/* Update cell offsets based on their sizes. */
 | 
			
		||||
void
 | 
			
		||||
layout_fix_offsets(struct window *w)
 | 
			
		||||
{
 | 
			
		||||
	struct layout_cell      *lc = w->layout_root;
 | 
			
		||||
 | 
			
		||||
	lc->xoff = 0;
 | 
			
		||||
	lc->yoff = 0;
 | 
			
		||||
 | 
			
		||||
	layout_fix_offsets1(lc);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Is this a top cell? */
 | 
			
		||||
static int
 | 
			
		||||
layout_need_status(struct layout_cell *lc, int status)
 | 
			
		||||
layout_cell_is_top(struct window *w, struct layout_cell *lc)
 | 
			
		||||
{
 | 
			
		||||
	struct layout_cell	*next;
 | 
			
		||||
 | 
			
		||||
	if (lc->parent != NULL) {
 | 
			
		||||
		if (lc->parent->type == LAYOUT_LEFTRIGHT)
 | 
			
		||||
			return (layout_need_status(lc->parent, status));
 | 
			
		||||
 | 
			
		||||
		if (status == PANE_STATUS_TOP)
 | 
			
		||||
			next = TAILQ_FIRST(&lc->parent->cells);
 | 
			
		||||
		else
 | 
			
		||||
			next = TAILQ_LAST(&lc->parent->cells,layout_cells);
 | 
			
		||||
		if (lc == next)
 | 
			
		||||
			return (layout_need_status(lc->parent, status));
 | 
			
		||||
		return (0);
 | 
			
		||||
	while (lc != w->layout_root) {
 | 
			
		||||
		next = lc->parent;
 | 
			
		||||
		if (next->type == LAYOUT_TOPBOTTOM &&
 | 
			
		||||
		    lc != TAILQ_FIRST(&next->cells))
 | 
			
		||||
			return (0);
 | 
			
		||||
		lc = next;
 | 
			
		||||
	}
 | 
			
		||||
	return (1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Is this a bottom cell? */
 | 
			
		||||
static int
 | 
			
		||||
layout_cell_is_bottom(struct window *w, struct layout_cell *lc)
 | 
			
		||||
{
 | 
			
		||||
	struct layout_cell	*next;
 | 
			
		||||
 | 
			
		||||
	while (lc != w->layout_root) {
 | 
			
		||||
		next = lc->parent;
 | 
			
		||||
		if (next->type == LAYOUT_TOPBOTTOM &&
 | 
			
		||||
		    lc != TAILQ_LAST(&next->cells, layout_cells))
 | 
			
		||||
			return (0);
 | 
			
		||||
		lc = next;
 | 
			
		||||
	}
 | 
			
		||||
	return (1);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Returns 1 if we need to add an extra line for the pane status line. This is
 | 
			
		||||
 * the case for the most upper or lower panes only.
 | 
			
		||||
 */
 | 
			
		||||
static int
 | 
			
		||||
layout_add_border(struct window *w, struct layout_cell *lc, int status)
 | 
			
		||||
{
 | 
			
		||||
	if (status == PANE_STATUS_TOP)
 | 
			
		||||
		return (layout_cell_is_top(w, lc));
 | 
			
		||||
	if (status == PANE_STATUS_BOTTOM)
 | 
			
		||||
		return (layout_cell_is_bottom(w, lc));
 | 
			
		||||
	return (0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/* Update pane offsets and sizes based on their cells. */
 | 
			
		||||
void
 | 
			
		||||
layout_fix_panes(struct window *w)
 | 
			
		||||
{
 | 
			
		||||
	struct window_pane	*wp;
 | 
			
		||||
	struct layout_cell	*lc;
 | 
			
		||||
	int			 shift, status;
 | 
			
		||||
	int			 status;
 | 
			
		||||
 | 
			
		||||
	status = options_get_number(w->options, "pane-border-status");
 | 
			
		||||
	TAILQ_FOREACH(wp, &w->panes, entry) {
 | 
			
		||||
		if ((lc = wp->layout_cell) == NULL)
 | 
			
		||||
			continue;
 | 
			
		||||
 | 
			
		||||
		if (status != PANE_STATUS_OFF)
 | 
			
		||||
			shift = layout_need_status(lc, status);
 | 
			
		||||
		else
 | 
			
		||||
			shift = 0;
 | 
			
		||||
 | 
			
		||||
		wp->xoff = lc->xoff;
 | 
			
		||||
		wp->yoff = lc->yoff;
 | 
			
		||||
 | 
			
		||||
		if (shift && status == PANE_STATUS_TOP)
 | 
			
		||||
			wp->yoff += 1;
 | 
			
		||||
 | 
			
		||||
		window_pane_resize(wp, lc->sx, lc->sy - shift);
 | 
			
		||||
		if (layout_add_border(w, lc, status)) {
 | 
			
		||||
			if (status == PANE_STATUS_TOP)
 | 
			
		||||
				wp->yoff++;
 | 
			
		||||
			window_pane_resize(wp, lc->sx, lc->sy - 1);
 | 
			
		||||
		} else
 | 
			
		||||
			window_pane_resize(wp, lc->sx, lc->sy);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -312,13 +342,15 @@ layout_resize_check(struct window *w, struct layout_cell *lc,
 | 
			
		||||
	status = options_get_number(w->options, "pane-border-status");
 | 
			
		||||
	if (lc->type == LAYOUT_WINDOWPANE) {
 | 
			
		||||
		/* Space available in this cell only. */
 | 
			
		||||
		minimum = PANE_MINIMUM;
 | 
			
		||||
		if (type == LAYOUT_LEFTRIGHT)
 | 
			
		||||
		if (type == LAYOUT_LEFTRIGHT) {
 | 
			
		||||
			available = lc->sx;
 | 
			
		||||
		else {
 | 
			
		||||
			minimum = PANE_MINIMUM;
 | 
			
		||||
		} else {
 | 
			
		||||
			available = lc->sy;
 | 
			
		||||
			if (status != PANE_STATUS_OFF)
 | 
			
		||||
				minimum += layout_need_status(lc, status);
 | 
			
		||||
			if (layout_add_border(w, lc, status))
 | 
			
		||||
				minimum = PANE_MINIMUM + 1;
 | 
			
		||||
			else
 | 
			
		||||
				minimum = PANE_MINIMUM;
 | 
			
		||||
		}
 | 
			
		||||
		if (available > minimum)
 | 
			
		||||
			available -= minimum;
 | 
			
		||||
@@ -507,7 +539,7 @@ layout_resize(struct window *w, u_int sx, u_int sy)
 | 
			
		||||
		layout_resize_adjust(w, lc, LAYOUT_TOPBOTTOM, ychange);
 | 
			
		||||
 | 
			
		||||
	/* Fix cell offsets. */
 | 
			
		||||
	layout_fix_offsets(lc);
 | 
			
		||||
	layout_fix_offsets(w);
 | 
			
		||||
	layout_fix_panes(w);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -567,7 +599,7 @@ layout_resize_layout(struct window *w, struct layout_cell *lc,
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* Fix cell offsets. */
 | 
			
		||||
	layout_fix_offsets(w->layout_root);
 | 
			
		||||
	layout_fix_offsets(w);
 | 
			
		||||
	layout_fix_panes(w);
 | 
			
		||||
	notify_window("window-layout-changed", w);
 | 
			
		||||
}
 | 
			
		||||
@@ -861,9 +893,10 @@ layout_split_pane(struct window_pane *wp, enum layout_type type, int size,
 | 
			
		||||
			return (NULL);
 | 
			
		||||
		break;
 | 
			
		||||
	case LAYOUT_TOPBOTTOM:
 | 
			
		||||
		minimum = PANE_MINIMUM * 2 + 1;
 | 
			
		||||
		if (status != PANE_STATUS_OFF)
 | 
			
		||||
			minimum += layout_need_status(lc, status);
 | 
			
		||||
		if (layout_add_border(wp->window, lc, status))
 | 
			
		||||
			minimum = PANE_MINIMUM * 2 + 2;
 | 
			
		||||
		else
 | 
			
		||||
			minimum = PANE_MINIMUM * 2 + 1;
 | 
			
		||||
		if (sy < minimum)
 | 
			
		||||
			return (NULL);
 | 
			
		||||
		break;
 | 
			
		||||
@@ -988,7 +1021,7 @@ layout_split_pane(struct window_pane *wp, enum layout_type type, int size,
 | 
			
		||||
	if (full_size) {
 | 
			
		||||
		if (!resize_first)
 | 
			
		||||
			layout_resize_child_cells(wp->window, lc);
 | 
			
		||||
		layout_fix_offsets(wp->window->layout_root);
 | 
			
		||||
		layout_fix_offsets(wp->window);
 | 
			
		||||
	} else
 | 
			
		||||
		layout_make_leaf(lc, wp);
 | 
			
		||||
 | 
			
		||||
@@ -1006,7 +1039,7 @@ layout_close_pane(struct window_pane *wp)
 | 
			
		||||
 | 
			
		||||
	/* Fix pane offsets and sizes. */
 | 
			
		||||
	if (w->layout_root != NULL) {
 | 
			
		||||
		layout_fix_offsets(w->layout_root);
 | 
			
		||||
		layout_fix_offsets(w);
 | 
			
		||||
		layout_fix_panes(w);
 | 
			
		||||
	}
 | 
			
		||||
	notify_window("window-layout-changed", w);
 | 
			
		||||
@@ -1029,9 +1062,10 @@ layout_spread_cell(struct window *w, struct layout_cell *parent)
 | 
			
		||||
	if (parent->type == LAYOUT_LEFTRIGHT)
 | 
			
		||||
		size = parent->sx;
 | 
			
		||||
	else if (parent->type == LAYOUT_TOPBOTTOM) {
 | 
			
		||||
		size = parent->sy;
 | 
			
		||||
		if (status != PANE_STATUS_OFF)
 | 
			
		||||
			size -= layout_need_status(parent, status);
 | 
			
		||||
		if (layout_add_border(w, parent, status))
 | 
			
		||||
			size = parent->sy - 1;
 | 
			
		||||
		else
 | 
			
		||||
			size = parent->sy;
 | 
			
		||||
	} else
 | 
			
		||||
		return (0);
 | 
			
		||||
	if (size < number - 1)
 | 
			
		||||
@@ -1049,9 +1083,10 @@ layout_spread_cell(struct window *w, struct layout_cell *parent)
 | 
			
		||||
			change = each - (int)lc->sx;
 | 
			
		||||
			layout_resize_adjust(w, lc, LAYOUT_LEFTRIGHT, change);
 | 
			
		||||
		} else if (parent->type == LAYOUT_TOPBOTTOM) {
 | 
			
		||||
			this = each;
 | 
			
		||||
			if (status != PANE_STATUS_OFF)
 | 
			
		||||
				this += layout_need_status(lc, status);
 | 
			
		||||
			if (layout_add_border(w, lc, status))
 | 
			
		||||
				this = each + 1;
 | 
			
		||||
			else
 | 
			
		||||
				this = each;
 | 
			
		||||
			change = this - (int)lc->sy;
 | 
			
		||||
			layout_resize_adjust(w, lc, LAYOUT_TOPBOTTOM, change);
 | 
			
		||||
		}
 | 
			
		||||
@@ -1073,7 +1108,7 @@ layout_spread_out(struct window_pane *wp)
 | 
			
		||||
 | 
			
		||||
	do {
 | 
			
		||||
		if (layout_spread_cell(w, parent)) {
 | 
			
		||||
			layout_fix_offsets(parent);
 | 
			
		||||
			layout_fix_offsets(w);
 | 
			
		||||
			layout_fix_panes(w);
 | 
			
		||||
			break;
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										2
									
								
								tmux.h
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								tmux.h
									
									
									
									
									
								
							@@ -2440,7 +2440,7 @@ void		 layout_set_size(struct layout_cell *, u_int, u_int, u_int,
 | 
			
		||||
		     u_int);
 | 
			
		||||
void		 layout_make_leaf(struct layout_cell *, struct window_pane *);
 | 
			
		||||
void		 layout_make_node(struct layout_cell *, enum layout_type);
 | 
			
		||||
void		 layout_fix_offsets(struct layout_cell *);
 | 
			
		||||
void		 layout_fix_offsets(struct window *);
 | 
			
		||||
void		 layout_fix_panes(struct window *);
 | 
			
		||||
void		 layout_resize_adjust(struct window *, struct layout_cell *,
 | 
			
		||||
		     enum layout_type, int);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user