diff options
author | Thomas Adam <thomas@xteddy.org> | 2016-04-29 18:01:09 +0100 |
---|---|---|
committer | Thomas Adam <thomas@xteddy.org> | 2016-04-29 18:01:09 +0100 |
commit | 55d472a9fe9b3d4196b8307a65480f6d66b95e9c (patch) | |
tree | e76c0961ba35fa67566947ea0247dc0aed3e1ce4 /layout.c | |
parent | ba9f32b464effc09b7ceaef21b1804c49ece17db (diff) | |
parent | eb8e76d4332e089e5cd3c5a3c9f4bf64c9474909 (diff) | |
download | rtmux-55d472a9fe9b3d4196b8307a65480f6d66b95e9c.tar.gz rtmux-55d472a9fe9b3d4196b8307a65480f6d66b95e9c.tar.bz2 rtmux-55d472a9fe9b3d4196b8307a65480f6d66b95e9c.zip |
Merge branch 'obsd-master'
Diffstat (limited to 'layout.c')
-rw-r--r-- | layout.c | 50 |
1 files changed, 46 insertions, 4 deletions
@@ -32,8 +32,11 @@ * cell a pointer to its parent cell. */ -int layout_resize_pane_grow(struct layout_cell *, enum layout_type, int); -int layout_resize_pane_shrink(struct layout_cell *, enum layout_type, int); +static int layout_resize_pane_grow(struct layout_cell *, enum layout_type, + int); +static int layout_resize_pane_shrink(struct layout_cell *, + enum layout_type, int); +static int layout_need_status(struct layout_cell *, int); struct layout_cell * layout_create_cell(struct layout_cell *lcparent) @@ -163,6 +166,30 @@ layout_fix_offsets(struct layout_cell *lc) } } +/* + * Returns 1 if we need to reserve space for the pane status line. This is the + * case for the most upper panes only. + */ +static int +layout_need_status(struct layout_cell *lc, int at_top) +{ + struct layout_cell *first_lc; + + if (lc->parent) { + if (lc->parent->type == LAYOUT_LEFTRIGHT) + return (layout_need_status(lc->parent, at_top)); + + if (at_top) + first_lc = TAILQ_FIRST(&lc->parent->cells); + else + first_lc = TAILQ_LAST(&lc->parent->cells,layout_cells); + if (lc == first_lc) + return (layout_need_status(lc->parent, at_top)); + return (0); + } + return (1); +} + /* Update pane offsets and sizes based on their cells. */ void layout_fix_panes(struct window *w, u_int wsx, u_int wsy) @@ -170,13 +197,25 @@ layout_fix_panes(struct window *w, u_int wsx, u_int wsy) struct window_pane *wp; struct layout_cell *lc; u_int sx, sy; + int shift, status, at_top; + status = options_get_number(w->options, "pane-border-status"); + at_top = (status == 1); TAILQ_FOREACH(wp, &w->panes, entry) { if ((lc = wp->layout_cell) == NULL) continue; + + if (status != 0) + shift = layout_need_status(lc, at_top); + else + shift = 0; + wp->xoff = lc->xoff; wp->yoff = lc->yoff; + if (shift && at_top) + wp->yoff += 1; + /* * Layout cells are limited by the smallest size of other cells * within the same row or column; if this isn't the case @@ -214,6 +253,9 @@ layout_fix_panes(struct window *w, u_int wsx, u_int wsy) sy = lc->sy; } + if (shift) + sy -= 1; + window_pane_resize(wp, sx, sy); } } @@ -520,7 +562,7 @@ layout_resize_pane(struct window_pane *wp, enum layout_type type, int change) } /* Helper function to grow pane. */ -int +static int layout_resize_pane_grow(struct layout_cell *lc, enum layout_type type, int needed) { @@ -561,7 +603,7 @@ layout_resize_pane_grow(struct layout_cell *lc, enum layout_type type, } /* Helper function to shrink pane. */ -int +static int layout_resize_pane_shrink(struct layout_cell *lc, enum layout_type type, int needed) { |