Add a client redraw-window flag instead of the redraw-all flag and for

all just use the three flags together (window, borders, status).
This commit is contained in:
nicm 2018-08-19 16:45:03 +00:00
parent bd2896b65e
commit 88327c7698
6 changed files with 65 additions and 77 deletions

View File

@ -318,7 +318,7 @@ screen_redraw_make_pane_status(struct client *c, struct window *w,
static void
screen_redraw_draw_pane_status(struct screen_redraw_ctx *ctx)
{
struct client *c = ctx->c;
struct client *c = ctx->c;
struct window *w = c->session->curw->window;
struct options *oo = c->session->options;
struct tty *tty = &c->tty;
@ -344,7 +344,7 @@ screen_redraw_draw_pane_status(struct screen_redraw_ctx *ctx)
}
/* Update status line and change flags if unchanged. */
void
static void
screen_redraw_update(struct client *c)
{
struct window *w = c->session->curw->window;
@ -359,7 +359,7 @@ screen_redraw_update(struct client *c)
else
redraw = status_redraw(c);
if (!redraw)
c->flags &= ~CLIENT_STATUS;
c->flags &= ~CLIENT_REDRAWSTATUS;
if (options_get_number(wo, "pane-border-status") != CELL_STATUS_OFF) {
redraw = 0;
@ -368,7 +368,7 @@ screen_redraw_update(struct client *c)
redraw = 1;
}
if (redraw)
c->flags |= CLIENT_BORDERS;
c->flags |= CLIENT_REDRAWBORDERS;
}
}
@ -376,10 +376,10 @@ screen_redraw_update(struct client *c)
static void
screen_redraw_set_context(struct client *c, struct screen_redraw_ctx *ctx)
{
struct session *s = c->session;
struct options *oo = s->options;
struct window *w = s->curw->window;
struct options *wo = w->options;
struct session *s = c->session;
struct options *oo = s->options;
struct window *w = s->curw->window;
struct options *wo = w->options;
memset(ctx, 0, sizeof *ctx);
ctx->c = c;
@ -395,26 +395,24 @@ screen_redraw_set_context(struct client *c, struct screen_redraw_ctx *ctx)
/* Redraw entire screen. */
void
screen_redraw_screen(struct client *c, int draw_panes, int draw_status,
int draw_borders)
screen_redraw_screen(struct client *c)
{
struct screen_redraw_ctx ctx;
struct screen_redraw_ctx ctx;
if (c->flags & CLIENT_SUSPENDED)
return;
screen_redraw_update(c);
screen_redraw_set_context(c, &ctx);
if (ctx.lines == 0)
draw_status = 0;
if (draw_borders)
if (c->flags & (CLIENT_REDRAWWINDOW|CLIENT_REDRAWBORDERS)) {
if (ctx.pane_status != CELL_STATUS_OFF)
screen_redraw_draw_pane_status(&ctx);
screen_redraw_draw_borders(&ctx);
if (draw_borders && ctx.pane_status != CELL_STATUS_OFF)
screen_redraw_draw_pane_status(&ctx);
if (draw_panes)
}
if (c->flags & CLIENT_REDRAWWINDOW)
screen_redraw_draw_panes(&ctx);
if (draw_status)
if (ctx.lines != 0 && (c->flags & CLIENT_REDRAWSTATUS))
screen_redraw_draw_status(&ctx);
tty_reset(&c->tty);
}
@ -447,15 +445,15 @@ screen_redraw_draw_borders_cell(struct screen_redraw_ctx *ctx, u_int x, u_int y,
struct grid_cell *active_gc, struct grid_cell *m_other_gc,
struct grid_cell *other_gc)
{
struct client *c = ctx->c;
struct session *s = c->session;
struct window *w = s->curw->window;
struct tty *tty = &c->tty;
struct window_pane *wp;
struct window_pane *active = w->active;
struct window_pane *marked = marked_pane.wp;
u_int type;
int flag, pane_status = ctx->pane_status;
struct client *c = ctx->c;
struct session *s = c->session;
struct window *w = s->curw->window;
struct tty *tty = &c->tty;
struct window_pane *wp;
struct window_pane *active = w->active;
struct window_pane *marked = marked_pane.wp;
u_int type;
int flag, pane_status = ctx->pane_status;
type = screen_redraw_check_cell(c, x, y, pane_status, &wp);
if (type == CELL_INSIDE)
@ -492,7 +490,7 @@ screen_redraw_draw_borders(struct screen_redraw_ctx *ctx)
struct tty *tty = &c->tty;
struct grid_cell m_active_gc, active_gc, m_other_gc, other_gc;
struct grid_cell msg_gc;
u_int i, j, msgx = 0, msgy = 0;
u_int i, j, msgx = 0, msgy = 0;
int small, flags;
char msg[256];
const char *tmp;
@ -558,7 +556,7 @@ screen_redraw_draw_panes(struct screen_redraw_ctx *ctx)
struct window *w = c->session->curw->window;
struct tty *tty = &c->tty;
struct window_pane *wp;
u_int i, y;
u_int i, y;
if (ctx->top)
y = ctx->lines;

View File

@ -1312,7 +1312,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, masked;
int needed, flags;
struct timeval tv = { .tv_usec = 1000 };
static struct event ev;
size_t left;
@ -1326,7 +1326,7 @@ server_client_check_redraw(struct client *c)
* end up back here.
*/
needed = 0;
if (c->flags & CLIENT_REDRAW)
if (c->flags & CLIENT_ALLREDRAWFLAGS)
needed = 1;
else {
TAILQ_FOREACH(wp, &c->session->curw->window->panes, entry) {
@ -1349,25 +1349,19 @@ server_client_check_redraw(struct client *c)
* 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_REDRAW;
c->flags |= CLIENT_ALLREDRAWFLAGS;
return;
} else if (needed)
log_debug("%s: redraw needed", c->name);
if (c->flags & (CLIENT_REDRAW|CLIENT_STATUS)) {
if (options_get_number(s->options, "set-titles"))
server_client_set_title(c);
screen_redraw_update(c); /* will adjust flags */
}
flags = tty->flags & (TTY_BLOCK|TTY_FREEZE|TTY_NOCURSOR);
tty->flags = (tty->flags & ~(TTY_BLOCK|TTY_FREEZE)) | TTY_NOCURSOR;
if (c->flags & CLIENT_REDRAW) {
tty_update_mode(tty, tty->mode, NULL);
screen_redraw_screen(c, 1, 1, 1);
c->flags &= ~(CLIENT_STATUS|CLIENT_BORDERS);
} else {
if (~c->flags & CLIENT_REDRAWWINDOW) {
/*
* If not redrawing the entire window, check whether each pane
* needs to be redrawn.
*/
TAILQ_FOREACH(wp, &c->session->curw->window->panes, entry) {
if (wp->flags & PANE_REDRAW) {
tty_update_mode(tty, tty->mode, NULL);
@ -1376,21 +1370,16 @@ server_client_check_redraw(struct client *c)
}
}
masked = c->flags & (CLIENT_BORDERS|CLIENT_STATUS);
if (masked != 0)
tty_update_mode(tty, tty->mode, NULL);
if (masked == CLIENT_BORDERS)
screen_redraw_screen(c, 0, 0, 1);
else if (masked == CLIENT_STATUS)
screen_redraw_screen(c, 0, 1, 0);
else if (masked != 0)
screen_redraw_screen(c, 0, 1, 1);
if (c->flags & CLIENT_ALLREDRAWFLAGS) {
if (options_get_number(s->options, "set-titles"))
server_client_set_title(c);
screen_redraw_screen(c);
}
tty->flags = (tty->flags & ~(TTY_FREEZE|TTY_NOCURSOR)) | flags;
tty_update_mode(tty, tty->mode, NULL);
c->flags &= ~(CLIENT_REDRAW|CLIENT_BORDERS|CLIENT_STATUS|
CLIENT_STATUSFORCE);
c->flags &= ~(CLIENT_ALLREDRAWFLAGS|CLIENT_STATUSFORCE);
if (needed) {
/*

View File

@ -35,13 +35,13 @@ static void server_destroy_session_group(struct session *);
void
server_redraw_client(struct client *c)
{
c->flags |= CLIENT_REDRAW;
c->flags |= CLIENT_ALLREDRAWFLAGS;
}
void
server_status_client(struct client *c)
{
c->flags |= CLIENT_STATUS;
c->flags |= CLIENT_REDRAWSTATUS;
}
void
@ -110,7 +110,7 @@ server_redraw_window_borders(struct window *w)
TAILQ_FOREACH(c, &clients, entry) {
if (c->session != NULL && c->session->curw->window == w)
c->flags |= CLIENT_BORDERS;
c->flags |= CLIENT_REDRAWBORDERS;
}
}

View File

@ -157,7 +157,7 @@ status_timer_callback(__unused int fd, __unused short events, void *arg)
return;
if (c->message_string == NULL && c->prompt_string == NULL)
c->flags |= CLIENT_STATUS;
c->flags |= CLIENT_REDRAWSTATUS;
timerclear(&tv);
tv.tv_sec = options_get_number(s->options, "status-interval");
@ -615,7 +615,7 @@ status_message_set(struct client *c, const char *fmt, ...)
}
c->tty.flags |= (TTY_NOCURSOR|TTY_FREEZE);
c->flags |= CLIENT_STATUS;
c->flags |= CLIENT_REDRAWSTATUS;
}
/* Clear status line message. */
@ -630,7 +630,7 @@ status_message_clear(struct client *c)
if (c->prompt_string == NULL)
c->tty.flags &= ~(TTY_NOCURSOR|TTY_FREEZE);
c->flags |= CLIENT_REDRAW; /* screen was frozen and may have changed */
c->flags |= CLIENT_ALLREDRAWFLAGS; /* was frozen and may have changed */
screen_reinit(&c->status.status);
}
@ -734,7 +734,7 @@ status_prompt_set(struct client *c, const char *msg, const char *input,
if (~flags & PROMPT_INCREMENTAL)
c->tty.flags |= (TTY_NOCURSOR|TTY_FREEZE);
c->flags |= CLIENT_STATUS;
c->flags |= CLIENT_REDRAWSTATUS;
if ((flags & PROMPT_INCREMENTAL) && *tmp != '\0') {
xasprintf(&cp, "=%s", tmp);
@ -763,7 +763,7 @@ status_prompt_clear(struct client *c)
c->prompt_buffer = NULL;
c->tty.flags &= ~(TTY_NOCURSOR|TTY_FREEZE);
c->flags |= CLIENT_REDRAW; /* screen was frozen and may have changed */
c->flags |= CLIENT_ALLREDRAWFLAGS; /* was frozen and may have changed */
screen_reinit(&c->status.status);
}
@ -791,7 +791,7 @@ status_prompt_update(struct client *c, const char *msg, const char *input)
c->prompt_hindex = 0;
c->flags |= CLIENT_STATUS;
c->flags |= CLIENT_REDRAWSTATUS;
free(tmp);
format_free(ft);
@ -938,7 +938,7 @@ status_prompt_translate_key(struct client *c, key_code key, key_code *new_key)
return (1);
case '\033': /* Escape */
c->prompt_mode = PROMPT_COMMAND;
c->flags |= CLIENT_STATUS;
c->flags |= CLIENT_REDRAWSTATUS;
return (0);
}
*new_key = key;
@ -952,17 +952,17 @@ status_prompt_translate_key(struct client *c, key_code key, key_code *new_key)
case 's':
case 'a':
c->prompt_mode = PROMPT_ENTRY;
c->flags |= CLIENT_STATUS;
c->flags |= CLIENT_REDRAWSTATUS;
break; /* switch mode and... */
case 'S':
c->prompt_mode = PROMPT_ENTRY;
c->flags |= CLIENT_STATUS;
c->flags |= CLIENT_REDRAWSTATUS;
*new_key = '\025'; /* C-u */
return (1);
case 'i':
case '\033': /* Escape */
c->prompt_mode = PROMPT_ENTRY;
c->flags |= CLIENT_STATUS;
c->flags |= CLIENT_REDRAWSTATUS;
return (0);
}
@ -1357,7 +1357,7 @@ process_key:
goto append_key;
}
c->flags |= CLIENT_STATUS;
c->flags |= CLIENT_REDRAWSTATUS;
return (0);
append_key:
@ -1392,7 +1392,7 @@ append_key:
}
changed:
c->flags |= CLIENT_STATUS;
c->flags |= CLIENT_REDRAWSTATUS;
if (c->prompt_flags & PROMPT_INCREMENTAL) {
s = utf8_tocstr(c->prompt_buffer);
xasprintf(&cp, "%c%s", prefix, s);

11
tmux.h
View File

@ -1329,14 +1329,14 @@ struct client {
#define CLIENT_TERMINAL 0x1
#define CLIENT_LOGIN 0x2
#define CLIENT_EXIT 0x4
#define CLIENT_REDRAW 0x8
#define CLIENT_STATUS 0x10
#define CLIENT_REDRAWWINDOW 0x8
#define CLIENT_REDRAWSTATUS 0x10
#define CLIENT_REPEAT 0x20
#define CLIENT_SUSPENDED 0x40
#define CLIENT_ATTACHED 0x80
#define CLIENT_IDENTIFY 0x100
#define CLIENT_DEAD 0x200
#define CLIENT_BORDERS 0x400
#define CLIENT_REDRAWBORDERS 0x400
#define CLIENT_READONLY 0x800
#define CLIENT_DETACHING 0x1000
#define CLIENT_CONTROL 0x2000
@ -1350,6 +1350,8 @@ struct client {
#define CLIENT_TRIPLECLICK 0x200000
#define CLIENT_SIZECHANGED 0x400000
#define CLIENT_STATUSOFF 0x800000
#define CLIENT_ALLREDRAWFLAGS \
(CLIENT_REDRAWWINDOW|CLIENT_REDRAWSTATUS|CLIENT_REDRAWBORDERS)
int flags;
struct key_table *keytable;
@ -2051,8 +2053,7 @@ void screen_write_setselection(struct screen_write_ctx *, u_char *, u_int);
void screen_write_rawstring(struct screen_write_ctx *, u_char *, u_int);
/* screen-redraw.c */
void screen_redraw_update(struct client *);
void screen_redraw_screen(struct client *, int, int, int);
void screen_redraw_screen(struct client *);
void screen_redraw_pane(struct client *, struct window_pane *);
/* screen.c */

4
tty.c
View File

@ -179,7 +179,7 @@ tty_timer_callback(__unused int fd, __unused short events, void *data)
log_debug("%s: %zu discarded", c->name, tty->discarded);
c->flags |= CLIENT_REDRAW;
c->flags |= CLIENT_ALLREDRAWFLAGS;
c->discarded += tty->discarded;
if (tty->discarded < TTY_BLOCK_STOP(tty)) {
@ -1049,7 +1049,7 @@ tty_client_ready(struct client *c, struct window_pane *wp)
{
if (c->session == NULL || c->tty.term == NULL)
return (0);
if (c->flags & (CLIENT_REDRAW|CLIENT_SUSPENDED))
if (c->flags & (CLIENT_REDRAWWINDOW|CLIENT_SUSPENDED))
return (0);
if (c->tty.flags & TTY_FREEZE)
return (0);