From 5289d4ed13e18fa4430aba27af0d525d2f76fc30 Mon Sep 17 00:00:00 2001 From: nicm Date: Sat, 18 Apr 2020 06:10:15 +0000 Subject: When a redraw is deferred because the terminal hasn't finished reading the data from the last one, other panes could update while waiting, so we set the flag to redraw them all when the new redraw actually happened. But this means a lot of redrawing panes unnecessarily if they haven't changed - so instead set a flag to say "at least one pane needs to be redrawed" then look at the invidual pane flags to see which ones need it. --- server-client.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'server-client.c') diff --git a/server-client.c b/server-client.c index 8365831f..a045c44b 100644 --- a/server-client.c +++ b/server-client.c @@ -1681,7 +1681,7 @@ server_client_check_redraw(struct client *c) struct session *s = c->session; struct tty *tty = &c->tty; struct window_pane *wp; - int needed, flags, mode = tty->mode; + int needed, flags, mode = tty->mode, new_flags = 0; struct timeval tv = { .tv_usec = 1000 }; static struct event ev; size_t left; @@ -1689,11 +1689,12 @@ server_client_check_redraw(struct client *c) if (c->flags & (CLIENT_CONTROL|CLIENT_SUSPENDED)) return; if (c->flags & CLIENT_ALLREDRAWFLAGS) { - log_debug("%s: redraw%s%s%s%s", c->name, + log_debug("%s: redraw%s%s%s%s%s", c->name, (c->flags & CLIENT_REDRAWWINDOW) ? " window" : "", (c->flags & CLIENT_REDRAWSTATUS) ? " status" : "", (c->flags & CLIENT_REDRAWBORDERS) ? " borders" : "", - (c->flags & CLIENT_REDRAWOVERLAY) ? " overlay" : ""); + (c->flags & CLIENT_REDRAWOVERLAY) ? " overlay" : "", + (c->flags & CLIENT_REDRAWPANES) ? " panes" : ""); } /* @@ -1711,6 +1712,8 @@ server_client_check_redraw(struct client *c) break; } } + if (needed) + new_flags |= CLIENT_REDRAWPANES; } if (needed && (left = EVBUFFER_LENGTH(tty->out)) != 0) { log_debug("%s: redraw deferred (%zu left)", c->name, left); @@ -1720,12 +1723,7 @@ server_client_check_redraw(struct client *c) log_debug("redraw timer started"); evtimer_add(&ev, &tv); } - - /* - * We may have got here for a single pane redraw, but force a - * full redraw next time in case other panes have been updated. - */ - c->flags |= CLIENT_ALLREDRAWFLAGS; + c->flags |= new_flags; return; } else if (needed) log_debug("%s: redraw needed", c->name); @@ -1741,10 +1739,12 @@ server_client_check_redraw(struct client *c) */ 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, tty->mode, NULL); screen_redraw_pane(c, wp); } } + c->flags &= ~CLIENT_REDRAWPANES; } if (c->flags & CLIENT_ALLREDRAWFLAGS) { -- cgit From d94bdf7420eb6d0ef88783a35db2c592a3fccec0 Mon Sep 17 00:00:00 2001 From: nicm Date: Sat, 18 Apr 2020 06:15:07 +0000 Subject: Revert previous, there is still a problem. --- server-client.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'server-client.c') diff --git a/server-client.c b/server-client.c index a045c44b..8365831f 100644 --- a/server-client.c +++ b/server-client.c @@ -1681,7 +1681,7 @@ server_client_check_redraw(struct client *c) struct session *s = c->session; struct tty *tty = &c->tty; struct window_pane *wp; - int needed, flags, mode = tty->mode, new_flags = 0; + int needed, flags, mode = tty->mode; struct timeval tv = { .tv_usec = 1000 }; static struct event ev; size_t left; @@ -1689,12 +1689,11 @@ server_client_check_redraw(struct client *c) if (c->flags & (CLIENT_CONTROL|CLIENT_SUSPENDED)) return; if (c->flags & CLIENT_ALLREDRAWFLAGS) { - log_debug("%s: redraw%s%s%s%s%s", c->name, + log_debug("%s: redraw%s%s%s%s", c->name, (c->flags & CLIENT_REDRAWWINDOW) ? " window" : "", (c->flags & CLIENT_REDRAWSTATUS) ? " status" : "", (c->flags & CLIENT_REDRAWBORDERS) ? " borders" : "", - (c->flags & CLIENT_REDRAWOVERLAY) ? " overlay" : "", - (c->flags & CLIENT_REDRAWPANES) ? " panes" : ""); + (c->flags & CLIENT_REDRAWOVERLAY) ? " overlay" : ""); } /* @@ -1712,8 +1711,6 @@ server_client_check_redraw(struct client *c) break; } } - if (needed) - new_flags |= CLIENT_REDRAWPANES; } if (needed && (left = EVBUFFER_LENGTH(tty->out)) != 0) { log_debug("%s: redraw deferred (%zu left)", c->name, left); @@ -1723,7 +1720,12 @@ server_client_check_redraw(struct client *c) log_debug("redraw timer started"); evtimer_add(&ev, &tv); } - c->flags |= new_flags; + + /* + * We may have got here for a single pane redraw, but force a + * full redraw next time in case other panes have been updated. + */ + c->flags |= CLIENT_ALLREDRAWFLAGS; return; } else if (needed) log_debug("%s: redraw needed", c->name); @@ -1739,12 +1741,10 @@ server_client_check_redraw(struct client *c) */ 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, tty->mode, NULL); screen_redraw_pane(c, wp); } } - c->flags &= ~CLIENT_REDRAWPANES; } if (c->flags & CLIENT_ALLREDRAWFLAGS) { -- cgit From 1d2bd864f25a58ab85a6f9f0a448f3a69d8491cd Mon Sep 17 00:00:00 2001 From: nicm Date: Sat, 18 Apr 2020 06:20:50 +0000 Subject: Add a flag to protect against nested syncs and add some extra logging to redrawing. --- server-client.c | 1 + 1 file changed, 1 insertion(+) (limited to 'server-client.c') diff --git a/server-client.c b/server-client.c index 8365831f..c74e4dd5 100644 --- a/server-client.c +++ b/server-client.c @@ -1741,6 +1741,7 @@ server_client_check_redraw(struct client *c) */ 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, tty->mode, NULL); screen_redraw_pane(c, wp); } -- cgit