summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2019-07-15 18:25:08 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2019-07-15 18:25:08 +0000
commit8cadae2d543cf2a7b3c348dc21f7397603f0f06b (patch)
tree0abf61d422f17a885a5f859b2d6f6130857c6ffb /usr.bin
parent76c8119a63f9ba02d011999c12095c2583a098c6 (diff)
Make layout_fix_offsets take a window like layout_fix_panes.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tmux/layout-custom.c4
-rw-r--r--usr.bin/tmux/layout-set.c10
-rw-r--r--usr.bin/tmux/layout.c32
-rw-r--r--usr.bin/tmux/tmux.h4
4 files changed, 31 insertions, 19 deletions
diff --git a/usr.bin/tmux/layout-custom.c b/usr.bin/tmux/layout-custom.c
index 4505f050248..4d6bd34c23d 100644
--- a/usr.bin/tmux/layout-custom.c
+++ b/usr.bin/tmux/layout-custom.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: layout-custom.c,v 1.14 2019/06/15 06:33:48 nicm Exp $ */
+/* $OpenBSD: layout-custom.c,v 1.15 2019/07/15 18:25:07 nicm Exp $ */
/*
* Copyright (c) 2010 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -165,7 +165,7 @@ layout_parse(struct window *w, const char *layout)
layout_assign(&wp, lc);
/* Update pane offsets and sizes. */
- layout_fix_offsets(lc);
+ layout_fix_offsets(w);
layout_fix_panes(w);
recalculate_sizes();
diff --git a/usr.bin/tmux/layout-set.c b/usr.bin/tmux/layout-set.c
index 5382b5f75ca..b66f530b481 100644
--- a/usr.bin/tmux/layout-set.c
+++ b/usr.bin/tmux/layout-set.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: layout-set.c,v 1.26 2019/05/14 07:37:50 nicm Exp $ */
+/* $OpenBSD: layout-set.c,v 1.27 2019/07/15 18:25:07 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -158,7 +158,7 @@ layout_set_even(struct window *w, enum layout_type type)
layout_spread_cell(w, lc);
/* Fix cell offsets. */
- layout_fix_offsets(lc);
+ layout_fix_offsets(w);
layout_fix_panes(w);
layout_print_cell(w->layout_root, __func__, 1);
@@ -257,7 +257,7 @@ layout_set_main_h(struct window *w)
}
/* Fix cell offsets. */
- layout_fix_offsets(lc);
+ layout_fix_offsets(w);
layout_fix_panes(w);
layout_print_cell(w->layout_root, __func__, 1);
@@ -344,7 +344,7 @@ layout_set_main_v(struct window *w)
}
/* Fix cell offsets. */
- layout_fix_offsets(lc);
+ layout_fix_offsets(w);
layout_fix_panes(w);
layout_print_cell(w->layout_root, __func__, 1);
@@ -453,7 +453,7 @@ layout_set_tiled(struct window *w)
}
/* Fix cell offsets. */
- layout_fix_offsets(lc);
+ layout_fix_offsets(w);
layout_fix_panes(w);
layout_print_cell(w->layout_root, __func__, 1);
diff --git a/usr.bin/tmux/layout.c b/usr.bin/tmux/layout.c
index fc1c8ea4c44..c548b276b8d 100644
--- a/usr.bin/tmux/layout.c
+++ b/usr.bin/tmux/layout.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: layout.c,v 1.45 2019/06/26 18:44:22 nicm Exp $ */
+/* $OpenBSD: layout.c,v 1.46 2019/07/15 18:25:07 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -200,8 +200,8 @@ layout_make_node(struct layout_cell *lc, enum layout_type type)
}
/* Fix cell offsets based on their sizes. */
-void
-layout_fix_offsets(struct layout_cell *lc)
+static void
+layout_fix_offsets1(struct layout_cell *lc)
{
struct layout_cell *lcchild;
u_int xoff, yoff;
@@ -212,7 +212,7 @@ layout_fix_offsets(struct layout_cell *lc)
lcchild->xoff = xoff;
lcchild->yoff = lc->yoff;
if (lcchild->type != LAYOUT_WINDOWPANE)
- layout_fix_offsets(lcchild);
+ layout_fix_offsets1(lcchild);
xoff += lcchild->sx + 1;
}
} else {
@@ -221,12 +221,24 @@ layout_fix_offsets(struct layout_cell *lc)
lcchild->xoff = lc->xoff;
lcchild->yoff = yoff;
if (lcchild->type != LAYOUT_WINDOWPANE)
- layout_fix_offsets(lcchild);
+ layout_fix_offsets1(lcchild);
yoff += lcchild->sy + 1;
}
}
}
+/* Update cell offsets based on their sizes. */
+void
+layout_fix_offsets(struct window *w)
+{
+ struct layout_cell *lc = w->layout_root;
+
+ lc->xoff = 0;
+ lc->yoff = 0;
+
+ layout_fix_offsets1(lc);
+}
+
/*
* Returns 1 if we need to reserve space for the pane status line. This is the
* case for the most upper panes only.
@@ -507,7 +519,7 @@ layout_resize(struct window *w, u_int sx, u_int sy)
layout_resize_adjust(w, lc, LAYOUT_TOPBOTTOM, ychange);
/* Fix cell offsets. */
- layout_fix_offsets(lc);
+ layout_fix_offsets(w);
layout_fix_panes(w);
}
@@ -567,7 +579,7 @@ layout_resize_layout(struct window *w, struct layout_cell *lc,
}
/* Fix cell offsets. */
- layout_fix_offsets(w->layout_root);
+ layout_fix_offsets(w);
layout_fix_panes(w);
notify_window("window-layout-changed", w);
}
@@ -988,7 +1000,7 @@ layout_split_pane(struct window_pane *wp, enum layout_type type, int size,
if (full_size) {
if (!resize_first)
layout_resize_child_cells(wp->window, lc);
- layout_fix_offsets(wp->window->layout_root);
+ layout_fix_offsets(wp->window);
} else
layout_make_leaf(lc, wp);
@@ -1006,7 +1018,7 @@ layout_close_pane(struct window_pane *wp)
/* Fix pane offsets and sizes. */
if (w->layout_root != NULL) {
- layout_fix_offsets(w->layout_root);
+ layout_fix_offsets(w);
layout_fix_panes(w);
}
notify_window("window-layout-changed", w);
@@ -1073,7 +1085,7 @@ layout_spread_out(struct window_pane *wp)
do {
if (layout_spread_cell(w, parent)) {
- layout_fix_offsets(parent);
+ layout_fix_offsets(w);
layout_fix_panes(w);
break;
}
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index 168068abec0..ad54c910c2e 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.921 2019/07/10 11:20:10 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.922 2019/07/15 18:25:07 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -2438,7 +2438,7 @@ void layout_set_size(struct layout_cell *, u_int, u_int, u_int,
u_int);
void layout_make_leaf(struct layout_cell *, struct window_pane *);
void layout_make_node(struct layout_cell *, enum layout_type);
-void layout_fix_offsets(struct layout_cell *);
+void layout_fix_offsets(struct window *);
void layout_fix_panes(struct window *);
void layout_resize_adjust(struct window *, struct layout_cell *,
enum layout_type, int);