=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/layout.c,v retrieving revision 1.1 retrieving revision 1.2 diff -c -r1.1 -r1.2 *** src/usr.bin/tmux/layout.c 2009/06/01 22:58:49 1.1 --- src/usr.bin/tmux/layout.c 2009/07/14 07:23:36 1.2 *************** *** 1,4 **** ! /* $OpenBSD: layout.c,v 1.1 2009/06/01 22:58:49 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: layout.c,v 1.2 2009/07/14 07:23:36 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott *************** *** 125,138 **** layout_active_only_refresh(struct window *w, unused int active_only) { struct window_pane *wp; TAILQ_FOREACH(wp, &w->panes, entry) { ! if (wp == w->active) { ! wp->flags &= ~PANE_HIDDEN; ! wp->xoff = wp->yoff = 0; ! window_pane_resize(wp, w->sx, w->sy); ! } else ! wp->flags |= PANE_HIDDEN; } } --- 125,143 ---- layout_active_only_refresh(struct window *w, unused int active_only) { struct window_pane *wp; + u_int xoff; + xoff = w->sx; TAILQ_FOREACH(wp, &w->panes, entry) { ! /* Put the active pane on screen and the rest to the right. */ ! if (wp == w->active) ! wp->xoff = 0; ! else { ! wp->xoff = xoff; ! xoff += w->sx; ! } ! wp->yoff = 0; ! window_pane_resize(wp, w->sx, w->sy); } } *************** *** 145,150 **** --- 150,161 ---- if (active_only) return; + /* If the screen is too small, show active only. */ + if (w->sx < PANE_MINIMUM || w->sy < PANE_MINIMUM) { + layout_active_only_refresh(w, active_only); + return; + } + /* Get number of panes. */ n = window_count_panes(w); if (n == 0) *************** *** 153,171 **** /* How many can we fit? */ if (w->sx / n < PANE_MINIMUM) { width = PANE_MINIMUM; ! n = w->sx / PANE_MINIMUM; } else width = w->sx / n; /* Fit the panes. */ i = xoff = 0; TAILQ_FOREACH(wp, &w->panes, entry) { - if (i > n) { - wp->flags |= PANE_HIDDEN; - continue; - } - wp->flags &= ~PANE_HIDDEN; - wp->xoff = xoff; wp->yoff = 0; if (i != n - 1) --- 164,176 ---- /* How many can we fit? */ if (w->sx / n < PANE_MINIMUM) { width = PANE_MINIMUM; ! n = UINT_MAX; } else width = w->sx / n; /* Fit the panes. */ i = xoff = 0; TAILQ_FOREACH(wp, &w->panes, entry) { wp->xoff = xoff; wp->yoff = 0; if (i != n - 1) *************** *** 193,198 **** --- 198,209 ---- if (active_only) return; + /* If the screen is too small, show active only. */ + if (w->sx < PANE_MINIMUM || w->sy < PANE_MINIMUM) { + layout_active_only_refresh(w, active_only); + return; + } + /* Get number of panes. */ n = window_count_panes(w); if (n == 0) *************** *** 201,219 **** /* How many can we fit? */ if (w->sy / n < PANE_MINIMUM) { height = PANE_MINIMUM; ! n = w->sy / PANE_MINIMUM; } else height = w->sy / n; /* Fit the panes. */ i = yoff = 0; TAILQ_FOREACH(wp, &w->panes, entry) { - if (i > n) { - wp->flags |= PANE_HIDDEN; - continue; - } - wp->flags &= ~PANE_HIDDEN; - wp->xoff = 0; wp->yoff = yoff; if (i != n - 1) --- 212,224 ---- /* How many can we fit? */ if (w->sy / n < PANE_MINIMUM) { height = PANE_MINIMUM; ! n = UINT_MAX; } else height = w->sy / n; /* Fit the panes. */ i = yoff = 0; TAILQ_FOREACH(wp, &w->panes, entry) { wp->xoff = 0; wp->yoff = yoff; if (i != n - 1) *************** *** 250,256 **** mainwidth = options_get_number(&w->options, "main-pane-width") + 1; /* Need >1 pane and minimum columns; if fewer, display active only. */ ! if (n == 1 || w->sx < mainwidth + PANE_MINIMUM) { layout_active_only_refresh(w, active_only); return; } --- 255,262 ---- mainwidth = options_get_number(&w->options, "main-pane-width") + 1; /* Need >1 pane and minimum columns; if fewer, display active only. */ ! if (n == 1 || ! w->sx < mainwidth + PANE_MINIMUM || w->sy < PANE_MINIMUM) { layout_active_only_refresh(w, active_only); return; } *************** *** 270,285 **** wp->xoff = 0; wp->yoff = 0; window_pane_resize(wp, mainwidth - 1, w->sy); - wp->flags &= ~PANE_HIDDEN; continue; } - if (i > n) { - wp->flags |= PANE_HIDDEN; - continue; - } - wp->flags &= ~PANE_HIDDEN; - wp->xoff = mainwidth; wp->yoff = yoff; if (i != n - 1) --- 276,284 ---- *************** *** 320,326 **** mainheight = options_get_number(&w->options, "main-pane-height") + 1; /* Need >1 pane and minimum rows; if fewer, display active only. */ ! if (n == 1 || w->sy < mainheight + PANE_MINIMUM) { layout_active_only_refresh(w, active_only); return; } --- 319,326 ---- mainheight = options_get_number(&w->options, "main-pane-height") + 1; /* Need >1 pane and minimum rows; if fewer, display active only. */ ! if (n == 1 || ! w->sy < mainheight + PANE_MINIMUM || w->sx < PANE_MINIMUM) { layout_active_only_refresh(w, active_only); return; } *************** *** 340,354 **** wp->xoff = 0; wp->yoff = 0; window_pane_resize(wp, w->sx, mainheight - 1); - wp->flags &= ~PANE_HIDDEN; continue; } - - if (i > n) { - wp->flags |= PANE_HIDDEN; - continue; - } - wp->flags &= ~PANE_HIDDEN; wp->xoff = xoff; wp->yoff = mainheight; --- 340,347 ----