From 158f0e8c414e9525358189bd7135e12e6e6ada49 Mon Sep 17 00:00:00 2001 From: nicm Date: Tue, 17 Aug 2021 07:14:33 +0000 Subject: [PATCH 1/3] Start sync before drawing popup. --- popup.c | 1 + 1 file changed, 1 insertion(+) diff --git a/popup.c b/popup.c index d4fc3833..33765d9b 100644 --- a/popup.c +++ b/popup.c @@ -554,6 +554,7 @@ popup_job_update_cb(struct job *job) if (size == 0) return; + tty_sync_start(&c->tty); if (pd->md != NULL) { c->overlay_check = menu_check_cb; c->overlay_data = pd->md; From 1a7eb6ca9006208b8b76c6a2a5a92c66648c03da Mon Sep 17 00:00:00 2001 From: nicm Date: Tue, 17 Aug 2021 08:22:44 +0000 Subject: [PATCH 2/3] Revert previous; this is not how it should work. --- popup.c | 1 - 1 file changed, 1 deletion(-) diff --git a/popup.c b/popup.c index 33765d9b..d4fc3833 100644 --- a/popup.c +++ b/popup.c @@ -554,7 +554,6 @@ popup_job_update_cb(struct job *job) if (size == 0) return; - tty_sync_start(&c->tty); if (pd->md != NULL) { c->overlay_check = menu_check_cb; c->overlay_data = pd->md; From 41ababdf6c0529d4336a1daf3418ad314c373614 Mon Sep 17 00:00:00 2001 From: nicm Date: Tue, 17 Aug 2021 08:44:52 +0000 Subject: [PATCH 3/3] Be more sophisticated about enabling synchronized updates when there is an overlay and treat it like the active pane (use for commands which move the cursor only). When there is an overlay also use it for all panes and not just the active pane. GitHub issue 2826. --- screen-write.c | 17 ++++++++++++++--- tty.c | 17 +++++++++++++++-- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/screen-write.c b/screen-write.c index 01f8a097..c09d09ab 100644 --- a/screen-write.c +++ b/screen-write.c @@ -197,9 +197,20 @@ screen_write_initctx(struct screen_write_ctx *ctx, struct tty_ctx *ttyctx, } } - if (ctx->wp != NULL && - (~ctx->flags & SCREEN_WRITE_SYNC) && - (sync || ctx->wp != ctx->wp->window->active)) { + if (~ctx->flags & SCREEN_WRITE_SYNC) { + /* + * For the active pane or for an overlay (no pane), we want to + * only use synchronized updates if requested (commands that + * move the cursor); for other panes, always use it, since the + * cursor will have to move. + */ + if (ctx->wp != NULL) { + if (ctx->wp != ctx->wp->window->active) + ttyctx->num = 1; + else + ttyctx->num = sync; + } else + ttyctx->num = 0x10|sync; tty_write(tty_cmd_syncstart, ttyctx); ctx->flags |= SCREEN_WRITE_SYNC; } diff --git a/tty.c b/tty.c index 2a9f8b01..f93f6c57 100644 --- a/tty.c +++ b/tty.c @@ -2039,9 +2039,22 @@ tty_cmd_rawstring(struct tty *tty, const struct tty_ctx *ctx) } void -tty_cmd_syncstart(struct tty *tty, __unused const struct tty_ctx *ctx) +tty_cmd_syncstart(struct tty *tty, const struct tty_ctx *ctx) { - tty_sync_start(tty); + if (ctx->num == 0x11) { + /* + * This is an overlay and a command that moves, the cursor so + * start synchronized updates. + */ + tty_sync_start(tty); + } else if (~ctx->num & 0x10) { + /* + * This is a pane. If there is an overlay, always start; + * otherwise, only if requested. + */ + if (ctx->num || tty->client->overlay_draw != NULL) + tty_sync_start(tty); + } } void