version 1.37, 2018/09/24 15:29:56 |
version 1.38, 2018/10/18 08:38:01 |
|
|
|
|
/* Update pane offsets and sizes based on their cells. */ |
/* Update pane offsets and sizes based on their cells. */ |
void |
void |
layout_fix_panes(struct window *w, u_int wsx, u_int wsy) |
layout_fix_panes(struct window *w) |
{ |
{ |
struct window_pane *wp; |
struct window_pane *wp; |
struct layout_cell *lc; |
struct layout_cell *lc; |
u_int sx, sy; |
int shift, status; |
int shift, status, at_top; |
|
|
|
status = options_get_number(w->options, "pane-border-status"); |
status = options_get_number(w->options, "pane-border-status"); |
at_top = (status == 1); |
|
TAILQ_FOREACH(wp, &w->panes, entry) { |
TAILQ_FOREACH(wp, &w->panes, entry) { |
if ((lc = wp->layout_cell) == NULL) |
if ((lc = wp->layout_cell) == NULL) |
continue; |
continue; |
|
|
if (status != 0) |
if (status != 0) |
shift = layout_need_status(lc, at_top); |
shift = layout_need_status(lc, status == 1); |
else |
else |
shift = 0; |
shift = 0; |
|
|
wp->xoff = lc->xoff; |
wp->xoff = lc->xoff; |
wp->yoff = lc->yoff; |
wp->yoff = lc->yoff; |
|
|
if (shift && at_top) |
if (shift && status == 1) |
wp->yoff += 1; |
wp->yoff += 1; |
|
|
/* |
window_pane_resize(wp, lc->sx, lc->sy - shift); |
* Layout cells are limited by the smallest size of other cells |
|
* within the same row or column; if this isn't the case |
|
* resizing becomes difficult. |
|
* |
|
* However, panes do not have to take up their entire cell, so |
|
* they can be cropped to the window edge if the layout |
|
* overflows and they are partly visible. |
|
* |
|
* This stops cells being hidden unnecessarily. |
|
*/ |
|
|
|
/* |
|
* Work out the horizontal size. If the pane is actually |
|
* outside the window or the entire pane is already visible, |
|
* don't crop. |
|
*/ |
|
if (lc->xoff >= wsx || lc->xoff + lc->sx < wsx) |
|
sx = lc->sx; |
|
else { |
|
sx = wsx - lc->xoff; |
|
if (sx < 1) |
|
sx = lc->sx; |
|
} |
|
|
|
/* |
|
* Similarly for the vertical size; the minimum vertical size |
|
* is two because scroll regions cannot be one line. |
|
*/ |
|
if (lc->yoff >= wsy || lc->yoff + lc->sy < wsy) |
|
sy = lc->sy; |
|
else { |
|
sy = wsy - lc->yoff; |
|
if (sy < 2) |
|
sy = lc->sy; |
|
} |
|
|
|
if (shift) |
|
sy -= 1; |
|
|
|
window_pane_resize(wp, sx, sy); |
|
} |
} |
} |
} |
|
|
|
|
lc = w->layout_root = layout_create_cell(NULL); |
lc = w->layout_root = layout_create_cell(NULL); |
layout_set_size(lc, w->sx, w->sy, 0, 0); |
layout_set_size(lc, w->sx, w->sy, 0, 0); |
layout_make_leaf(lc, wp); |
layout_make_leaf(lc, wp); |
|
layout_fix_panes(w); |
layout_fix_panes(w, w->sx, w->sy); |
|
} |
} |
|
|
void |
void |
|
|
|
|
/* Fix cell offsets. */ |
/* Fix cell offsets. */ |
layout_fix_offsets(lc); |
layout_fix_offsets(lc); |
layout_fix_panes(w, sx, sy); |
layout_fix_panes(w); |
} |
} |
|
|
/* Resize a pane to an absolute size. */ |
/* Resize a pane to an absolute size. */ |
|
|
|
|
/* Fix cell offsets. */ |
/* Fix cell offsets. */ |
layout_fix_offsets(w->layout_root); |
layout_fix_offsets(w->layout_root); |
layout_fix_panes(w, w->sx, w->sy); |
layout_fix_panes(w); |
notify_window("window-layout-changed", w); |
notify_window("window-layout-changed", w); |
} |
} |
|
|
|
|
layout_assign_pane(struct layout_cell *lc, struct window_pane *wp) |
layout_assign_pane(struct layout_cell *lc, struct window_pane *wp) |
{ |
{ |
layout_make_leaf(lc, wp); |
layout_make_leaf(lc, wp); |
layout_fix_panes(wp->window, wp->window->sx, wp->window->sy); |
layout_fix_panes(wp->window); |
} |
} |
|
|
/* Calculate the new pane size for resized parent. */ |
/* Calculate the new pane size for resized parent. */ |
|
|
/* Fix pane offsets and sizes. */ |
/* Fix pane offsets and sizes. */ |
if (w->layout_root != NULL) { |
if (w->layout_root != NULL) { |
layout_fix_offsets(w->layout_root); |
layout_fix_offsets(w->layout_root); |
layout_fix_panes(w, w->sx, w->sy); |
layout_fix_panes(w); |
} |
} |
notify_window("window-layout-changed", w); |
notify_window("window-layout-changed", w); |
} |
} |
|
|
do { |
do { |
if (layout_spread_cell(w, parent)) { |
if (layout_spread_cell(w, parent)) { |
layout_fix_offsets(parent); |
layout_fix_offsets(parent); |
layout_fix_panes(w, w->sx, w->sy); |
layout_fix_panes(w); |
break; |
break; |
} |
} |
} while ((parent = parent->parent) != NULL); |
} while ((parent = parent->parent) != NULL); |