From 2083a6ea2050fb211eab3da0df0ff5a40b4973b4 Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 20 Apr 2020 14:59:31 +0000 Subject: Change how sync works to always send the end sequence after all output is done when we are returning to the event loop (since we always move the cursor at that point). Also a man fix from jmc. --- screen-redraw.c | 2 -- screen-write.c | 9 --------- server-client.c | 12 +++++++++++- tmux.1 | 2 +- tmux.h | 1 - tty-keys.c | 2 +- tty.c | 26 ++++++++++++++++---------- 7 files changed, 29 insertions(+), 25 deletions(-) diff --git a/screen-redraw.c b/screen-redraw.c index c9e70590..8e74fe97 100644 --- a/screen-redraw.c +++ b/screen-redraw.c @@ -458,7 +458,6 @@ screen_redraw_screen(struct client *c) } tty_reset(&c->tty); - tty_sync_end(&c->tty); } /* Redraw a single pane. */ @@ -476,7 +475,6 @@ screen_redraw_pane(struct client *c, struct window_pane *wp) screen_redraw_draw_pane(&ctx, wp); tty_reset(&c->tty); - tty_sync_end(&c->tty); } /* Draw a border cell. */ diff --git a/screen-write.c b/screen-write.c index 55d399a7..042f2fa8 100644 --- a/screen-write.c +++ b/screen-write.c @@ -119,7 +119,6 @@ screen_write_initctx(struct screen_write_ctx *ctx, struct tty_ctx *ttyctx, ttyctx->orupper = s->rupper; if (sync && !ctx->sync && ttyctx->wp != NULL) { - log_debug("%s: starting sync", __func__); tty_write(tty_cmd_syncstart, ttyctx); ctx->sync = 1; } @@ -184,8 +183,6 @@ screen_write_start(struct screen_write_ctx *ctx, struct window_pane *wp, void screen_write_stop(struct screen_write_ctx *ctx) { - struct tty_ctx ttyctx; - screen_write_collect_end(ctx); screen_write_collect_flush(ctx, 0, __func__); @@ -196,12 +193,6 @@ screen_write_stop(struct screen_write_ctx *ctx) ctx->wp->skipped += ctx->skipped; } - if (ctx->sync) { - screen_write_initctx(ctx, &ttyctx, 0); - tty_write(tty_cmd_syncend, &ttyctx); - log_debug("%s: ending sync", __func__); - } - free(ctx->item); } diff --git a/server-client.c b/server-client.c index cd850593..8da55ac0 100644 --- a/server-client.c +++ b/server-client.c @@ -1541,7 +1541,7 @@ server_client_reset_state(struct client *c) struct window_pane *wp = w->active, *loop; struct screen *s; struct options *oo = c->session->options; - int mode, cursor; + int mode, cursor, flags; u_int cx = 0, cy = 0, ox, oy, sx, sy; if (c->flags & (CLIENT_CONTROL|CLIENT_SUSPENDED)) @@ -1606,6 +1606,16 @@ server_client_reset_state(struct client *c) /* Set the terminal mode and reset attributes. */ tty_update_mode(&c->tty, mode, s); tty_reset(&c->tty); + + /* + * All writing must be done, send a sync end (if it was started). It + * may have been started by redrawing so needs to go out even if the + * block flag is set. + */ + flags = (c->tty.flags & TTY_BLOCK); + c->tty.flags &= ~TTY_BLOCK; + tty_sync_end(&c->tty); + c->tty.flags |= flags; } /* Repeat time callback. */ diff --git a/tmux.1 b/tmux.1 index 648aed4d..e54817d5 100644 --- a/tmux.1 +++ b/tmux.1 @@ -5534,7 +5534,7 @@ The server crashed or otherwise exited without telling the client the reason. .Sh TERMINFO EXTENSIONS .Nm understands some unofficial extensions to -.Xr terminfo 5. +.Xr terminfo 5 . It is not normally necessary to set these manually, instead the .Ic terminal-features option should be used. diff --git a/tmux.h b/tmux.h index 3853b09f..5d7dbba7 100644 --- a/tmux.h +++ b/tmux.h @@ -1992,7 +1992,6 @@ void tty_cmd_reverseindex(struct tty *, const struct tty_ctx *); void tty_cmd_setselection(struct tty *, const struct tty_ctx *); void tty_cmd_rawstring(struct tty *, const struct tty_ctx *); void tty_cmd_syncstart(struct tty *, const struct tty_ctx *); -void tty_cmd_syncend(struct tty *, const struct tty_ctx *); /* tty-term.c */ extern struct tty_terms tty_terms; diff --git a/tty-keys.c b/tty-keys.c index 14952c05..aa775d69 100644 --- a/tty-keys.c +++ b/tty-keys.c @@ -1150,7 +1150,7 @@ tty_keys_device_status_report(struct tty *tty, const char *buf, size_t len, "cstyle," "margins," "sync," - "title,", + "title", ","); } else if (strncmp(tmp, "TMUX ", 5) == 0) { tty_add_features(&c->term_features, diff --git a/tty.c b/tty.c index e1c629ec..0214524c 100644 --- a/tty.c +++ b/tty.c @@ -1427,18 +1427,30 @@ 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_term_has(tty->term, TTYC_SYNC)) { + if (tty->flags & TTY_BLOCK) + return; + if (tty->flags & TTY_SYNCING) + return; + tty->flags |= TTY_SYNCING; + + if (tty_term_has(tty->term, TTYC_SYNC)) { + log_debug("%s sync start", tty->client->name); tty_putcode1(tty, TTYC_SYNC, 1); - tty->flags |= TTY_SYNCING; } } void tty_sync_end(struct tty *tty) { - if ((tty->flags & TTY_SYNCING) && tty_term_has(tty->term, TTYC_SYNC)) { + if (tty->flags & TTY_BLOCK) + return; + if (~tty->flags & TTY_SYNCING) + return; + tty->flags &= ~TTY_SYNCING; + + if (tty_term_has(tty->term, TTYC_SYNC)) { + log_debug("%s sync end", tty->client->name); tty_putcode1(tty, TTYC_SYNC, 2); - tty->flags &= ~TTY_SYNCING; } } @@ -1952,12 +1964,6 @@ tty_cmd_syncstart(struct tty *tty, __unused const struct tty_ctx *ctx) tty_sync_start(tty); } -void -tty_cmd_syncend(struct tty *tty, __unused const struct tty_ctx *ctx) -{ - tty_sync_end(tty); -} - static void tty_cell(struct tty *tty, const struct grid_cell *gc, struct window_pane *wp) { -- cgit