summaryrefslogtreecommitdiffstats
path: root/layout.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2009-07-14 07:23:36 +0000
committerNicholas Marriott <nicm@openbsd.org>2009-07-14 07:23:36 +0000
commitfe20c0d89ef5b8581c28067496f0f4c545d55ef8 (patch)
treee3283e2030d865de1025215bb8527636c78966b8 /layout.c
parent4a9b01eb0d328f13a03f967759bfd76d749da17f (diff)
Get rid of the PANE_HIDDEN flag in favour of a function, and moving the
decision for whether or not a pane should be drawn out of the layout code and into the redraw code. This is needed for the new layout design, getting it in now to make that easier to work on.
Diffstat (limited to 'layout.c')
-rw-r--r--layout.c65
1 files changed, 29 insertions, 36 deletions
diff --git a/layout.c b/layout.c
index 1ae946e5..66cf7af2 100644
--- a/layout.c
+++ b/layout.c
@@ -125,14 +125,19 @@ void
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) {
- 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;
+ /* 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,6 +150,12 @@ layout_even_h_refresh(struct window *w, int active_only)
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,19 +164,13 @@ layout_even_h_refresh(struct window *w, int active_only)
/* How many can we fit? */
if (w->sx / n < PANE_MINIMUM) {
width = PANE_MINIMUM;
- n = w->sx / PANE_MINIMUM;
+ n = UINT_MAX;
} 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)
@@ -193,6 +198,12 @@ layout_even_v_refresh(struct window *w, int active_only)
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,19 +212,13 @@ layout_even_v_refresh(struct window *w, int active_only)
/* How many can we fit? */
if (w->sy / n < PANE_MINIMUM) {
height = PANE_MINIMUM;
- n = w->sy / PANE_MINIMUM;
+ n = UINT_MAX;
} 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)
@@ -250,7 +255,8 @@ layout_main_v_refresh(struct window *w, int active_only)
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) {
+ if (n == 1 ||
+ w->sx < mainwidth + PANE_MINIMUM || w->sy < PANE_MINIMUM) {
layout_active_only_refresh(w, active_only);
return;
}
@@ -270,16 +276,9 @@ layout_main_v_refresh(struct window *w, int active_only)
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)
@@ -320,7 +319,8 @@ layout_main_h_refresh(struct window *w, int active_only)
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) {
+ if (n == 1 ||
+ w->sy < mainheight + PANE_MINIMUM || w->sx < PANE_MINIMUM) {
layout_active_only_refresh(w, active_only);
return;
}
@@ -340,15 +340,8 @@ layout_main_h_refresh(struct window *w, int active_only)
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;