mirror of
https://github.com/tmux/tmux.git
synced 2025-09-02 13:37:12 +00:00
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.
This commit is contained in:
@ -438,17 +438,24 @@ screen_redraw_screen(struct client *c)
|
|||||||
tty_sync_start(&c->tty);
|
tty_sync_start(&c->tty);
|
||||||
|
|
||||||
if (flags & (CLIENT_REDRAWWINDOW|CLIENT_REDRAWBORDERS)) {
|
if (flags & (CLIENT_REDRAWWINDOW|CLIENT_REDRAWBORDERS)) {
|
||||||
|
log_debug("%s: redrawing borders", c->name);
|
||||||
if (ctx.pane_status != PANE_STATUS_OFF)
|
if (ctx.pane_status != PANE_STATUS_OFF)
|
||||||
screen_redraw_draw_pane_status(&ctx);
|
screen_redraw_draw_pane_status(&ctx);
|
||||||
screen_redraw_draw_borders(&ctx);
|
screen_redraw_draw_borders(&ctx);
|
||||||
}
|
}
|
||||||
if (flags & CLIENT_REDRAWWINDOW)
|
if (flags & CLIENT_REDRAWWINDOW) {
|
||||||
|
log_debug("%s: redrawing panes", c->name);
|
||||||
screen_redraw_draw_panes(&ctx);
|
screen_redraw_draw_panes(&ctx);
|
||||||
|
}
|
||||||
if (ctx.statuslines != 0 &&
|
if (ctx.statuslines != 0 &&
|
||||||
(flags & (CLIENT_REDRAWSTATUS|CLIENT_REDRAWSTATUSALWAYS)))
|
(flags & (CLIENT_REDRAWSTATUS|CLIENT_REDRAWSTATUSALWAYS))) {
|
||||||
|
log_debug("%s: redrawing status", c->name);
|
||||||
screen_redraw_draw_status(&ctx);
|
screen_redraw_draw_status(&ctx);
|
||||||
if (c->overlay_draw != NULL && (flags & CLIENT_REDRAWOVERLAY))
|
}
|
||||||
|
if (c->overlay_draw != NULL && (flags & CLIENT_REDRAWOVERLAY)) {
|
||||||
|
log_debug("%s: redrawing overlay", c->name);
|
||||||
c->overlay_draw(c, &ctx);
|
c->overlay_draw(c, &ctx);
|
||||||
|
}
|
||||||
|
|
||||||
tty_reset(&c->tty);
|
tty_reset(&c->tty);
|
||||||
tty_sync_end(&c->tty);
|
tty_sync_end(&c->tty);
|
||||||
|
@ -1681,7 +1681,7 @@ server_client_check_redraw(struct client *c)
|
|||||||
struct session *s = c->session;
|
struct session *s = c->session;
|
||||||
struct tty *tty = &c->tty;
|
struct tty *tty = &c->tty;
|
||||||
struct window_pane *wp;
|
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 };
|
struct timeval tv = { .tv_usec = 1000 };
|
||||||
static struct event ev;
|
static struct event ev;
|
||||||
size_t left;
|
size_t left;
|
||||||
@ -1689,11 +1689,12 @@ server_client_check_redraw(struct client *c)
|
|||||||
if (c->flags & (CLIENT_CONTROL|CLIENT_SUSPENDED))
|
if (c->flags & (CLIENT_CONTROL|CLIENT_SUSPENDED))
|
||||||
return;
|
return;
|
||||||
if (c->flags & CLIENT_ALLREDRAWFLAGS) {
|
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_REDRAWWINDOW) ? " window" : "",
|
||||||
(c->flags & CLIENT_REDRAWSTATUS) ? " status" : "",
|
(c->flags & CLIENT_REDRAWSTATUS) ? " status" : "",
|
||||||
(c->flags & CLIENT_REDRAWBORDERS) ? " borders" : "",
|
(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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (needed)
|
||||||
|
new_flags |= CLIENT_REDRAWPANES;
|
||||||
}
|
}
|
||||||
if (needed && (left = EVBUFFER_LENGTH(tty->out)) != 0) {
|
if (needed && (left = EVBUFFER_LENGTH(tty->out)) != 0) {
|
||||||
log_debug("%s: redraw deferred (%zu left)", c->name, left);
|
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");
|
log_debug("redraw timer started");
|
||||||
evtimer_add(&ev, &tv);
|
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;
|
return;
|
||||||
} else if (needed)
|
} else if (needed)
|
||||||
log_debug("%s: redraw needed", c->name);
|
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) {
|
TAILQ_FOREACH(wp, &c->session->curw->window->panes, entry) {
|
||||||
if (wp->flags & PANE_REDRAW) {
|
if (wp->flags & PANE_REDRAW) {
|
||||||
|
log_debug("%s: redrawing pane %%%u", __func__, wp->id);
|
||||||
tty_update_mode(tty, tty->mode, NULL);
|
tty_update_mode(tty, tty->mode, NULL);
|
||||||
screen_redraw_pane(c, wp);
|
screen_redraw_pane(c, wp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
c->flags &= ~CLIENT_REDRAWPANES;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c->flags & CLIENT_ALLREDRAWFLAGS) {
|
if (c->flags & CLIENT_ALLREDRAWFLAGS) {
|
||||||
|
5
tmux.h
5
tmux.h
@ -1244,6 +1244,7 @@ struct tty {
|
|||||||
#define TTY_BLOCK 0x80
|
#define TTY_BLOCK 0x80
|
||||||
#define TTY_HAVEDA 0x100
|
#define TTY_HAVEDA 0x100
|
||||||
#define TTY_HAVEDSR 0x200
|
#define TTY_HAVEDSR 0x200
|
||||||
|
#define TTY_SYNCING 0x400
|
||||||
int flags;
|
int flags;
|
||||||
|
|
||||||
struct tty_term *term;
|
struct tty_term *term;
|
||||||
@ -1538,12 +1539,14 @@ struct client {
|
|||||||
#define CLIENT_CONTROL_NOOUTPUT 0x4000000
|
#define CLIENT_CONTROL_NOOUTPUT 0x4000000
|
||||||
#define CLIENT_DEFAULTSOCKET 0x8000000
|
#define CLIENT_DEFAULTSOCKET 0x8000000
|
||||||
#define CLIENT_STARTSERVER 0x10000000
|
#define CLIENT_STARTSERVER 0x10000000
|
||||||
|
#define CLIENT_REDRAWPANES 0x20000000
|
||||||
#define CLIENT_ALLREDRAWFLAGS \
|
#define CLIENT_ALLREDRAWFLAGS \
|
||||||
(CLIENT_REDRAWWINDOW| \
|
(CLIENT_REDRAWWINDOW| \
|
||||||
CLIENT_REDRAWSTATUS| \
|
CLIENT_REDRAWSTATUS| \
|
||||||
CLIENT_REDRAWSTATUSALWAYS| \
|
CLIENT_REDRAWSTATUSALWAYS| \
|
||||||
CLIENT_REDRAWBORDERS| \
|
CLIENT_REDRAWBORDERS| \
|
||||||
CLIENT_REDRAWOVERLAY)
|
CLIENT_REDRAWOVERLAY| \
|
||||||
|
CLIENT_REDRAWPANES)
|
||||||
#define CLIENT_UNATTACHEDFLAGS \
|
#define CLIENT_UNATTACHEDFLAGS \
|
||||||
(CLIENT_DEAD| \
|
(CLIENT_DEAD| \
|
||||||
CLIENT_SUSPENDED| \
|
CLIENT_SUSPENDED| \
|
||||||
|
16
tty.c
16
tty.c
@ -1438,15 +1438,19 @@ tty_draw_line(struct tty *tty, struct window_pane *wp, struct screen *s,
|
|||||||
void
|
void
|
||||||
tty_sync_start(struct tty *tty)
|
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_puts(tty, "\033P=1s\033\\");
|
||||||
|
tty->flags |= TTY_SYNCING;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
tty_sync_end(struct tty *tty)
|
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_puts(tty, "\033P=2s\033\\");
|
||||||
|
tty->flags &= ~TTY_SYNCING;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -1480,6 +1484,14 @@ tty_write(void (*cmdfn)(struct tty *, const struct tty_ctx *),
|
|||||||
TAILQ_FOREACH(c, &clients, entry) {
|
TAILQ_FOREACH(c, &clients, entry) {
|
||||||
if (!tty_client_ready(c, wp))
|
if (!tty_client_ready(c, wp))
|
||||||
continue;
|
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->bigger = tty_window_offset(&c->tty, &ctx->ox, &ctx->oy,
|
||||||
&ctx->sx, &ctx->sy);
|
&ctx->sx, &ctx->sy);
|
||||||
|
Reference in New Issue
Block a user