Merge branch 'obsd-master'

This commit is contained in:
Thomas Adam 2018-08-19 19:02:40 +01:00
commit 9ecf657703
6 changed files with 65 additions and 77 deletions

View File

@ -344,7 +344,7 @@ screen_redraw_draw_pane_status(struct screen_redraw_ctx *ctx)
} }
/* Update status line and change flags if unchanged. */ /* Update status line and change flags if unchanged. */
void static void
screen_redraw_update(struct client *c) screen_redraw_update(struct client *c)
{ {
struct window *w = c->session->curw->window; struct window *w = c->session->curw->window;
@ -359,7 +359,7 @@ screen_redraw_update(struct client *c)
else else
redraw = status_redraw(c); redraw = status_redraw(c);
if (!redraw) if (!redraw)
c->flags &= ~CLIENT_STATUS; c->flags &= ~CLIENT_REDRAWSTATUS;
if (options_get_number(wo, "pane-border-status") != CELL_STATUS_OFF) { if (options_get_number(wo, "pane-border-status") != CELL_STATUS_OFF) {
redraw = 0; redraw = 0;
@ -368,7 +368,7 @@ screen_redraw_update(struct client *c)
redraw = 1; redraw = 1;
} }
if (redraw) if (redraw)
c->flags |= CLIENT_BORDERS; c->flags |= CLIENT_REDRAWBORDERS;
} }
} }
@ -395,26 +395,24 @@ screen_redraw_set_context(struct client *c, struct screen_redraw_ctx *ctx)
/* Redraw entire screen. */ /* Redraw entire screen. */
void void
screen_redraw_screen(struct client *c, int draw_panes, int draw_status, screen_redraw_screen(struct client *c)
int draw_borders)
{ {
struct screen_redraw_ctx ctx; struct screen_redraw_ctx ctx;
if (c->flags & CLIENT_SUSPENDED) if (c->flags & CLIENT_SUSPENDED)
return; return;
screen_redraw_update(c);
screen_redraw_set_context(c, &ctx); screen_redraw_set_context(c, &ctx);
if (ctx.lines == 0) if (c->flags & (CLIENT_REDRAWWINDOW|CLIENT_REDRAWBORDERS)) {
draw_status = 0; if (ctx.pane_status != CELL_STATUS_OFF)
if (draw_borders)
screen_redraw_draw_borders(&ctx);
if (draw_borders && ctx.pane_status != CELL_STATUS_OFF)
screen_redraw_draw_pane_status(&ctx); screen_redraw_draw_pane_status(&ctx);
if (draw_panes) screen_redraw_draw_borders(&ctx);
}
if (c->flags & CLIENT_REDRAWWINDOW)
screen_redraw_draw_panes(&ctx); screen_redraw_draw_panes(&ctx);
if (draw_status) if (ctx.lines != 0 && (c->flags & CLIENT_REDRAWSTATUS))
screen_redraw_draw_status(&ctx); screen_redraw_draw_status(&ctx);
tty_reset(&c->tty); tty_reset(&c->tty);
} }

View File

