mirror of
https://github.com/tmux/tmux.git
synced 2024-12-13 10:08:47 +00:00
Move status timer check into the global once-per-second timer, this could maybe
be done better but one every second is better than once every 50 ms.
This commit is contained in:
parent
b1264a7416
commit
946ed97273
@ -30,7 +30,6 @@
|
|||||||
void server_client_handle_data(struct client *);
|
void server_client_handle_data(struct client *);
|
||||||
void server_client_check_redraw(struct client *);
|
void server_client_check_redraw(struct client *);
|
||||||
void server_client_set_title(struct client *);
|
void server_client_set_title(struct client *);
|
||||||
void server_client_check_timers(struct client *);
|
|
||||||
|
|
||||||
int server_client_msg_dispatch(struct client *);
|
int server_client_msg_dispatch(struct client *);
|
||||||
void server_client_msg_command(struct client *, struct msg_command_data *);
|
void server_client_msg_command(struct client *, struct msg_command_data *);
|
||||||
@ -184,6 +183,45 @@ client_lost:
|
|||||||
server_client_lost(c);
|
server_client_lost(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Handle client status timer. */
|
||||||
|
void
|
||||||
|
server_client_status_timer(void)
|
||||||
|
{
|
||||||
|
struct client *c;
|
||||||
|
struct session *s;
|
||||||
|
struct job *job;
|
||||||
|
struct timeval tv;
|
||||||
|
u_int i, interval;
|
||||||
|
|
||||||
|
if (gettimeofday(&tv, NULL) != 0)
|
||||||
|
fatal("gettimeofday failed");
|
||||||
|
|
||||||
|
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
|
||||||
|
c = ARRAY_ITEM(&clients, i);
|
||||||
|
if (c == NULL || c->session == NULL)
|
||||||
|
continue;
|
||||||
|
if (c->message_string != NULL || c->prompt_string != NULL) {
|
||||||
|
/*
|
||||||
|
* Don't need timed redraw for messages/prompts so bail
|
||||||
|
* now. The status timer isn't reset when they are
|
||||||
|
* redrawn anyway.
|
||||||
|
*/
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
s = c->session;
|
||||||
|
|
||||||
|
if (!options_get_number(&s->options, "status"))
|
||||||
|
continue;
|
||||||
|
interval = options_get_number(&s->options, "status-interval");
|
||||||
|
|
||||||
|
if (tv.tv_sec - c->status_timer.tv_sec >= interval) {
|
||||||
|
RB_FOREACH(job, jobs, &c->status_jobs)
|
||||||
|
job_run(job);
|
||||||
|
c->flags |= CLIENT_STATUS;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Client functions that need to happen every loop. */
|
/* Client functions that need to happen every loop. */
|
||||||
void
|
void
|
||||||
server_client_loop(void)
|
server_client_loop(void)
|
||||||
@ -199,11 +237,9 @@ server_client_loop(void)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
server_client_handle_data(c);
|
server_client_handle_data(c);
|
||||||
if (c->session != NULL) {
|
if (c->session != NULL)
|
||||||
server_client_check_timers(c);
|
|
||||||
server_client_check_redraw(c);
|
server_client_check_redraw(c);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Any windows will have been redrawn as part of clients, so clear
|
* Any windows will have been redrawn as part of clients, so clear
|
||||||
@ -439,42 +475,6 @@ server_client_set_title(struct client *c)
|
|||||||
xfree(title);
|
xfree(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check client timers. */
|
|
||||||
void
|
|
||||||
server_client_check_timers(struct client *c)
|
|
||||||
{
|
|
||||||
struct session *s = c->session;
|
|
||||||
struct job *job;
|
|
||||||
struct timeval tv;
|
|
||||||
u_int interval;
|
|
||||||
|
|
||||||
if (gettimeofday(&tv, NULL) != 0)
|
|
||||||
fatal("gettimeofday failed");
|
|
||||||
|
|
||||||
if (c->message_string != NULL || c->prompt_string != NULL) {
|
|
||||||
/*
|
|
||||||
* Don't need timed redraw for messages/prompts so bail now.
|
|
||||||
* The status timer isn't reset when they are redrawn anyway.
|
|
||||||
*/
|
|
||||||
return;
|
|
||||||
|
|
||||||
}
|
|
||||||
if (!options_get_number(&s->options, "status"))
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* Check timer; resolution is only a second so don't be too clever. */
|
|
||||||
interval = options_get_number(&s->options, "status-interval");
|
|
||||||
if (interval == 0)
|
|
||||||
return;
|
|
||||||
if (tv.tv_sec < c->status_timer.tv_sec ||
|
|
||||||
((u_int) tv.tv_sec) - c->status_timer.tv_sec >= interval) {
|
|
||||||
/* Run the jobs for this client and schedule for redraw. */
|
|
||||||
RB_FOREACH(job, jobs, &c->status_jobs)
|
|
||||||
job_run(job);
|
|
||||||
c->flags |= CLIENT_STATUS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Dispatch message from client. */
|
/* Dispatch message from client. */
|
||||||
int
|
int
|
||||||
server_client_msg_dispatch(struct client *c)
|
server_client_msg_dispatch(struct client *c)
|
||||||
|
2
server.c
2
server.c
@ -520,6 +520,8 @@ server_second_callback(unused int fd, unused short events, unused void *arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
server_client_status_timer();
|
||||||
|
|
||||||
evtimer_del(&server_ev_second);
|
evtimer_del(&server_ev_second);
|
||||||
memset(&tv, 0, sizeof tv);
|
memset(&tv, 0, sizeof tv);
|
||||||
tv.tv_sec = 1;
|
tv.tv_sec = 1;
|
||||||
|
1
tmux.h
1
tmux.h
@ -1565,6 +1565,7 @@ void server_signal_clear(void);
|
|||||||
void server_client_create(int);
|
void server_client_create(int);
|
||||||
void server_client_lost(struct client *);
|
void server_client_lost(struct client *);
|
||||||
void server_client_callback(int, short, void *);
|
void server_client_callback(int, short, void *);
|
||||||
|
void server_client_status_timer(void);
|
||||||
void server_client_loop(void);
|
void server_client_loop(void);
|
||||||
|
|
||||||
/* server-window.c */
|
/* server-window.c */
|
||||||
|
Loading…
Reference in New Issue
Block a user