mirror of
https://github.com/tmate-io/tmate.git
synced 2025-01-11 08:28:29 +01:00
Be more conservative about redrawing using flags.
This commit is contained in:
parent
6f7d59d279
commit
77224aaf8b
57
server-fn.c
57
server-fn.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: server-fn.c,v 1.38 2008-06-03 21:42:37 nicm Exp $ */
|
/* $Id: server-fn.c,v 1.39 2008-06-07 06:47:38 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -48,7 +48,9 @@ server_write_session(
|
|||||||
|
|
||||||
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||||
c = ARRAY_ITEM(&clients, i);
|
c = ARRAY_ITEM(&clients, i);
|
||||||
if (c != NULL && c->session == s)
|
if (c == NULL || c->session == NULL)
|
||||||
|
continue;
|
||||||
|
if (c->session == s)
|
||||||
server_write_client(c, type, buf, len);
|
server_write_client(c, type, buf, len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -85,19 +87,13 @@ server_clear_client(struct client *c)
|
|||||||
void
|
void
|
||||||
server_redraw_client(struct client *c)
|
server_redraw_client(struct client *c)
|
||||||
{
|
{
|
||||||
struct screen_redraw_ctx ctx;
|
c->flags |= CLIENT_REDRAW;
|
||||||
|
|
||||||
screen_redraw_start_client(&ctx, c);
|
|
||||||
screen_redraw_lines(&ctx, 0, screen_size_y(ctx.s));
|
|
||||||
screen_redraw_stop(&ctx);
|
|
||||||
|
|
||||||
status_write_client(c);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
server_status_client(struct client *c)
|
server_status_client(struct client *c)
|
||||||
{
|
{
|
||||||
status_write_client(c);
|
c->flags |= CLIENT_STATUS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -116,19 +112,31 @@ server_clear_session(struct session *s)
|
|||||||
void
|
void
|
||||||
server_redraw_session(struct session *s)
|
server_redraw_session(struct session *s)
|
||||||
{
|
{
|
||||||
struct screen_redraw_ctx ctx;
|
struct client *c;
|
||||||
|
u_int i;
|
||||||
|
|
||||||
screen_redraw_start_session(&ctx, s);
|
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||||
screen_redraw_lines(&ctx, 0, screen_size_y(ctx.s));
|
c = ARRAY_ITEM(&clients, i);
|
||||||
screen_redraw_stop(&ctx);
|
if (c == NULL || c->session == NULL)
|
||||||
|
continue;
|
||||||
status_write_session(s);
|
if (c->session == s)
|
||||||
|
server_redraw_client(c);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
server_status_session(struct session *s)
|
server_status_session(struct session *s)
|
||||||
{
|
{
|
||||||
status_write_session(s);
|
struct client *c;
|
||||||
|
u_int i;
|
||||||
|
|
||||||
|
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||||
|
c = ARRAY_ITEM(&clients, i);
|
||||||
|
if (c == NULL || c->session == NULL)
|
||||||
|
continue;
|
||||||
|
if (c->session == s)
|
||||||
|
server_status_client(c);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -147,13 +155,16 @@ server_clear_window(struct window *w)
|
|||||||
void
|
void
|
||||||
server_redraw_window(struct window *w)
|
server_redraw_window(struct window *w)
|
||||||
{
|
{
|
||||||
struct screen_redraw_ctx ctx;
|
struct client *c;
|
||||||
|
u_int i;
|
||||||
|
|
||||||
screen_redraw_start_window(&ctx, w);
|
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||||
screen_redraw_lines(&ctx, 0, screen_size_y(ctx.s));
|
c = ARRAY_ITEM(&clients, i);
|
||||||
screen_redraw_stop(&ctx);
|
if (c == NULL || c->session == NULL)
|
||||||
|
continue;
|
||||||
status_write_window(w);
|
if (c->session->curw->window == w)
|
||||||
|
server_redraw_client(c);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
33
server.c
33
server.c
@ -1,4 +1,4 @@
|
|||||||
/* $Id: server.c,v 1.56 2008-06-07 06:13:21 nicm Exp $ */
|
/* $Id: server.c,v 1.57 2008-06-07 06:47:38 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -54,6 +54,7 @@ void server_handle_client(struct client *);
|
|||||||
void server_handle_window(struct window *);
|
void server_handle_window(struct window *);
|
||||||
void server_lost_client(struct client *);
|
void server_lost_client(struct client *);
|
||||||
void server_lost_window(struct window *);
|
void server_lost_window(struct window *);
|
||||||
|
void server_check_redraw(struct client *);
|
||||||
void server_check_status(struct client *);
|
void server_check_status(struct client *);
|
||||||
|
|
||||||
/* Fork new server. */
|
/* Fork new server. */
|
||||||
@ -269,6 +270,26 @@ server_handle_windows(struct pollfd **pfd)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check for general redraw on client. */
|
||||||
|
void
|
||||||
|
server_check_redraw(struct client *c)
|
||||||
|
{
|
||||||
|
struct screen_redraw_ctx ctx;
|
||||||
|
|
||||||
|
if (c == NULL || c->session == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (c->flags & CLIENT_REDRAW) {
|
||||||
|
screen_redraw_start_client(&ctx, c);
|
||||||
|
screen_redraw_lines(&ctx, 0, screen_size_y(ctx.s));
|
||||||
|
screen_redraw_stop(&ctx);
|
||||||
|
status_write_client(c);
|
||||||
|
} else if (c->flags & CLIENT_STATUS)
|
||||||
|
status_write_client(c);
|
||||||
|
|
||||||
|
c->flags &= ~(CLIENT_REDRAW|CLIENT_STATUS);
|
||||||
|
}
|
||||||
|
|
||||||
/* Check for status line redraw on client. */
|
/* Check for status line redraw on client. */
|
||||||
void
|
void
|
||||||
server_check_status(struct client *c)
|
server_check_status(struct client *c)
|
||||||
@ -276,8 +297,9 @@ server_check_status(struct client *c)
|
|||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
u_int nlines, interval;
|
u_int nlines, interval;
|
||||||
|
|
||||||
if (c->session == NULL)
|
if (c == NULL || c->session == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
nlines = options_get_number(&c->session->options, "status-lines");
|
nlines = options_get_number(&c->session->options, "status-lines");
|
||||||
interval = options_get_number(&c->session->options, "status-interval");
|
interval = options_get_number(&c->session->options, "status-interval");
|
||||||
if (nlines == 0 || interval == 0)
|
if (nlines == 0 || interval == 0)
|
||||||
@ -288,7 +310,7 @@ server_check_status(struct client *c)
|
|||||||
ts.tv_sec -= interval;
|
ts.tv_sec -= interval;
|
||||||
|
|
||||||
if (timespeccmp(&c->status_ts, &ts, <))
|
if (timespeccmp(&c->status_ts, &ts, <))
|
||||||
server_status_client(c);
|
c->flags |= CLIENT_STATUS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fill client pollfds. */
|
/* Fill client pollfds. */
|
||||||
@ -301,6 +323,9 @@ server_fill_clients(struct pollfd **pfd)
|
|||||||
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||||
c = ARRAY_ITEM(&clients, i);
|
c = ARRAY_ITEM(&clients, i);
|
||||||
|
|
||||||
|
server_check_redraw(c);
|
||||||
|
server_check_status(c);
|
||||||
|
|
||||||
if (c == NULL)
|
if (c == NULL)
|
||||||
(*pfd)->fd = -1;
|
(*pfd)->fd = -1;
|
||||||
else {
|
else {
|
||||||
@ -336,8 +361,6 @@ server_handle_clients(struct pollfd **pfd)
|
|||||||
c = ARRAY_ITEM(&clients, i);
|
c = ARRAY_ITEM(&clients, i);
|
||||||
|
|
||||||
if (c != NULL) {
|
if (c != NULL) {
|
||||||
server_check_status(c);
|
|
||||||
|
|
||||||
log_debug("testing client %d (%d)", (*pfd)->fd, c->fd);
|
log_debug("testing client %d (%d)", (*pfd)->fd, c->fd);
|
||||||
if (buffer_poll(*pfd, c->in, c->out) != 0) {
|
if (buffer_poll(*pfd, c->in, c->out) != 0) {
|
||||||
server_lost_client(c);
|
server_lost_client(c);
|
||||||
|
4
tmux.h
4
tmux.h
@ -1,4 +1,4 @@
|
|||||||
/* $Id: tmux.h,v 1.136 2008-06-06 20:02:27 nicm Exp $ */
|
/* $Id: tmux.h,v 1.137 2008-06-07 06:47:38 nicm Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
|
||||||
@ -649,6 +649,8 @@ struct client {
|
|||||||
#define CLIENT_TERMINAL 0x1
|
#define CLIENT_TERMINAL 0x1
|
||||||
#define CLIENT_PREFIX 0x2
|
#define CLIENT_PREFIX 0x2
|
||||||
#define CLIENT_MOUSE 0x4
|
#define CLIENT_MOUSE 0x4
|
||||||
|
#define CLIENT_REDRAW 0x8
|
||||||
|
#define CLIENT_STATUS 0x10
|
||||||
int flags;
|
int flags;
|
||||||
|
|
||||||
struct session *session;
|
struct session *session;
|
||||||
|
Loading…
Reference in New Issue
Block a user