From 8d59b189cc9e83ac0049fc3108de1b822fa7b4ce Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Fri, 22 Mar 2013 10:31:22 +0000 Subject: No more lint means no more ARGSUSED. --- window.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'window.c') diff --git a/window.c b/window.c index 20cd9aa3..79ade400 100644 --- a/window.c +++ b/window.c @@ -802,7 +802,6 @@ window_pane_timer_callback(unused int fd, unused short events, void *data) wp->changes = 0; } -/* ARGSUSED */ void window_pane_read_callback(unused struct bufferevent *bufev, void *data) { @@ -829,7 +828,6 @@ window_pane_read_callback(unused struct bufferevent *bufev, void *data) fatal("gettimeofday failed."); } -/* ARGSUSED */ void window_pane_error_callback( unused struct bufferevent *bufev, unused short what, void *data) -- cgit From 3eae71b5b28cf591f6cff652e2f2c67be394c040 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Sun, 24 Mar 2013 09:25:04 +0000 Subject: Do pane resize ioctls once at the end of the server loop rather than immediately. --- window.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'window.c') diff --git a/window.c b/window.c index 79ade400..dfece2ee 100644 --- a/window.c +++ b/window.c @@ -310,24 +310,36 @@ window_create1(u_int sx, u_int sy) struct window * window_create(const char *name, const char *cmd, const char *shell, const char *cwd, struct environ *env, struct termios *tio, - u_int sx, u_int sy, u_int hlimit,char **cause) + u_int sx, u_int sy, u_int hlimit, char **cause) { struct window *w; struct window_pane *wp; + const char *prefix; + char *cmd1; w = window_create1(sx, sy); wp = window_add_pane(w, hlimit); layout_init(w); - if (window_pane_spawn(wp, cmd, shell, cwd, env, tio, cause) != 0) { + + if (*cmd != '\0') { + prefix = options_get_string(&w->options, "command-prefix"); + xasprintf(&cmd1, "%s%s", prefix, cmd); + } else + cmd1 = xstrdup(""); + if (window_pane_spawn(wp, cmd1, shell, cwd, env, tio, cause) != 0) { window_destroy(w); + free(cmd1); return (NULL); } + free(cmd1); + w->active = TAILQ_FIRST(&w->panes); if (name != NULL) { w->name = xstrdup(name); options_set_number(&w->options, "automatic-rename", 0); } else w->name = default_window_name(w); + return (w); } @@ -704,6 +716,8 @@ window_pane_spawn(struct window_pane *wp, const char *cmd, const char *shell, wp->cwd = xstrdup(cwd); } + log_debug("spawn: %s -- %s", wp->shell, wp->cmd); + memset(&ws, 0, sizeof ws); ws.ws_col = screen_size_x(&wp->base); ws.ws_row = screen_size_y(&wp->base); @@ -840,23 +854,14 @@ window_pane_error_callback( void window_pane_resize(struct window_pane *wp, u_int sx, u_int sy) { - struct winsize ws; - if (sx == wp->sx && sy == wp->sy) return; wp->sx = sx; wp->sy = sy; - memset(&ws, 0, sizeof ws); - ws.ws_col = sx; - ws.ws_row = sy; - screen_resize(&wp->base, sx, sy, wp->saved_grid == NULL); if (wp->mode != NULL) wp->mode->resize(wp, sx, sy); - - if (wp->fd != -1 && ioctl(wp->fd, TIOCSWINSZ, &ws) == -1) - fatal("ioctl failed"); } /* -- cgit From c71844de631186f3df7ff5a6e3aab613da1e4853 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Sun, 24 Mar 2013 09:57:59 +0000 Subject: Add resize-pane -Z to temporary zoom the active pane to occupy the full window or unzoom (restored to the normal layout) if it already zoomed, bound to C-b z by default. The pane is unzoomed on pretty much any excuse whatsoever. We considered making this a new layout but the requirements are quite different from layouts so decided it is better as a special case. Each current layout cell is saved, a temporary one-cell layout generated and all except the active pane set to NULL. Prompted by suggestions and scripts from several. Thanks to Aaron Jensen and Thiago Padilha for testing an earlier version. --- window.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) (limited to 'window.c') 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) -- cgit From 114d822d27b2d4d20d707361629aaab6ba5a1a9f Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Mon, 25 Mar 2013 11:39:11 +0000 Subject: Don't zoom windows with one pane, from Romain Francoise. --- window.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'window.c') diff --git a/window.c b/window.c index 38af88f9..99d87ed6 100644 --- a/window.c +++ b/window.c @@ -483,6 +483,10 @@ window_zoom(struct window_pane *wp) if (!window_pane_visible(wp)) return (-1); + + if (window_count_panes(w) == 1) + return (-1); + if (w->active != wp) window_set_active_pane(w, wp); -- cgit From 58bb6f8c5650d496fb3b872766c0278aa024631d Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Mon, 25 Mar 2013 11:55:01 +0000 Subject: Set pane resize flag when needed. --- window.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'window.c') diff --git a/window.c b/window.c index 99d87ed6..0ab36033 100644 --- a/window.c +++ b/window.c @@ -918,6 +918,8 @@ window_pane_resize(struct window_pane *wp, u_int sx, u_int sy) screen_resize(&wp->base, sx, sy, wp->saved_grid == NULL); if (wp->mode != NULL) wp->mode->resize(wp, sx, sy); + + wp->flags |= PANE_RESIZE; } /* -- cgit