summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cmd-break-pane.c4
-rw-r--r--cmd-join-pane.c2
-rw-r--r--cmd-kill-pane.c1
-rw-r--r--cmd-resize-pane.c21
-rw-r--r--cmd-respawn-window.c2
-rw-r--r--cmd-select-layout.c1
-rw-r--r--cmd-select-pane.c2
-rw-r--r--cmd-split-window.c1
-rw-r--r--cmd-swap-pane.c2
-rw-r--r--input-keys.c3
-rw-r--r--key-bindings.c1
-rw-r--r--layout.c4
-rw-r--r--resize.c8
-rw-r--r--server-client.c1
-rw-r--r--server-fn.c9
-rw-r--r--window.c56
16 files changed, 108 insertions, 10 deletions
diff --git a/cmd-break-pane.c b/cmd-break-pane.c
index 27ae1624..bac332a2 100644
--- a/cmd-break-pane.c
+++ b/cmd-break-pane.c
@@ -63,6 +63,8 @@ cmd_break_pane_exec(struct cmd *self, struct cmd_q *cmdq)
}
w = wl->window;
+ server_unzoom_window(w);
+
TAILQ_REMOVE(&w->panes, wp, entry);
if (wp == w->active) {
w->active = w->last;
@@ -82,7 +84,7 @@ cmd_break_pane_exec(struct cmd *self, struct cmd_q *cmdq)
name = default_window_name(w);
window_set_name(w, name);
free(name);
- layout_init(w);
+ layout_init(w, wp);
base_idx = options_get_number(&s->options, "base-index");
wl = session_attach(s, w, -1 - base_idx, &cause); /* can't fail */
diff --git a/cmd-join-pane.c b/cmd-join-pane.c
index 2e7a59cd..cf17e7d9 100644
--- a/cmd-join-pane.c
+++ b/cmd-join-pane.c
@@ -92,11 +92,13 @@ join_pane(struct cmd *self, struct cmd_q *cmdq, int not_same_window)
return (CMD_RETURN_ERROR);
dst_w = dst_wl->window;
dst_idx = dst_wl->idx;
+ server_unzoom_window(dst_w);
src_wl = cmd_find_pane(cmdq, args_get(args, 's'), NULL, &src_wp);
if (src_wl == NULL)
return (CMD_RETURN_ERROR);
src_w = src_wl->window;
+ server_unzoom_window(src_w);
if (not_same_window && src_w == dst_w) {
cmdq_error(cmdq, "can't join a pane to its own window");
diff --git a/cmd-kill-pane.c b/cmd-kill-pane.c
index 1aa776d9..ba3bfd20 100644
--- a/cmd-kill-pane.c
+++ b/cmd-kill-pane.c
@@ -47,6 +47,7 @@ cmd_kill_pane_exec(struct cmd *self, struct cmd_q *cmdq)
if ((wl = cmd_find_pane(cmdq, args_get(args, 't'), NULL, &wp)) == NULL)
return (CMD_RETURN_ERROR);
+ server_unzoom_window(wl->window);
if (window_count_panes(wl->window) == 1) {
/* Only one pane, kill the window. */
diff --git a/cmd-resize-pane.c b/cmd-resize-pane.c
index f31e3258..41c15269 100644
--- a/cmd-resize-pane.c
+++ b/cmd-resize-pane.c
@@ -31,8 +31,8 @@ enum cmd_retval cmd_resize_pane_exec(struct cmd *, struct cmd_q *);
const struct cmd_entry cmd_resize_pane_entry = {
"resize-pane", "resizep",
- "DLRt:Ux:y:", 0, 1,
- "[-DLRU] [-x width] [-y height] " CMD_TARGET_PANE_USAGE " [adjustment]",
+ "DLRt:Ux:y:Z", 0, 1,
+ "[-DLRUZ] [-x width] [-y height] " CMD_TARGET_PANE_USAGE " [adjustment]",
0,
cmd_resize_pane_key_binding,
NULL,
@@ -75,6 +75,10 @@ cmd_resize_pane_key_binding(struct cmd *self, int key)
self->args = args_create(1, "5");
args_set(self->args, 'R', NULL);
break;
+ case 'z':
+ self->args = args_create(0);
+ args_set(self->args, 'Z', NULL);
+ break;
default:
self->args = args_create(0);
break;
@@ -86,6 +90,7 @@ cmd_resize_pane_exec(struct cmd *self, struct cmd_q *cmdq)
{
struct args *args = self->args;
struct winlink *wl;
+ struct window *w;
const char *errstr;
char *cause;
struct window_pane *wp;
@@ -94,6 +99,18 @@ cmd_resize_pane_exec(struct cmd *self, struct cmd_q *cmdq)
if ((wl = cmd_find_pane(cmdq, args_get(args, 't'), NULL, &wp)) == NULL)
return (CMD_RETURN_ERROR);
+ w = wl->window;
+
+ if (args_has(args, 'Z')) {
+ if (w->flags & WINDOW_ZOOMED)
+ window_unzoom(w);
+ else
+ window_zoom(wp);
+ server_redraw_window(w);
+ server_status_window(w);
+ return (CMD_RETURN_NORMAL);
+ }
+ server_unzoom_window(w);
if (args->argc == 0)
adjust = 1;
diff --git a/cmd-respawn-window.c b/cmd-respawn-window.c
index 646882b0..a446794b 100644
--- a/cmd-respawn-window.c
+++ b/cmd-respawn-window.c
@@ -87,7 +87,7 @@ cmd_respawn_window_exec(struct cmd *self, struct cmd_q *cmdq)
server_destroy_pane(wp);
return (CMD_RETURN_ERROR);
}
- layout_init(w);
+ layout_init(w, wp);
window_pane_reset_mode(wp);
screen_reinit(&wp->base);
input_init(wp);
diff --git a/cmd-select-layout.c b/cmd-select-layout.c
index 4b01a69d..aa73e500 100644
--- a/cmd-select-layout.c
+++ b/cmd-select-layout.c
@@ -92,6 +92,7 @@ cmd_select_layout_exec(struct cmd *self, struct cmd_q *cmdq)
if ((wl = cmd_find_window(cmdq, args_get(args, 't'), NULL)) == NULL)
return (CMD_RETURN_ERROR);
+ server_unzoom_window(wl->window);
next = self->entry == &cmd_next_layout_entry;
if (args_has(self->args, 'n'))
diff --git a/cmd-select-pane.c b/cmd-select-pane.c
index 459e98cf..77be368f 100644
--- a/cmd-select-pane.c
+++ b/cmd-select-pane.c
@@ -80,6 +80,7 @@ cmd_select_pane_exec(struct cmd *self, struct cmd_q *cmdq)
return (CMD_RETURN_ERROR);
}
+ server_unzoom_window(wl->window);
window_set_active_pane(wl->window, wl->window->last);
server_status_window(wl->window);
server_redraw_window_borders(wl->window);
@@ -90,6 +91,7 @@ cmd_select_pane_exec(struct cmd *self, struct cmd_q *cmdq)
if ((wl = cmd_find_pane(cmdq, args_get(args, 't'), NULL, &wp)) == NULL)
return (CMD_RETURN_ERROR);
+ server_unzoom_window(wp->window);
if (!window_pane_visible(wp)) {
cmdq_error(cmdq, "pane not visible");
return (CMD_RETURN_ERROR);
diff --git a/cmd-split-window.c b/cmd-split-window.c
index 87c0e6bc..e3d6f6ea 100644
--- a/cmd-split-window.c
+++ b/cmd-split-window.c
@@ -73,6 +73,7 @@ cmd_split_window_exec(struct cmd *self, struct cmd_q *cmdq)
if ((wl = cmd_find_pane(cmdq, args_get(args, 't'), &s, &wp)) == NULL)
return (CMD_RETURN_ERROR);
w = wl->window;
+ server_unzoom_window(w);
environ_init(&env);
environ_copy(&global_environ, &env);
diff --git a/cmd-swap-pane.c b/cmd-swap-pane.c
index ae875946..e7ea6242 100644
--- a/cmd-swap-pane.c
+++ b/cmd-swap-pane.c
@@ -63,6 +63,7 @@ cmd_swap_pane_exec(struct cmd *self, struct cmd_q *cmdq)
if (dst_wl == NULL)
return (CMD_RETURN_ERROR);
dst_w = dst_wl->window;
+ server_unzoom_window(dst_w);
if (!args_has(args, 's')) {
src_w = dst_w;
@@ -82,6 +83,7 @@ cmd_swap_pane_exec(struct cmd *self, struct cmd_q *cmdq)
return (CMD_RETURN_ERROR);
src_w = src_wl->window;
}
+ server_unzoom_window(src_w);
if (src_wp == dst_wp)
return (CMD_RETURN_NORMAL);
diff --git a/input-keys.c b/input-keys.c
index 23549e32..d7e8513d 100644
--- a/input-keys.c
+++ b/input-keys.c
@@ -219,7 +219,8 @@ input_mouse(struct window_pane *wp, struct session *s, struct mouse_event *m)
*/
if (m->sgr && (wp->screen->mode & MODE_MOUSE_SGR)) {
len = xsnprintf(buf, sizeof buf, "\033[<%d;%d;%d%c",
- m->sgr_xb, m->x + 1, m->y + 1, m->sgr_rel ? 'm' : 'M');
+ m->sgr_xb, m->x + 1, m->y + 1,
+ m->sgr_rel ? 'm' : 'M');
} else if (wp->screen->mode & MODE_MOUSE_UTF8) {
len = xsnprintf(buf, sizeof buf, "\033[M");
len += utf8_split2(m->xb + 32, &buf[len]);
diff --git a/key-bindings.c b/key-bindings.c
index 4e889b7e..625ffddf 100644
--- a/key-bindings.c
+++ b/key-bindings.c
@@ -150,6 +150,7 @@ key_bindings_init(void)
{ 't', 0, &cmd_clock_mode_entry },
{ 'w', 0, &cmd_choose_window_entry },
{ 'x', 0, &cmd_confirm_before_entry },
+ { 'z', 0, &cmd_resize_pane_entry },
{ '{', 0, &cmd_swap_pane_entry },
{ '}', 0, &cmd_swap_pane_entry },
{ '~', 0, &cmd_show_messages_entry },
diff --git a/layout.c b/layout.c
index f08580b7..4dd3756c 100644
--- a/layout.c
+++ b/layout.c
@@ -374,13 +374,13 @@ layout_destroy_cell(struct layout_cell *lc, struct layout_cell **lcroot)
}
void
-layout_init(struct window *w)
+layout_init(struct window *w, struct window_pane *wp)
{
struct layout_cell *lc;
lc = w->layout_root = layout_create_cell(NULL);
layout_set_size(lc, w->sx, w->sy, 0, 0);
- layout_make_leaf(lc, TAILQ_FIRST(&w->panes));
+ layout_make_leaf(lc, wp);
layout_fix_panes(w, w->sx, w->sy);
}
diff --git a/resize.c b/resize.c
index d398ab37..b5196c1c 100644
--- a/resize.c
+++ b/resize.c
@@ -50,7 +50,7 @@ recalculate_sizes(void)
struct window *w;
struct window_pane *wp;
u_int i, j, ssx, ssy, has, limit;
- int flag, has_status;
+ int flag, has_status, is_zoomed;
RB_FOREACH(s, sessions, &sessions) {
has_status = options_get_number(&s->options, "status");
@@ -123,12 +123,16 @@ recalculate_sizes(void)
if (w->sx == ssx && w->sy == ssy)
continue;
-
log_debug("window size %u,%u (was %u,%u)", ssx, ssy, w->sx,
w->sy);
+ is_zoomed = w->flags & WINDOW_ZOOMED;
+ if (is_zoomed)
+ window_unzoom(w);
layout_resize(w, ssx, ssy);
window_resize(w, ssx, ssy);
+ if (is_zoomed && window_pane_visible(w->active))
+ window_zoom(w->active);
/*
* If the current pane is now not visible, move to the next
diff --git a/server-client.c b/server-client.c
index 6f29000b..64af442a 100644
--- a/server-client.c
+++ b/server-client.c
@@ -384,6 +384,7 @@ server_client_handle_key(struct client *c, int key)
if (c->flags & CLIENT_IDENTIFY && key >= '0' && key <= '9') {
if (c->flags & CLIENT_READONLY)
return;
+ window_unzoom(w);
wp = window_pane_at_index(w, key - '0');
if (wp != NULL && window_pane_visible(wp))
window_set_active_pane(w, wp);
diff --git a/server-fn.c b/server-fn.c
index b9217ef2..874afffb 100644
--- a/server-fn.c
+++ b/server-fn.c
@@ -377,6 +377,7 @@ server_destroy_pane(struct window_pane *wp)
return;
}
+ server_unzoom_window(w);
layout_close_pane(wp);
window_remove_pane(w, wp);
@@ -588,3 +589,11 @@ server_set_stdin_callback(struct client *c, void (*cb)(struct client *, int,
return (0);
}
+
+void
+server_unzoom_window(struct window *w)
+{
+ window_unzoom(w);
+ server_redraw_window(w);
+ server_status_window(w);
+}
diff --git a/window.c b/window.c
index dfece2ee..38af88f9 100644
--- a/window.c
+++ b/window.c
@@ -319,7 +319,7 @@ window_create(const char *name, const char *cmd, const char *shell,
w = window_create1(sx, sy);
wp = window_add_pane(w, hlimit);
- layout_init(w);
+ layout_init(w, wp);
if (*cmd != '\0') {
prefix = options_get_string(&w->options, "command-prefix");
@@ -348,6 +348,8 @@ window_destroy(struct window *w)
{
u_int i;
+ window_unzoom(w);
+
if (window_index(w, &i) != 0)
fatalx("index not found");
ARRAY_SET(&windows, i, NULL);
@@ -470,6 +472,54 @@ window_find_string(struct window *w, const char *s)
return (window_get_active_at(w, x, y));
}
+int
+window_zoom(struct window_pane *wp)
+{
+ struct window *w = wp->window;
+ struct window_pane *wp1;
+
+ if (w->flags & WINDOW_ZOOMED)
+ return (-1);
+
+ if (!window_pane_visible(wp))
+ return (-1);
+ if (w->active != wp)
+ window_set_active_pane(w, wp);
+
+ TAILQ_FOREACH(wp1, &w->panes, entry) {
+ wp1->saved_layout_cell = wp1->layout_cell;
+ wp1->layout_cell = NULL;
+ }
+
+ w->saved_layout_root = w->layout_root;
+ layout_init(w, wp);
+ w->flags |= WINDOW_ZOOMED;
+
+ return (0);
+}
+
+int
+window_unzoom(struct window *w)
+{
+ struct window_pane *wp, *wp1;
+
+ if (!(w->flags & WINDOW_ZOOMED))
+ return (-1);
+ wp = w->active;
+
+ w->flags &= ~WINDOW_ZOOMED;
+ layout_free(w);
+ w->layout_root = w->saved_layout_root;
+
+ TAILQ_FOREACH(wp1, &w->panes, entry) {
+ wp1->layout_cell = wp1->saved_layout_cell;
+ wp1->saved_layout_cell = NULL;
+ }
+ layout_fix_panes(w, w->sx, w->sy);
+
+ return (0);
+}
+
struct window_pane *
window_add_pane(struct window *w, u_int hlimit)
{
@@ -600,6 +650,8 @@ window_printable_flags(struct session *s, struct winlink *wl)
flags[pos++] = '*';
if (wl == TAILQ_FIRST(&s->lastw))
flags[pos++] = '-';
+ if (wl->window->flags & WINDOW_ZOOMED)
+ flags[pos++] = 'Z';
if (pos == 0)
flags[pos++] = ' ';
flags[pos] = '\0';
@@ -1027,6 +1079,8 @@ window_pane_visible(struct window_pane *wp)
{
struct window *w = wp->window;
+ if (wp->layout_cell == NULL)
+ return (0);
if (wp->xoff >= w->sx || wp->yoff >= w->sy)
return (0);
if (wp->xoff + wp->sx > w->sx || wp->yoff + wp->sy > w->sy)