diff options
author | 2015-08-28 16:10:46 +0000 | |
---|---|---|
committer | 2015-08-28 16:10:46 +0000 | |
commit | f5015e681a1eecd3b0661a8df7c9584184871bb9 (patch) | |
tree | a7781d61e1d97b2dc8534d118c034663fdff424e /usr.bin/tmux/names.c | |
parent | We now only checking for name changes when the active pane has changed, (diff) | |
download | wireguard-openbsd-f5015e681a1eecd3b0661a8df7c9584184871bb9.tar.xz wireguard-openbsd-f5015e681a1eecd3b0661a8df7c9584184871bb9.zip |
Revert previous; we do need a timer, until I have a better idea. We
can't do the name check every loop, because that is too expensive, and
we can't make sure it only happens infrequently because we have no idea
when the next change will happen.
Diffstat (limited to 'usr.bin/tmux/names.c')
-rw-r--r-- | usr.bin/tmux/names.c | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/usr.bin/tmux/names.c b/usr.bin/tmux/names.c index c407d1d67a2..8491adf5da1 100644 --- a/usr.bin/tmux/names.c +++ b/usr.bin/tmux/names.c @@ -1,4 +1,4 @@ -/* $OpenBSD: names.c,v 1.27 2015/08/28 15:51:48 nicm Exp $ */ +/* $OpenBSD: names.c,v 1.28 2015/08/28 16:10:46 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -25,16 +25,37 @@ #include "tmux.h" +void window_name_callback(unused int, unused short, void *); + +void +queue_window_name(struct window *w) +{ + struct timeval tv; + + tv.tv_sec = 0; + tv.tv_usec = NAME_INTERVAL * 1000L; + + if (event_initialized(&w->name_timer)) + evtimer_del(&w->name_timer); + evtimer_set(&w->name_timer, window_name_callback, w); + evtimer_add(&w->name_timer, &tv); +} + void -check_window_name(struct window *w) +window_name_callback(unused int fd, unused short events, void *data) { - char *name; + struct window *w = data; + char *name; if (w->active == NULL) return; - if (!options_get_number(&w->options, "automatic-rename")) + if (!options_get_number(&w->options, "automatic-rename")) { + if (event_initialized(&w->name_timer)) + event_del(&w->name_timer); return; + } + queue_window_name(w); if (~w->active->flags & PANE_CHANGED) return; @@ -42,12 +63,9 @@ check_window_name(struct window *w) name = format_window_name(w); if (strcmp(name, w->name) != 0) { - log_debug("@%u new name %s (was %s)", w->id, name, w->name); window_set_name(w, name); server_status_window(w); - } else - log_debug("@%u name not changed (still %s)", w->id, w->name); - + } free(name); } |