diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-11-04 23:42:52 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-11-04 23:42:52 +0000 |
commit | d139043c80e30af1d1336dda9a15bd8e3d52306e (patch) | |
tree | c99041e278cabb5ad070be3c758cb0d4b12c6d40 /usr.bin/tmux | |
parent | 19daa3940ff1a5efcad8306ad6ecda6d708dbd4e (diff) |
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.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r-- | usr.bin/tmux/server-client.c | 82 | ||||
-rw-r--r-- | usr.bin/tmux/server.c | 4 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 3 |
3 files changed, 46 insertions, 43 deletions
diff --git a/usr.bin/tmux/server-client.c b/usr.bin/tmux/server-client.c index 6db511bf4e7..5353c5e4cae 100644 --- a/usr.bin/tmux/server-client.c +++ b/usr.bin/tmux/server-client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server-client.c,v 1.15 2009/11/04 23:29:42 nicm Exp $ */ +/* $OpenBSD: server-client.c,v 1.16 2009/11/04 23:42:51 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -30,7 +30,6 @@ void server_client_handle_data(struct client *); void server_client_check_redraw(struct client *); void server_client_set_title(struct client *); -void server_client_check_timers(struct client *); int server_client_msg_dispatch(struct client *); void server_client_msg_command(struct client *, struct msg_command_data *); @@ -184,6 +183,45 @@ client_lost: 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. */ void server_client_loop(void) @@ -199,10 +237,8 @@ server_client_loop(void) continue; server_client_handle_data(c); - if (c->session != NULL) { - server_client_check_timers(c); + if (c->session != NULL) server_client_check_redraw(c); - } } /* @@ -439,42 +475,6 @@ server_client_set_title(struct client *c) 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. */ int server_client_msg_dispatch(struct client *c) diff --git a/usr.bin/tmux/server.c b/usr.bin/tmux/server.c index e8c0b7dd0fa..7a1fb83b05e 100644 --- a/usr.bin/tmux/server.c +++ b/usr.bin/tmux/server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server.c,v 1.71 2009/11/04 23:12:43 nicm Exp $ */ +/* $OpenBSD: server.c,v 1.72 2009/11/04 23:42:51 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -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); memset(&tv, 0, sizeof tv); tv.tv_sec = 1; diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 3484032022d..2250bd6251a 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.166 2009/11/04 23:29:42 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.167 2009/11/04 23:42:51 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -1565,6 +1565,7 @@ void server_signal_clear(void); void server_client_create(int); void server_client_lost(struct client *); void server_client_callback(int, short, void *); +void server_client_status_timer(void); void server_client_loop(void); /* server-window.c */ |