mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 00:56:10 +00:00 
			
		
		
		
	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.
This commit is contained in:
		@@ -180,7 +180,9 @@ 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"))
 | 
			
		||||
				w->active->flags |= PANE_CHANGED;
 | 
			
		||||
				queue_window_name(w);
 | 
			
		||||
			else if (event_initialized(&w->name_timer))
 | 
			
		||||
				evtimer_del(&w->name_timer);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	if (strcmp(oe->name, "status") == 0 ||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										32
									
								
								names.c
									
									
									
									
									
								
							
							
						
						
									
										32
									
								
								names.c
									
									
									
									
									
								
							@@ -25,16 +25,37 @@
 | 
			
		||||
 | 
			
		||||
#include "tmux.h"
 | 
			
		||||
 | 
			
		||||
void	 window_name_callback(unused int, unused short, void *);
 | 
			
		||||
 | 
			
		||||
void
 | 
			
		||||
check_window_name(struct window *w)
 | 
			
		||||
queue_window_name(struct window *w)
 | 
			
		||||
{
 | 
			
		||||
	char	*name;
 | 
			
		||||
	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)
 | 
			
		||||
{
 | 
			
		||||
	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);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -49,7 +49,6 @@ server_window_loop(void)
 | 
			
		||||
					server_status_session(s);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		check_window_name(w);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										3
									
								
								tmux.h
									
									
									
									
									
								
							
							
						
						
									
										3
									
								
								tmux.h
									
									
									
									
									
								
							@@ -870,6 +870,7 @@ 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;
 | 
			
		||||
 | 
			
		||||
@@ -2208,7 +2209,7 @@ void	window_choose_collapse_all(struct window_pane *);
 | 
			
		||||
void	window_choose_set_current(struct window_pane *, u_int);
 | 
			
		||||
 | 
			
		||||
/* names.c */
 | 
			
		||||
void	 check_window_name(struct window *);
 | 
			
		||||
void	 queue_window_name(struct window *);
 | 
			
		||||
char	*default_window_name(struct window *);
 | 
			
		||||
char	*format_window_name(struct window *);
 | 
			
		||||
char	*parse_window_name(const char *);
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										5
									
								
								window.c
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								window.c
									
									
									
									
									
								
							@@ -299,6 +299,8 @@ 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;
 | 
			
		||||
 | 
			
		||||
@@ -347,6 +349,9 @@ 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);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user