/* * If we're decreasing size, recursively search for windows that have no * children, decrease those to fit, then decrease the containing window, etc. */ static int decrease_size(int ToLines, int ToCols, int stolen) { bool found; int depth = 0; WINDOWLIST *wp; T((T_CALLED("decrease_size(%d, %d)"), ToLines, ToCols)); do { found = FALSE; TR(TRACE_UPDATE, ("decreasing size of windows to %dx%d, depth=%d", ToLines, ToCols, depth)); for (wp = _nc_windows; wp != 0; wp = wp->next) { WINDOW *win = &(wp->win); if (!(win->_flags & _ISPAD)) { if (child_depth(win) == depth) { found = TRUE; if (adjust_window(win, ToLines, ToCols, stolen) != OK) returnCode(ERR); } } } ++depth; } while (found); returnCode(OK); }
/* * Return the number of levels of child-windows under the current window. */ static int child_depth(WINDOW *cmp) { int depth = 0; if (cmp != 0) { WINDOWLIST *wp; for (each_window(wp)) { WINDOW *tst = &(wp->win); if (tst->_parent == cmp) { depth = 1 + child_depth(tst); break; } } }
/* * Return the number of levels of child-windows under the current window. */ static int child_depth(WINDOW *cmp) { int depth = 0; if (cmp != 0) { WINDOWLIST *wp; for (wp = _nc_windows; wp != 0; wp = wp->next) { WINDOW *tst = &(wp->win); if (tst->_parent == cmp) { depth = 1 + child_depth(tst); break; } } } return depth; }