@ -1322,7 +1322,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, masked; int needed, flags;
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;
@ -1336,7 +1336,7 @@ server_client_check_redraw(struct client *c)
* end up back here. * end up back here.
*/ */
needed = 0; needed = 0;
if (c->flags & CLIENT_REDRAW) if (c->flags & CLIENT_ALLREDRAWFLAGS)
needed = 1; needed = 1;
else { else {
TAILQ_FOREACH(wp, &c->session->curw->window->panes, entry) { TAILQ_FOREACH(wp, &c->session->curw->window->panes, entry) {
@ -1359,25 +1359,19 @@ server_client_check_redraw(struct client *c)
* We may have got here for a single pane redraw, but force a * We may have got here for a single pane redraw, but force a
* full redraw next time in case other panes have been updated. * full redraw next time in case other panes have been updated.
*/ */
c->flags |= CLIENT_REDRAW; 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);
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); flags = tty->flags & (TTY_BLOCK|TTY_FREEZE|TTY_NOCURSOR);
tty->flags = (tty->flags & ~(TTY_BLOCK|TTY_FREEZE)) | TTY_NOCURSOR; tty->flags = (tty->flags & ~(TTY_BLOCK|TTY_FREEZE)) | TTY_NOCURSOR;
if (c->flags & CLIENT_REDRAW) { if (~c->flags & CLIENT_REDRAWWINDOW) {
tty_update_mode(tty, tty->mode, NULL); /*
screen_redraw_screen(c, 1, 1, 1); * If not redrawing the entire window, check whether each pane
c->flags &= ~(CLIENT_STATUS|CLIENT_BORDERS); * needs to be redrawn.
} else { */
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) {
tty_update_mode(tty, tty->mode, NULL); tty_update_mode(tty, tty->mode, NULL);
@ -1386,21 +1380,16 @@ server_client_check_redraw(struct client *c)
} }
} }
masked = c->flags & (CLIENT_BORDERS|CLIENT_STATUS); if (c->flags & CLIENT_ALLREDRAWFLAGS) {
if (masked != 0) if (options_get_number(s->options, "set-titles"))
tty_update_mode(tty, tty->mode, NULL); server_client_set_title(c);
if (masked == CLIENT_BORDERS) screen_redraw_screen(c);
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);
tty->flags = (tty->flags & ~(TTY_FREEZE|TTY_NOCURSOR)) | flags; tty->flags = (tty->flags & ~(TTY_FREEZE|TTY_NOCURSOR)) | flags;
tty_update_mode(tty, tty->mode, NULL); tty_update_mode(tty, tty->mode, NULL);
c->flags &= ~(CLIENT_REDRAW|CLIENT_BORDERS|CLIENT_STATUS| c->flags &= ~(CLIENT_ALLREDRAWFLAGS|CLIENT_STATUSFORCE);
CLIENT_STATUSFORCE);
if (needed) { if (needed) {
/* /*

View File

@ -33,13 +33,13 @@ static void server_destroy_session_group(struct session *);
void void
server_redraw_client(struct client *c) server_redraw_client(struct client *c)
{ {
c->flags |= CLIENT_REDRAW; c->flags |= CLIENT_ALLREDRAWFLAGS;
} }
void void
server_status_client(struct client *c) server_status_client(struct client *c)
{ {
c->flags |= CLIENT_STATUS; c->flags |= CLIENT_REDRAWSTATUS;
} }
void void
@ -108,7 +108,7 @@ server_redraw_window_borders(struct window *w)
TAILQ_FOREACH(c, &clients, entry) { TAILQ_FOREACH(c, &clients, entry) {
if (c->session != NULL && c->session->curw->window == w) 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; return;
if (c->message_string == NULL && c->prompt_string == NULL) if (c->message_string == NULL && c->prompt_string == NULL)
c->flags |= CLIENT_STATUS; c->flags |= CLIENT_REDRAWSTATUS;
timerclear(&tv); timerclear(&tv);
tv.tv_sec = options_get_number(s->options, "status-interval"); 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->tty.flags |= (TTY_NOCURSOR|TTY_FREEZE);
c->flags |= CLIENT_STATUS; c->flags |= CLIENT_REDRAWSTATUS;
} }
/* Clear status line message. */ /* Clear status line message. */
@ -630,7 +630,7 @@ status_message_clear(struct client *c)
if (c->prompt_string == NULL) if (c->prompt_string == NULL)
c->tty.flags &= ~(TTY_NOCURSOR|TTY_FREEZE); 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); 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) if (~flags & PROMPT_INCREMENTAL)
c->tty.flags |= (TTY_NOCURSOR|TTY_FREEZE); c->tty.flags |= (TTY_NOCURSOR|TTY_FREEZE);
c->flags |= CLIENT_STATUS; c->flags |= CLIENT_REDRAWSTATUS;
if ((flags & PROMPT_INCREMENTAL) && *tmp != '\0') { if ((flags & PROMPT_INCREMENTAL) && *tmp != '\0') {
xasprintf(&cp, "=%s", tmp); xasprintf(&cp, "=%s", tmp);
@ -763,7 +763,7 @@ status_prompt_clear(struct client *c)
c->prompt_buffer = NULL; c->prompt_buffer = NULL;
c->tty.flags &= ~(TTY_NOCURSOR|TTY_FREEZE); 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); 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->prompt_hindex = 0;
c->flags |= CLIENT_STATUS; c->flags |= CLIENT_REDRAWSTATUS;
free(tmp); free(tmp);
format_free(ft); format_free(ft);
@ -938,7 +938,7 @@ status_prompt_translate_key(struct client *c, key_code key, key_code *new_key)
return (1); return (1);
case '\033': /* Escape */ case '\033': /* Escape */
c->prompt_mode = PROMPT_COMMAND; c->prompt_mode = PROMPT_COMMAND;
c->flags |= CLIENT_STATUS; c->flags |= CLIENT_REDRAWSTATUS;
return (0); return (0);
} }
*new_key = key; *new_key = key;
@ -952,17 +952,17 @@ status_prompt_translate_key(struct client *c, key_code key, key_code *new_key)
case 's': case 's':
case 'a': case 'a':
c->prompt_mode = PROMPT_ENTRY; c->prompt_mode = PROMPT_ENTRY;
c->flags |= CLIENT_STATUS; c->flags |= CLIENT_REDRAWSTATUS;
break; /* switch mode and... */ break; /* switch mode and... */
case 'S': case 'S':
c->prompt_mode = PROMPT_ENTRY; c->prompt_mode = PROMPT_ENTRY;
c->flags |= CLIENT_STATUS; c->flags |= CLIENT_REDRAWSTATUS;
*new_key = '\025'; /* C-u */ *new_key = '\025'; /* C-u */
return (1); return (1);
case 'i': case 'i':
case '\033': /* Escape */ case '\033': /* Escape */
c->prompt_mode = PROMPT_ENTRY; c->prompt_mode = PROMPT_ENTRY;
c->flags |= CLIENT_STATUS; c->flags |= CLIENT_REDRAWSTATUS;
return (0); return (0);
} }
@ -1357,7 +1357,7 @@ process_key:
goto append_key; goto append_key;
} }
c->flags |= CLIENT_STATUS; c->flags |= CLIENT_REDRAWSTATUS;
return (0); return (0);
append_key: append_key:
@ -1392,7 +1392,7 @@ append_key:
} }
changed: changed:
c->flags |= CLIENT_STATUS; c->flags |= CLIENT_REDRAWSTATUS;
if (c->prompt_flags & PROMPT_INCREMENTAL) { if (c->prompt_flags & PROMPT_INCREMENTAL) {
s = utf8_tocstr(c->prompt_buffer); s = utf8_tocstr(c->prompt_buffer);
xasprintf(&cp, "%c%s", prefix, s); xasprintf(&cp, "%c%s", prefix, s);

11
tmux.h
View File

@ -1333,14 +1333,14 @@ struct client {
#define CLIENT_TERMINAL 0x1 #define CLIENT_TERMINAL 0x1
#define CLIENT_LOGIN 0x2 #define CLIENT_LOGIN 0x2
#define CLIENT_EXIT 0x4 #define CLIENT_EXIT 0x4
#define CLIENT_REDRAW 0x8 #define CLIENT_REDRAWWINDOW 0x8
#define CLIENT_STATUS 0x10 #define CLIENT_REDRAWSTATUS 0x10
#define CLIENT_REPEAT 0x20 #define CLIENT_REPEAT 0x20
#define CLIENT_SUSPENDED 0x40 #define CLIENT_SUSPENDED 0x40
#define CLIENT_ATTACHED 0x80 #define CLIENT_ATTACHED 0x80
#define CLIENT_IDENTIFY 0x100 #define CLIENT_IDENTIFY 0x100
#define CLIENT_DEAD 0x200 #define CLIENT_DEAD 0x200
#define CLIENT_BORDERS 0x400 #define CLIENT_REDRAWBORDERS 0x400
#define CLIENT_READONLY 0x800 #define CLIENT_READONLY 0x800
#define CLIENT_DETACHING 0x1000 #define CLIENT_DETACHING 0x1000
#define CLIENT_CONTROL 0x2000 #define CLIENT_CONTROL 0x2000
@ -1354,6 +1354,8 @@ struct client {
#define CLIENT_TRIPLECLICK 0x200000 #define CLIENT_TRIPLECLICK 0x200000
#define CLIENT_SIZECHANGED 0x400000 #define CLIENT_SIZECHANGED 0x400000
#define CLIENT_STATUSOFF 0x800000 #define CLIENT_STATUSOFF 0x800000
#define CLIENT_ALLREDRAWFLAGS \
(CLIENT_REDRAWWINDOW|CLIENT_REDRAWSTATUS|CLIENT_REDRAWBORDERS)
int flags; int flags;
struct key_table *keytable; struct key_table *keytable;
@ -2055,8 +2057,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); void screen_write_rawstring(struct screen_write_ctx *, u_char *, u_int);
/* screen-redraw.c */ /* screen-redraw.c */
void screen_redraw_update(struct client *); void screen_redraw_screen(struct client *);
void screen_redraw_screen(struct client *, int, int, int);
void screen_redraw_pane(struct client *, struct window_pane *); void screen_redraw_pane(struct client *, struct window_pane *);
/* screen.c */ /* 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); log_debug("%s: %zu discarded", c->name, tty->discarded);
c->flags |= CLIENT_REDRAW; c->flags |= CLIENT_ALLREDRAWFLAGS;
c->discarded += tty->discarded; c->discarded += tty->discarded;
if (tty->discarded < TTY_BLOCK_STOP(tty)) { 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) if (c->session == NULL || c->tty.term == NULL)
return (0); return (0);
if (c->flags & (CLIENT_REDRAW|CLIENT_SUSPENDED)) if (c->flags & (CLIENT_REDRAWWINDOW|CLIENT_SUSPENDED))
return (0); return (0);
if (c->tty.flags & TTY_FREEZE) if (c->tty.flags & TTY_FREEZE)
return (0); return (0);