summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2019-04-17 14:43:49 +0000
committernicm <nicm@openbsd.org>2019-04-17 14:43:49 +0000
commitd4ddf7e1665cc214d55aeaa38156b8cf76b4c8bf (patch)
tree2def0da642d75e0b90b3e329f5428d7f07c9573c
parentDo not let the size of the pane status screen go negative. (diff)
downloadwireguard-openbsd-d4ddf7e1665cc214d55aeaa38156b8cf76b4c8bf.tar.xz
wireguard-openbsd-d4ddf7e1665cc214d55aeaa38156b8cf76b4c8bf.zip
Set the window size as well as the layout size when using the preset
layouts.
-rw-r--r--usr.bin/tmux/cmd-select-layout.c3
-rw-r--r--usr.bin/tmux/layout-set.c31
-rw-r--r--usr.bin/tmux/layout.c6
-rw-r--r--usr.bin/tmux/resize.c4
-rw-r--r--usr.bin/tmux/tty.c5
5 files changed, 36 insertions, 13 deletions
diff --git a/usr.bin/tmux/cmd-select-layout.c b/usr.bin/tmux/cmd-select-layout.c
index bc914123a8f..3c33c25af95 100644
--- a/usr.bin/tmux/cmd-select-layout.c
+++ b/usr.bin/tmux/cmd-select-layout.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-select-layout.c,v 1.35 2018/07/02 12:39:14 nicm Exp $ */
+/* $OpenBSD: cmd-select-layout.c,v 1.36 2019/04/17 14:43:49 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -135,6 +135,7 @@ cmd_select_layout_exec(struct cmd *self, struct cmdq_item *item)
changed:
free(oldlayout);
+ recalculate_sizes();
server_redraw_window(w);
notify_window("window-layout-changed", w);
return (CMD_RETURN_NORMAL);
diff --git a/usr.bin/tmux/layout-set.c b/usr.bin/tmux/layout-set.c
index fcf33708eaa..e203ed7f279 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.22 2019/04/04 10:25:35 nicm Exp $ */
+/* $OpenBSD: layout-set.c,v 1.23 2019/04/17 14:43:49 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -119,7 +119,7 @@ layout_set_even(struct window *w, enum layout_type type)
{
struct window_pane *wp;
struct layout_cell *lc, *lcnew;
- u_int n;
+ u_int n, sx, sy;
layout_print_cell(w->layout_root, __func__, 1);
@@ -131,7 +131,18 @@ layout_set_even(struct window *w, enum layout_type type)
/* Free the old root and construct a new. */
layout_free(w);
lc = w->layout_root = layout_create_cell(NULL);
- layout_set_size(lc, w->sx, w->sy, 0, 0);
+ if (type == LAYOUT_LEFTRIGHT) {
+ sx = (n * (PANE_MINIMUM + 1)) - 1;
+ if (sx < w->sx)
+ sx = w->sx;
+ sy = w->sy;
+ } else {
+ sy = (n * (PANE_MINIMUM + 1)) - 1;
+ if (sy < w->sy)
+ sy = w->sy;
+ sx = w->sx;
+ }
+ layout_set_size(lc, sx, sy, 0, 0);
layout_make_node(lc, type);
/* Build new leaf cells. */
@@ -152,6 +163,7 @@ layout_set_even(struct window *w, enum layout_type type)
layout_print_cell(w->layout_root, __func__, 1);
+ window_resize(w, lc->sx, lc->sy);
notify_window("window-layout-changed", w);
server_redraw_window(w);
}
@@ -288,6 +300,7 @@ layout_set_main_h(struct window *w)
layout_print_cell(w->layout_root, __func__, 1);
+ window_resize(w, lc->sx, lc->sy);
notify_window("window-layout-changed", w);
server_redraw_window(w);
}
@@ -412,6 +425,7 @@ layout_set_main_v(struct window *w)
layout_print_cell(w->layout_root, __func__, 1);
+ window_resize(w, lc->sx, lc->sy);
notify_window("window-layout-changed", w);
server_redraw_window(w);
}
@@ -421,7 +435,7 @@ layout_set_tiled(struct window *w)
{
struct window_pane *wp;
struct layout_cell *lc, *lcrow, *lcchild;
- u_int n, width, height, used;
+ u_int n, width, height, used, sx, sy;
u_int i, j, columns, rows;
layout_print_cell(w->layout_root, __func__, 1);
@@ -450,7 +464,13 @@ layout_set_tiled(struct window *w)
/* Free old tree and create a new root. */
layout_free(w);
lc = w->layout_root = layout_create_cell(NULL);
- layout_set_size(lc, w->sx, w->sy, 0, 0);
+ sx = ((width + 1) * columns) - 1;
+ if (sx < w->sx)
+ sx = w->sx;
+ sy = ((height + 1) * rows) - 1;
+ if (sy < w->sy)
+ sy = w->sy;
+ layout_set_size(lc, sx, sy, 0, 0);
layout_make_node(lc, LAYOUT_TOPBOTTOM);
/* Create a grid of the cells. */
@@ -514,6 +534,7 @@ layout_set_tiled(struct window *w)
layout_print_cell(w->layout_root, __func__, 1);
+ window_resize(w, lc->sx, lc->sy);
notify_window("window-layout-changed", w);
server_redraw_window(w);
}
diff --git a/usr.bin/tmux/layout.c b/usr.bin/tmux/layout.c
index 2cf22b4e937..798ad29389f 100644
--- a/usr.bin/tmux/layout.c
+++ b/usr.bin/tmux/layout.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: layout.c,v 1.40 2019/04/17 14:37:48 nicm Exp $ */
+/* $OpenBSD: layout.c,v 1.41 2019/04/17 14:43:49 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -479,7 +479,7 @@ layout_resize(struct window *w, u_int sx, u_int sy)
* out proportionately - this should leave the layout fitting the new
* window size.
*/
- xchange = sx - w->sx;
+ xchange = sx - lc->sx;
xlimit = layout_resize_check(w, lc, LAYOUT_LEFTRIGHT);
if (xchange < 0 && xchange < -xlimit)
xchange = -xlimit;
@@ -493,7 +493,7 @@ layout_resize(struct window *w, u_int sx, u_int sy)
layout_resize_adjust(w, lc, LAYOUT_LEFTRIGHT, xchange);
/* Adjust vertically in a similar fashion. */
- ychange = sy - w->sy;
+ ychange = sy - lc->sy;
ylimit = layout_resize_check(w, lc, LAYOUT_TOPBOTTOM);
if (ychange < 0 && ychange < -ylimit)
ychange = -ylimit;
diff --git a/usr.bin/tmux/resize.c b/usr.bin/tmux/resize.c
index 74749147f69..d3411b23153 100644
--- a/usr.bin/tmux/resize.c
+++ b/usr.bin/tmux/resize.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: resize.c,v 1.30 2019/03/16 17:14:07 nicm Exp $ */
+/* $OpenBSD: resize.c,v 1.31 2019/04/17 14:43:49 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -51,6 +51,8 @@ resize_window(struct window *w, u_int sx, u_int sy)
if (sy < w->layout_root->sy)
sy = w->layout_root->sy;
window_resize(w, sx, sy);
+ log_debug("%s: @%u resized to %u,%u; layout %u,%u", __func__, w->id,
+ sx, sy, w->layout_root->sx, w->layout_root->sy);
/* Restore the window zoom state. */
if (zoomed)
diff --git a/usr.bin/tmux/tty.c b/usr.bin/tmux/tty.c
index 90e73dfae7f..fbf706cd6c2 100644
--- a/usr.bin/tmux/tty.c
+++ b/usr.bin/tmux/tty.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty.c,v 1.319 2019/03/14 17:58:52 nicm Exp $ */
+/* $OpenBSD: tty.c,v 1.320 2019/04/17 14:43:49 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -907,9 +907,8 @@ tty_is_visible(struct tty *tty, const struct tty_ctx *ctx, u_int px, u_int py,
lines = 0;
if (xoff + nx <= ctx->ox || xoff >= ctx->ox + ctx->sx ||
- yoff + ny <= ctx->oy || yoff >= lines + ctx->oy + ctx->sy) {
+ yoff + ny <= ctx->oy || yoff >= lines + ctx->oy + ctx->sy)
return (0);
- }
return (1);
}