diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2020-04-18 21:35:33 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2020-04-18 21:35:33 +0000 |
commit | f19bd07f81bd5bb25361e97893295f6cff6dc666 (patch) | |
tree | 57d560003fd334152bfd057d55c87ca80b73f567 | |
parent | 2ca1ada1d221465ad3f7db95534bc8c4692795f0 (diff) |
The PANE_REDRAW flag bit might be needed by other panes so we can't
clear it on the first redraw, and it can't be set when we are finished
or they would be redrawn again, so if the redraw is deferred for a
client, copy the redraw flag into a separate set of bits just for that
client.
-rw-r--r-- | usr.bin/tmux/screen-redraw.c | 4 | ||||
-rw-r--r-- | usr.bin/tmux/server-client.c | 47 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 4 |
3 files changed, 40 insertions, 15 deletions
diff --git a/usr.bin/tmux/screen-redraw.c b/usr.bin/tmux/screen-redraw.c index 110e5146f0c..0131e155b2b 100644 --- a/usr.bin/tmux/screen-redraw.c +++ b/usr.bin/tmux/screen-redraw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: screen-redraw.c,v 1.71 2020/04/18 07:32:53 nicm Exp $ */ +/* $OpenBSD: screen-redraw.c,v 1.72 2020/04/18 21:35:32 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -474,7 +474,6 @@ screen_redraw_pane(struct client *c, struct window_pane *wp) tty_sync_start(&c->tty); screen_redraw_draw_pane(&ctx, wp); - wp->flags &= ~PANE_REDRAW; tty_reset(&c->tty); tty_sync_end(&c->tty); @@ -564,7 +563,6 @@ screen_redraw_draw_panes(struct screen_redraw_ctx *ctx) TAILQ_FOREACH(wp, &w->panes, entry) { if (window_pane_visible(wp)) screen_redraw_draw_pane(ctx, wp); - wp->flags &= ~PANE_REDRAW; } } diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c index b9dec44c433..af2ef1a6780 100644 --- a/usr.bin/tmux/server-client.c +++ b/usr.bin/tmux/server-client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server-client.c,v 1.325 2020/04/18 07:32:53 nicm Exp $ */ +/* $OpenBSD: server-client.c,v 1.326 2020/04/18 21:35:32 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -1370,6 +1370,7 @@ server_client_loop(void) if (resize) server_client_check_resize(wp); } + wp->flags &= ~PANE_REDRAW; } check_window_name(w); } @@ -1679,8 +1680,11 @@ server_client_check_redraw(struct client *c) { struct session *s = c->session; struct tty *tty = &c->tty; + struct window *w = c->session->curw->window; struct window_pane *wp; int needed, flags, mode = tty->mode, new_flags = 0; + int redraw; + u_int bit = 0; struct timeval tv = { .tv_usec = 1000 }; static struct event ev; size_t left; @@ -1705,7 +1709,7 @@ server_client_check_redraw(struct client *c) if (c->flags & CLIENT_ALLREDRAWFLAGS) needed = 1; else { - TAILQ_FOREACH(wp, &c->session->curw->window->panes, entry) { + TAILQ_FOREACH(wp, &w->panes, entry) { if (wp->flags & PANE_REDRAW) { needed = 1; break; @@ -1722,25 +1726,46 @@ server_client_check_redraw(struct client *c) log_debug("redraw timer started"); evtimer_add(&ev, &tv); } + if (new_flags & CLIENT_REDRAWPANES) { + c->redraw_panes = 0; + TAILQ_FOREACH(wp, &w->panes, entry) { + if (wp->flags & PANE_REDRAW) + c->redraw_panes |= (1 << bit); + if (++bit == 64) { + /* + * If more that 64 panes, give up and + * just redraw the window. + */ + new_flags &= CLIENT_REDRAWPANES; + new_flags |= CLIENT_REDRAWWINDOW; + break; + } + } + } c->flags |= new_flags; return; } else if (needed) log_debug("%s: redraw needed", c->name); flags = tty->flags & (TTY_BLOCK|TTY_FREEZE|TTY_NOCURSOR); - tty->flags = (tty->flags & ~(TTY_BLOCK|TTY_FREEZE)) | TTY_NOCURSOR; + tty->flags = (tty->flags & ~(TTY_BLOCK|TTY_FREEZE))|TTY_NOCURSOR; if (~c->flags & CLIENT_REDRAWWINDOW) { /* * If not redrawing the entire window, check whether each pane * needs to be redrawn. */ - TAILQ_FOREACH(wp, &c->session->curw->window->panes, entry) { - if (wp->flags & PANE_REDRAW) { - log_debug("%s: redrawing pane %%%u", __func__, wp->id); - tty_update_mode(tty, mode, NULL); - screen_redraw_pane(c, wp); - } + TAILQ_FOREACH(wp, &w->panes, entry) { + redraw = 0; + if (wp->flags & PANE_REDRAW) + redraw = 1; + else if (c->flags & CLIENT_REDRAWPANES) + redraw = !!(c->redraw_panes & (1 << bit)); + if (!redraw) + continue; + log_debug("%s: redrawing pane %%%u", __func__, wp->id); + tty_update_mode(tty, mode, NULL); + screen_redraw_pane(c, wp); } c->flags &= ~CLIENT_REDRAWPANES; } @@ -1752,9 +1777,9 @@ server_client_check_redraw(struct client *c) screen_redraw_screen(c); } - tty->flags = (tty->flags & ~TTY_NOCURSOR) | (flags & TTY_NOCURSOR); + tty->flags = (tty->flags & ~TTY_NOCURSOR)|(flags & TTY_NOCURSOR); tty_update_mode(tty, mode, NULL); - tty->flags = (tty->flags & ~(TTY_BLOCK|TTY_FREEZE|TTY_NOCURSOR)) | flags; + tty->flags = (tty->flags & ~(TTY_BLOCK|TTY_FREEZE|TTY_NOCURSOR))|flags; c->flags &= ~(CLIENT_ALLREDRAWFLAGS|CLIENT_STATUSFORCE); diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 660374fc311..302a7547805 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.1009 2020/04/18 17:20:25 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.1010 2020/04/18 21:35:32 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -1562,6 +1562,8 @@ struct client { int flags; struct key_table *keytable; + uint64_t redraw_panes; + char *message_string; struct event message_timer; u_int message_next; |