summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2009-11-04 23:29:42 +0000
committerNicholas Marriott <nicm@openbsd.org>2009-11-04 23:29:42 +0000
commitb1264a7416789dad8fad1b4b00a63f99b1ca25e5 (patch)
treedf5e1caa4db6713325be59dc06ff33da4008a6a2
parentb3c4956efeb62bae3c9ac64eab2371bb6384623a (diff)
Use timeout events for the identify and message timers.
-rw-r--r--server-client.c9
-rw-r--r--server-fn.c18
-rw-r--r--status.c17
-rw-r--r--tmux.h4
4 files changed, 32 insertions, 16 deletions
diff --git a/server-client.c b/server-client.c
index 2d5701f5..ec243300 100644
--- a/server-client.c
+++ b/server-client.c
@@ -120,8 +120,11 @@ server_client_lost(struct client *c)
if (c->title != NULL)
xfree(c->title);
+ evtimer_del(&c->identify_timer);
+
if (c->message_string != NULL)
xfree(c->message_string);
+ evtimer_del(&c->message_timer);
if (c->prompt_string != NULL)
xfree(c->prompt_string);
@@ -448,12 +451,6 @@ server_client_check_timers(struct client *c)
if (gettimeofday(&tv, NULL) != 0)
fatal("gettimeofday failed");
- if (c->flags & CLIENT_IDENTIFY && timercmp(&tv, &c->identify_timer, >))
- server_clear_identify(c);
-
- if (c->message_string != NULL && timercmp(&tv, &c->message_timer, >))
- status_message_clear(c);
-
if (c->message_string != NULL || c->prompt_string != NULL) {
/*
* Don't need timed redraw for messages/prompts so bail now.
diff --git a/server-fn.c b/server-fn.c
index 66845b91..f31e1337 100644
--- a/server-fn.c
+++ b/server-fn.c
@@ -24,6 +24,8 @@
#include "tmux.h"
+void server_callback_identify(int, short, void *);
+
void
server_fill_environ(struct session *s, struct environ *env)
{
@@ -353,10 +355,10 @@ server_set_identify(struct client *c)
delay = options_get_number(&c->session->options, "display-panes-time");
tv.tv_sec = delay / 1000;
tv.tv_usec = (delay % 1000) * 1000L;
-
- if (gettimeofday(&c->identify_timer, NULL) != 0)
- fatal("gettimeofday failed");
- timeradd(&c->identify_timer, &tv, &c->identify_timer);
+
+ evtimer_del(&c->identify_timer);
+ evtimer_set(&c->identify_timer, server_callback_identify, c);
+ evtimer_add(&c->identify_timer, &tv);
c->flags |= CLIENT_IDENTIFY;
c->tty.flags |= (TTY_FREEZE|TTY_NOCURSOR);
@@ -374,6 +376,14 @@ server_clear_identify(struct client *c)
}
void
+server_callback_identify(unused int fd, unused short events, void *data)
+{
+ struct client *c = data;
+
+ server_clear_identify(c);
+}
+
+void
server_update_event(struct client *c)
{
short events;
diff --git a/status.c b/status.c
index 4b0c81fb..deb3a621 100644
--- a/status.c
+++ b/status.c
@@ -33,6 +33,7 @@ char *status_job(struct client *, char **);
void status_job_callback(struct job *);
size_t status_width(struct winlink *);
char *status_print(struct session *, struct winlink *, struct grid_cell *);
+void status_message_callback(int, short, void *);
void status_prompt_add_history(struct client *);
char *status_prompt_complete(const char *);
@@ -579,10 +580,10 @@ status_message_set(struct client *c, const char *fmt, ...)
delay = options_get_number(&c->session->options, "display-time");
tv.tv_sec = delay / 1000;
tv.tv_usec = (delay % 1000) * 1000L;
-
- if (gettimeofday(&c->message_timer, NULL) != 0)
- fatal("gettimeofday failed");
- timeradd(&c->message_timer, &tv, &c->message_timer);
+
+ evtimer_del(&c->message_timer);
+ evtimer_set(&c->message_timer, status_message_callback, c);
+ evtimer_add(&c->message_timer, &tv);
c->tty.flags |= (TTY_NOCURSOR|TTY_FREEZE);
c->flags |= CLIENT_STATUS;
@@ -603,6 +604,14 @@ status_message_clear(struct client *c)
screen_reinit(&c->status);
}
+void
+status_message_callback(unused int fd, unused short event, void *data)
+{
+ struct client *c = data;
+
+ status_message_clear(c);
+}
+
/* Draw client message on status line of present else on last line. */
int
status_message_redraw(struct client *c)
diff --git a/tmux.h b/tmux.h
index 4603af4d..d33cb634 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1074,10 +1074,10 @@ struct client {
#define CLIENT_DEAD 0x200
int flags;
- struct timeval identify_timer;
+ struct event identify_timer;
char *message_string;
- struct timeval message_timer;
+ struct event message_timer;
char *prompt_string;
char *prompt_buffer;