=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/status.c,v retrieving revision 1.132 retrieving revision 1.133 diff -c -r1.132 -r1.133 *** src/usr.bin/tmux/status.c 2015/07/29 11:56:02 1.132 --- src/usr.bin/tmux/status.c 2015/08/28 12:16:28 1.133 *************** *** 1,4 **** ! /* $OpenBSD: status.c,v 1.132 2015/07/29 11:56:02 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: status.c,v 1.133 2015/08/28 12:16:28 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 37,42 **** --- 37,43 ---- struct grid_cell *); char *status_replace(struct client *, struct winlink *, const char *, time_t); void status_message_callback(int, short, void *); + void status_timer_callback(int, short, void *); const char *status_prompt_up_history(u_int *); const char *status_prompt_down_history(u_int *); *************** *** 142,147 **** --- 143,197 ---- } + /* Status timer callback. */ + void + status_timer_callback(unused int fd, unused short events, void *arg) + { + struct client *c = arg; + struct session *s = c->session; + struct timeval tv; + + evtimer_del(&c->status_timer); + + if (s == NULL) + return; + + if (c->message_string == NULL && c->prompt_string == NULL) + c->flags |= CLIENT_STATUS; + + timerclear(&tv); + tv.tv_sec = options_get_number(&s->options, "status-interval"); + + if (tv.tv_sec != 0) + evtimer_add(&c->status_timer, &tv); + log_debug("client %d, status interval %d", c->ibuf.fd, (int)tv.tv_sec); + } + + /* Start status timer for client. */ + void + status_timer_start(struct client *c) + { + struct session *s = c->session; + + if (event_initialized(&c->status_timer)) + evtimer_del(&c->status_timer); + else + evtimer_set(&c->status_timer, status_timer_callback, c); + + if (s != NULL && options_get_number(&s->options, "status")) + status_timer_callback(-1, 0, c); + } + + /* Start status timer for all clients. */ + void + status_timer_start_all(void) + { + struct client *c; + + TAILQ_FOREACH(c, &clients, entry) + status_timer_start(c); + } + /* Get screen line of status line. -1 means off. */ int status_at_line(struct client *c) *************** *** 244,253 **** left = right = NULL; larrow = rarrow = 0; ! /* Update status timer. */ ! if (gettimeofday(&c->status_timer, NULL) != 0) ! fatal("gettimeofday failed"); ! t = c->status_timer.tv_sec; /* Set up default colour. */ style_apply(&stdgc, &s->options, "status-style"); --- 294,301 ---- left = right = NULL; larrow = rarrow = 0; ! /* Store current time. */ ! t = time(NULL); /* Set up default colour. */ style_apply(&stdgc, &s->options, "status-style");