From 3c24bc5617bfdf90f94cc088f3769397c7569649 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 7 Mar 2019 19:34:22 +0000 Subject: [PATCH] Tidy changing the mode into window_copy_init_for_output. --- cfg.c | 1 - cmd-queue.c | 7 +------ cmd-run-shell.c | 6 ++---- window-copy.c | 6 ++++++ 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/cfg.c b/cfg.c index 9cbb9c2a..0842f638 100644 --- a/cfg.c +++ b/cfg.c @@ -348,7 +348,6 @@ cfg_show_causes(struct session *s) return; wp = s->curw->window->active; - window_pane_set_mode(wp, &window_copy_mode, NULL, NULL); window_copy_init_for_output(wp); for (i = 0; i < cfg_ncauses; i++) { window_copy_add(wp, "%s", cfg_causes[i]); diff --git a/cmd-queue.c b/cmd-queue.c index ec65bd80..ccb25c9a 100644 --- a/cmd-queue.c +++ b/cmd-queue.c @@ -426,12 +426,7 @@ cmdq_print(struct cmdq_item *item, const char *fmt, ...) server_client_push_stdout(c); } else { w = c->session->curw->window; - if (w->active->mode != &window_copy_mode) { - window_pane_reset_mode(w->active); - window_pane_set_mode(w->active, &window_copy_mode, NULL, - NULL); - window_copy_init_for_output(w->active); - } + window_copy_init_for_output(w->active); window_copy_vadd(w->active, fmt, ap); } diff --git a/cmd-run-shell.c b/cmd-run-shell.c index 47fceafe..998ffcd8 100644 --- a/cmd-run-shell.c +++ b/cmd-run-shell.c @@ -75,10 +75,8 @@ cmd_run_shell_print(struct job *job, const char *msg) return; } - if (window_pane_set_mode(wp, &window_copy_mode, NULL, NULL) == 0) - window_copy_init_for_output(wp); - if (wp->mode == &window_copy_mode) - window_copy_add(wp, "%s", msg); + window_copy_init_for_output(wp); + window_copy_add(wp, "%s", msg); } static enum cmd_retval diff --git a/window-copy.c b/window-copy.c index ed36efc0..a79e3bf4 100644 --- a/window-copy.c +++ b/window-copy.c @@ -263,6 +263,12 @@ window_copy_init_for_output(struct window_pane *wp) { struct window_copy_mode_data *data = wp->modedata; + if (wp->mode == &window_copy_mode && data->backing != &wp->base) + return; + window_pane_reset_mode(wp); + window_pane_set_mode(wp, &window_copy_mode, NULL, NULL); + + data = wp->modedata; data->backing = xmalloc(sizeof *data->backing); screen_init(data->backing, screen_size_x(&wp->base), screen_size_y(&wp->base), UINT_MAX);