summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2015-08-28 15:51:49 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2015-08-28 15:51:49 +0000
commitdfb48d71786eb399c3c1e45e69d14f2144d90956 (patch)
tree32925066bc63e11597ac886bda7e7039f262b167
parent84718a7067e532e26ebe7e167af4bd83701508fb (diff)
We now only checking for name changes when the active pane has changed,
but that can only happen when we have already been woken up by a read event, so there is no need for a timer, we can just check the changed flag on the end of that read event (we already loop over the windows to check for bells etc anyway).
-rw-r--r--usr.bin/tmux/cmd-set-option.c6
-rw-r--r--usr.bin/tmux/names.c34
-rw-r--r--usr.bin/tmux/server-window.c3
-rw-r--r--usr.bin/tmux/tmux.h5
-rw-r--r--usr.bin/tmux/window.c7
5 files changed, 15 insertions, 40 deletions
diff --git a/usr.bin/tmux/cmd-set-option.c b/usr.bin/tmux/cmd-set-option.c
index aab181187b6..ed50d855979 100644
--- a/usr.bin/tmux/cmd-set-option.c
+++ b/usr.bin/tmux/cmd-set-option.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-set-option.c,v 1.78 2015/08/28 13:12:20 nicm Exp $ */
+/* $OpenBSD: cmd-set-option.c,v 1.79 2015/08/28 15:51:48 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -180,9 +180,7 @@ cmd_set_option_exec(struct cmd *self, struct cmd_q *cmdq)
if (strcmp(oe->name, "automatic-rename") == 0) {
RB_FOREACH(w, windows, &windows) {
if (options_get_number(&w->options, "automatic-rename"))
- queue_window_name(w);
- else if (event_initialized(&w->name_timer))
- evtimer_del(&w->name_timer);
+ w->active->flags |= PANE_CHANGED;
}
}
if (strcmp(oe->name, "status") == 0 ||
diff --git a/usr.bin/tmux/names.c b/usr.bin/tmux/names.c
index 1091d26f83b..c407d1d67a2 100644
--- a/usr.bin/tmux/names.c
+++ b/usr.bin/tmux/names.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: names.c,v 1.26 2015/08/28 13:26:41 nicm Exp $ */
+/* $OpenBSD: names.c,v 1.27 2015/08/28 15:51:48 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -25,37 +25,16 @@
#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
-window_name_callback(unused int fd, unused short events, void *data)
+check_window_name(struct window *w)
{
- struct window *w = data;
- char *name;
+ char *name;
if (w->active == NULL)
return;
- if (!options_get_number(&w->options, "automatic-rename")) {
- if (event_initialized(&w->name_timer))
- event_del(&w->name_timer);
+ if (!options_get_number(&w->options, "automatic-rename"))
return;
- }
- queue_window_name(w);
if (~w->active->flags & PANE_CHANGED)
return;
@@ -63,9 +42,12 @@ window_name_callback(unused int fd, unused short events, void *data)
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);
}
diff --git a/usr.bin/tmux/server-window.c b/usr.bin/tmux/server-window.c
index 825a1176a17..5c9102e2d7d 100644
--- a/usr.bin/tmux/server-window.c
+++ b/usr.bin/tmux/server-window.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server-window.c,v 1.36 2015/08/28 07:55:43 nicm Exp $ */
+/* $OpenBSD: server-window.c,v 1.37 2015/08/28 15:51:48 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -49,6 +49,7 @@ server_window_loop(void)
server_status_session(s);
}
}
+ check_window_name(w);
}
}
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index c7ceaee35ff..781f5fda6a2 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.537 2015/08/28 13:12:20 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.538 2015/08/28 15:51:48 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -870,7 +870,6 @@ RB_HEAD(window_pane_tree, window_pane);
struct window {
u_int id;
char *name;
- struct event name_timer;
struct timeval silence_timer;
struct timeval activity_time;
@@ -2209,7 +2208,7 @@ void window_choose_collapse_all(struct window_pane *);
void window_choose_set_current(struct window_pane *, u_int);
/* names.c */
-void queue_window_name(struct window *);
+void check_window_name(struct window *);
char *default_window_name(struct window *);
char *format_window_name(struct window *);
char *parse_window_name(const char *);
diff --git a/usr.bin/tmux/window.c b/usr.bin/tmux/window.c
index ae0aa6a1921..db1cb28743e 100644
--- a/usr.bin/tmux/window.c
+++ b/usr.bin/tmux/window.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: window.c,v 1.137 2015/08/28 07:55:43 nicm Exp $ */
+/* $OpenBSD: window.c,v 1.138 2015/08/28 15:51:48 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -299,8 +299,6 @@ window_create1(u_int sx, u_int sy)
fatal("gettimeofday failed");
options_init(&w->options, &global_w_options);
- if (options_get_number(&w->options, "automatic-rename"))
- queue_window_name(w);
w->references = 0;
@@ -349,9 +347,6 @@ window_destroy(struct window *w)
layout_free_cell(w->saved_layout_root);
free(w->old_layout);
- if (event_initialized(&w->name_timer))
- evtimer_del(&w->name_timer);
-
options_free(&w->options);
window_destroy_panes(w);