summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2015-08-28 12:25:42 +0000
committernicm <nicm@openbsd.org>2015-08-28 12:25:42 +0000
commitc439b3e0570f492d7b8a912e95afc24414856e46 (patch)
tree05318ae3a090df6dae8228772c3a03b4ba419df1
parentRun status update on a per-client timer at status-interval. (diff)
downloadwireguard-openbsd-c439b3e0570f492d7b8a912e95afc24414856e46.tar.xz
wireguard-openbsd-c439b3e0570f492d7b8a912e95afc24414856e46.zip
Give clock mode its own timer.
-rw-r--r--usr.bin/tmux/server.c11
-rw-r--r--usr.bin/tmux/tmux.h3
-rw-r--r--usr.bin/tmux/window-choose.c3
-rw-r--r--usr.bin/tmux/window-clock.c52
-rw-r--r--usr.bin/tmux/window-copy.c3
5 files changed, 35 insertions, 37 deletions
diff --git a/usr.bin/tmux/server.c b/usr.bin/tmux/server.c
index 743ba68dd19..5056f277e4a 100644
--- a/usr.bin/tmux/server.c
+++ b/usr.bin/tmux/server.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server.c,v 1.131 2015/08/28 12:16:28 nicm Exp $ */
+/* $OpenBSD: server.c,v 1.132 2015/08/28 12:25:42 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -504,8 +504,6 @@ server_child_stopped(pid_t pid, int status)
void
server_second_callback(unused int fd, unused short events, unused void *arg)
{
- struct window *w;
- struct window_pane *wp;
struct timeval tv;
if (options_get_number(&global_s_options, "lock-server"))
@@ -513,13 +511,6 @@ server_second_callback(unused int fd, unused short events, unused void *arg)
else
server_lock_sessions();
- RB_FOREACH(w, windows, &windows) {
- TAILQ_FOREACH(wp, &w->panes, entry) {
- if (wp->mode != NULL && wp->mode->timer != NULL)
- wp->mode->timer(wp);
- }
- }
-
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 89e1872c7dd..af650a3e39c 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.534 2015/08/28 12:16:28 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.535 2015/08/28 12:25:42 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -777,7 +777,6 @@ struct window_mode {
void (*resize)(struct window_pane *, u_int, u_int);
void (*key)(struct window_pane *, struct client *, struct session *,
int, struct mouse_event *);
- void (*timer)(struct window_pane *);
};
/* Structures for choose mode. */
diff --git a/usr.bin/tmux/window-choose.c b/usr.bin/tmux/window-choose.c
index 38141c56796..f5b5e73c7f0 100644
--- a/usr.bin/tmux/window-choose.c
+++ b/usr.bin/tmux/window-choose.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window-choose.c,v 1.65 2015/06/05 18:18:32 nicm Exp $ */
+/* $OpenBSD: window-choose.c,v 1.66 2015/08/28 12:25:42 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -57,7 +57,6 @@ const struct window_mode window_choose_mode = {
window_choose_free,
window_choose_resize,
window_choose_key,
- NULL,
};
struct window_choose_mode_item {
diff --git a/usr.bin/tmux/window-clock.c b/usr.bin/tmux/window-clock.c
index a706d58de05..e1fc58c6702 100644
--- a/usr.bin/tmux/window-clock.c
+++ b/usr.bin/tmux/window-clock.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window-clock.c,v 1.11 2015/04/19 21:34:21 nicm Exp $ */
+/* $OpenBSD: window-clock.c,v 1.12 2015/08/28 12:25:42 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -29,8 +29,8 @@ void window_clock_free(struct window_pane *);
void window_clock_resize(struct window_pane *, u_int, u_int);
void window_clock_key(struct window_pane *, struct client *,
struct session *, int, struct mouse_event *);
-void window_clock_timer(struct window_pane *);
+void window_clock_timer_callback(int, short, void *);
void window_clock_draw_screen(struct window_pane *);
const struct window_mode window_clock_mode = {
@@ -38,12 +38,12 @@ const struct window_mode window_clock_mode = {
window_clock_free,
window_clock_resize,
window_clock_key,
- window_clock_timer,
};
struct window_clock_mode_data {
struct screen screen;
time_t tim;
+ struct event timer;
};
const char window_clock_table[14][5][5] = {
@@ -119,15 +119,42 @@ const char window_clock_table[14][5][5] = {
{ 1,0,0,0,1 } },
};
+void
+window_clock_timer_callback(unused int fd, unused short events, void *arg)
+{
+ struct window_pane *wp = arg;
+ struct window_clock_mode_data *data = wp->modedata;
+ struct tm now, then;
+ time_t t;
+ struct timeval tv = { .tv_sec = 1 };
+
+ evtimer_del(&data->timer);
+ evtimer_add(&data->timer, &tv);
+
+ t = time(NULL);
+ gmtime_r(&t, &now);
+ gmtime_r(&data->tim, &then);
+ if (now.tm_min == then.tm_min)
+ return;
+ data->tim = t;
+
+ window_clock_draw_screen(wp);
+ server_redraw_window(wp->window);
+}
+
struct screen *
window_clock_init(struct window_pane *wp)
{
struct window_clock_mode_data *data;
struct screen *s;
+ struct timeval tv = { .tv_sec = 1 };
wp->modedata = data = xmalloc(sizeof *data);
data->tim = time(NULL);
+ evtimer_set(&data->timer, window_clock_timer_callback, wp);
+ evtimer_add(&data->timer, &tv);
+
s = &data->screen;
screen_init(s, screen_size_x(&wp->base), screen_size_y(&wp->base), 0);
s->mode &= ~MODE_CURSOR;
@@ -142,6 +169,7 @@ window_clock_free(struct window_pane *wp)
{
struct window_clock_mode_data *data = wp->modedata;
+ evtimer_del(&data->timer);
screen_free(&data->screen);
free(data);
}
@@ -164,24 +192,6 @@ window_clock_key(struct window_pane *wp, unused struct client *c,
}
void
-window_clock_timer(struct window_pane *wp)
-{
- struct window_clock_mode_data *data = wp->modedata;
- struct tm now, then;
- time_t t;
-
- t = time(NULL);
- gmtime_r(&t, &now);
- gmtime_r(&data->tim, &then);
- if (now.tm_min == then.tm_min)
- return;
- data->tim = t;
-
- window_clock_draw_screen(wp);
- server_redraw_window(wp->window);
-}
-
-void
window_clock_draw_screen(struct window_pane *wp)
{
struct window_clock_mode_data *data = wp->modedata;
diff --git a/usr.bin/tmux/window-copy.c b/usr.bin/tmux/window-copy.c
index 4adead2819e..7695ce1ca07 100644
--- a/usr.bin/tmux/window-copy.c
+++ b/usr.bin/tmux/window-copy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window-copy.c,v 1.130 2015/04/24 22:19:36 nicm Exp $ */
+/* $OpenBSD: window-copy.c,v 1.131 2015/08/28 12:25:42 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -91,7 +91,6 @@ const struct window_mode window_copy_mode = {
window_copy_free,
window_copy_resize,
window_copy_key,
- NULL,
};
enum window_copy_input_type {