summaryrefslogtreecommitdiffstats
path: root/layout-set.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2009-07-28 06:48:44 +0000
committerNicholas Marriott <nicm@openbsd.org>2009-07-28 06:48:44 +0000
commit2da48644837cd51cfe5a9628140866f06e049e50 (patch)
tree299073ccb81f85b53b47b60324cd1508f8e2621e /layout-set.c
parent309b76fb3255529976ff7ade7e29df8624647312 (diff)
If select-layout is not given an argument, repply the last layout used in the
window, if any.
Diffstat (limited to 'layout-set.c')
-rw-r--r--layout-set.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/layout-set.c b/layout-set.c
index 4433d0cf..8c54a166 100644
--- a/layout-set.c
+++ b/layout-set.c
@@ -74,36 +74,47 @@ layout_set_select(struct window *w, u_int layout)
if (layout_sets[layout].arrange != NULL)
layout_sets[layout].arrange(w);
- w->layout = layout;
+ w->lastlayout = layout;
return (layout);
}
u_int
layout_set_next(struct window *w)
{
- u_int layout = w->layout;
+ u_int layout;
+
+ if (w->lastlayout == -1)
+ layout = 0;
+ else {
+ layout = w->lastlayout + 1;
+ if (layout > nitems(layout_sets) - 1)
+ layout = 0;
+ }
if (layout_sets[layout].arrange != NULL)
layout_sets[layout].arrange(w);
-
- w->layout++;
- if (w->layout > nitems(layout_sets) - 1)
- w->layout = 0;
+ w->lastlayout = layout;
return (layout);
}
u_int
layout_set_previous(struct window *w)
{
- u_int layout = w->layout;
+ u_int layout;
+
+ if (w->lastlayout == -1)
+ layout = nitems(layout_sets) - 1;
+ else {
+ layout = w->lastlayout;
+ if (layout == 0)
+ layout = nitems(layout_sets) - 1;
+ else
+ layout--;
+ }
if (layout_sets[layout].arrange != NULL)
layout_sets[layout].arrange(w);
-
- if (w->layout == 0)
- w->layout = nitems(layout_sets) - 1;
- else
- w->layout--;
+ w->lastlayout = layout;
return (layout);
}