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. --- tty.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'tty.c') diff --git a/tty.c b/tty.c index 82436959..a50db799 100644 --- a/tty.c +++ b/tty.c @@ -1438,15 +1438,19 @@ tty_draw_line(struct tty *tty, struct window_pane *wp, struct screen *s, void tty_sync_start(struct tty *tty) { - if (tty_get_flags(tty) & TERM_SYNC) + if ((~tty->flags & TTY_SYNCING) && (tty_get_flags(tty) & TERM_SYNC)) { tty_puts(tty, "\033P=1s\033\\"); + tty->flags |= TTY_SYNCING; + } } void tty_sync_end(struct tty *tty) { - if (tty_get_flags(tty) & TERM_SYNC) + if (tty_get_flags(tty) & TERM_SYNC) { tty_puts(tty, "\033P=2s\033\\"); + tty->flags &= ~TTY_SYNCING; + } } static int @@ -1480,6 +1484,14 @@ tty_write(void (*cmdfn)(struct tty *, const struct tty_ctx *), TAILQ_FOREACH(c, &clients, entry) { if (!tty_client_ready(c, wp)) continue; + if (c->flags & CLIENT_REDRAWPANES) { + /* + * Redraw is already deferred to redraw another pane - + * redraw this one also when that happens. + */ + wp->flags |= PANE_REDRAW; + break; + } ctx->bigger = tty_window_offset(&c->tty, &ctx->ox, &ctx->oy, &ctx->sx, &ctx->sy); -- 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. --- tty.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'tty.c') diff --git a/tty.c b/tty.c index a50db799..82436959 100644 --- a/tty.c +++ b/tty.c @@ -1438,19 +1438,15 @@ tty_draw_line(struct tty *tty, struct window_pane *wp, struct screen *s, void tty_sync_start(struct tty *tty) { - if ((~tty->flags & TTY_SYNCING) && (tty_get_flags(tty) & TERM_SYNC)) { + if (tty_get_flags(tty) & TERM_SYNC) tty_puts(tty, "\033P=1s\033\\"); - tty->flags |= TTY_SYNCING; - } } void tty_sync_end(struct tty *tty) { - if (tty_get_flags(tty) & TERM_SYNC) { + if (tty_get_flags(tty) & TERM_SYNC) tty_puts(tty, "\033P=2s\033\\"); - tty->flags &= ~TTY_SYNCING; - } } static int @@ -1484,14 +1480,6 @@ tty_write(void (*cmdfn)(struct tty *, const struct tty_ctx *), TAILQ_FOREACH(c, &clients, entry) { if (!tty_client_ready(c, wp)) continue; - if (c->flags & CLIENT_REDRAWPANES) { - /* - * Redraw is already deferred to redraw another pane - - * redraw this one also when that happens. - */ - wp->flags |= PANE_REDRAW; - break; - } ctx->bigger = tty_window_offset(&c->tty, &ctx->ox, &ctx->oy, &ctx->sx, &ctx->sy); -- 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. --- tty.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'tty.c') diff --git a/tty.c b/tty.c index 82436959..92827f5d 100644 --- a/tty.c +++ b/tty.c @@ -1438,15 +1438,19 @@ tty_draw_line(struct tty *tty, struct window_pane *wp, struct screen *s, void tty_sync_start(struct tty *tty) { - if (tty_get_flags(tty) & TERM_SYNC) + if ((~tty->flags & TTY_SYNCING) && (tty_get_flags(tty) & TERM_SYNC)) { tty_puts(tty, "\033P=1s\033\\"); + tty->flags |= TTY_SYNCING; + } } void tty_sync_end(struct tty *tty) { - if (tty_get_flags(tty) & TERM_SYNC) + if (tty_get_flags(tty) & TERM_SYNC) { tty_puts(tty, "\033P=2s\033\\"); + tty->flags &= ~TTY_SYNCING; + } } static int -- cgit