mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-03 16:46:18 +00:00 
			
		
		
		
	Make server exit when last session dies. Also fix window check for status activity redraw.
This commit is contained in:
		
							
								
								
									
										7
									
								
								CHANGES
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								CHANGES
									
									
									
									
									
								
							@@ -1,3 +1,8 @@
 | 
				
			|||||||
 | 
					06 June 2008
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					* The server now exits when no sessions remain.
 | 
				
			||||||
 | 
					* Fix bug with inserting characters with TERM=xterm-color.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
05 June 2008
 | 
					05 June 2008
 | 
				
			||||||
 | 
					
 | 
				
			||||||
* Completely reorganise command parsing. Much more common code in cmd-generic.c
 | 
					* Completely reorganise command parsing. Much more common code in cmd-generic.c
 | 
				
			||||||
@@ -440,4 +445,4 @@
 | 
				
			|||||||
  (including mutt, emacs). No status bar yet and no key remapping or other
 | 
					  (including mutt, emacs). No status bar yet and no key remapping or other
 | 
				
			||||||
  customisation.
 | 
					  customisation.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$Id: CHANGES,v 1.113 2008-06-05 23:17:03 nicm Exp $
 | 
					$Id: CHANGES,v 1.114 2008-06-06 17:55:27 nicm Exp $
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								TODO
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								TODO
									
									
									
									
									
								
							@@ -79,6 +79,6 @@
 | 
				
			|||||||
- status bar customisation variables, show-activity, show-last-window
 | 
					- status bar customisation variables, show-activity, show-last-window
 | 
				
			||||||
- show-options
 | 
					- show-options
 | 
				
			||||||
- let server die when last session does
 | 
					- let server die when last session does
 | 
				
			||||||
- each command should have a print op as well for list keys
 | 
					 | 
				
			||||||
- fix occasion start server problems
 | 
					- fix occasion start server problems
 | 
				
			||||||
 | 
					- key binding bug: random changes?
 | 
				
			||||||
- test and fix wsvt25
 | 
					- test and fix wsvt25
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										24
									
								
								server.c
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								server.c
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
				
			|||||||
/* $Id: server.c,v 1.54 2008-06-06 17:20:29 nicm Exp $ */
 | 
					/* $Id: server.c,v 1.55 2008-06-06 17:55:27 nicm Exp $ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
					 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
				
			||||||
@@ -142,7 +142,7 @@ server_main(const char *srv_path, int srv_fd)
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
	struct pollfd	*pfds, *pfd;
 | 
						struct pollfd	*pfds, *pfd;
 | 
				
			||||||
	int		 nfds;
 | 
						int		 nfds;
 | 
				
			||||||
	u_int		 i;
 | 
						u_int		 i, n;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	siginit();
 | 
						siginit();
 | 
				
			||||||
 
 | 
					 
 | 
				
			||||||
@@ -188,6 +188,22 @@ server_main(const char *srv_path, int srv_fd)
 | 
				
			|||||||
		 */
 | 
							 */
 | 
				
			||||||
		server_handle_windows(&pfd);
 | 
							server_handle_windows(&pfd);
 | 
				
			||||||
		server_handle_clients(&pfd);
 | 
							server_handle_clients(&pfd);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							/*
 | 
				
			||||||
 | 
							 * If we have no sessions and clients left, let's get out
 | 
				
			||||||
 | 
							 * of here...
 | 
				
			||||||
 | 
							 */
 | 
				
			||||||
 | 
							n = 0;
 | 
				
			||||||
 | 
							for (i = 0; i < ARRAY_LENGTH(&sessions); i++) {
 | 
				
			||||||
 | 
								if (ARRAY_ITEM(&sessions, i) != NULL)
 | 
				
			||||||
 | 
									n++;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
 | 
				
			||||||
 | 
								if (ARRAY_ITEM(&clients, i) != NULL)
 | 
				
			||||||
 | 
									n++;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							if (n == 0)
 | 
				
			||||||
 | 
								break;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (pfds != NULL)
 | 
						if (pfds != NULL)
 | 
				
			||||||
		xfree(pfds);
 | 
							xfree(pfds);
 | 
				
			||||||
@@ -430,7 +446,7 @@ server_handle_window(struct window *w)
 | 
				
			|||||||
			continue;
 | 
								continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (w->flags & WINDOW_BELL &&
 | 
							if (w->flags & WINDOW_BELL &&
 | 
				
			||||||
		    !session_alert_has(s, w, WINDOW_BELL)) {
 | 
							    !session_alert_has_window(s, w, WINDOW_BELL)) {
 | 
				
			||||||
			session_alert_add(s, w, WINDOW_BELL);
 | 
								session_alert_add(s, w, WINDOW_BELL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			action = options_get_number(&s->options, "bell-action");
 | 
								action = options_get_number(&s->options, "bell-action");
 | 
				
			||||||
@@ -449,7 +465,7 @@ server_handle_window(struct window *w)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		if ((w->flags & WINDOW_MONITOR) &&
 | 
							if ((w->flags & WINDOW_MONITOR) &&
 | 
				
			||||||
		    (w->flags & WINDOW_ACTIVITY) &&
 | 
							    (w->flags & WINDOW_ACTIVITY) &&
 | 
				
			||||||
		    !session_alert_has(s, w, WINDOW_ACTIVITY)) {
 | 
							    !session_alert_has_window(s, w, WINDOW_ACTIVITY)) {
 | 
				
			||||||
			session_alert_add(s, w, WINDOW_ACTIVITY);
 | 
								session_alert_add(s, w, WINDOW_ACTIVITY);
 | 
				
			||||||
			update = 1;
 | 
								update = 1;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										18
									
								
								session.c
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								session.c
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
				
			|||||||
/* $Id: session.c,v 1.35 2008-06-06 17:20:29 nicm Exp $ */
 | 
					/* $Id: session.c,v 1.36 2008-06-06 17:55:27 nicm Exp $ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
					 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
				
			||||||
@@ -55,7 +55,8 @@ session_alert_add(struct session *s, struct window *w, int type)
 | 
				
			|||||||
		if (wl == s->curw)
 | 
							if (wl == s->curw)
 | 
				
			||||||
			continue;
 | 
								continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (wl->window == w && !session_alert_has(s, wl, type)) {
 | 
							if (wl->window == w &&
 | 
				
			||||||
 | 
							    !session_alert_has(s, wl, type)) {
 | 
				
			||||||
			sa = xmalloc(sizeof *sa);
 | 
								sa = xmalloc(sizeof *sa);
 | 
				
			||||||
			sa->wl = wl;
 | 
								sa->wl = wl;
 | 
				
			||||||
			sa->type = type;
 | 
								sa->type = type;
 | 
				
			||||||
@@ -77,6 +78,19 @@ session_alert_has(struct session *s, struct winlink *wl, int type)
 | 
				
			|||||||
	return (0);
 | 
						return (0);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					int
 | 
				
			||||||
 | 
					session_alert_has_window(struct session *s, struct window *w, int type)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct session_alert	*sa;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						TAILQ_FOREACH(sa, &s->alerts, entry) {
 | 
				
			||||||
 | 
							if (sa->wl->window == w && sa->type == type)
 | 
				
			||||||
 | 
								return (1);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return (0);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Find session by name. */
 | 
					/* Find session by name. */
 | 
				
			||||||
struct session *
 | 
					struct session *
 | 
				
			||||||
session_find(const char *name)
 | 
					session_find(const char *name)
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										13
									
								
								tmux.h
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								tmux.h
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
				
			|||||||
/* $Id: tmux.h,v 1.134 2008-06-06 17:20:30 nicm Exp $ */
 | 
					/* $Id: tmux.h,v 1.135 2008-06-06 17:55:27 nicm Exp $ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
					 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
				
			||||||
@@ -1061,13 +1061,14 @@ void printflike2 window_more_add(struct window *, const char *, ...);
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
/* session.c */
 | 
					/* session.c */
 | 
				
			||||||
extern struct sessions sessions;
 | 
					extern struct sessions sessions;
 | 
				
			||||||
void		 session_alert_add(struct session *, struct window *, int);
 | 
					void	 session_alert_add(struct session *, struct window *, int);
 | 
				
			||||||
void		 session_alert_cancel(struct session *, struct winlink *);
 | 
					void	 session_alert_cancel(struct session *, struct winlink *);
 | 
				
			||||||
int		 session_alert_has(struct session *, struct winlink *, int);
 | 
					int	 session_alert_has(struct session *, struct winlink *, int);
 | 
				
			||||||
 | 
					int	 session_alert_has_window(struct session *, struct window *, int);
 | 
				
			||||||
struct session	*session_find(const char *);
 | 
					struct session	*session_find(const char *);
 | 
				
			||||||
struct session	*session_create(const char *, const char *, u_int, u_int);
 | 
					struct session	*session_create(const char *, const char *, u_int, u_int);
 | 
				
			||||||
void		 session_destroy(struct session *);
 | 
					void	 	 session_destroy(struct session *);
 | 
				
			||||||
int		 session_index(struct session *, u_int *);
 | 
					int	 	 session_index(struct session *, u_int *);
 | 
				
			||||||
struct winlink	*session_new(struct session *, const char *, const char *, int);
 | 
					struct winlink	*session_new(struct session *, const char *, const char *, int);
 | 
				
			||||||
struct winlink	*session_attach(struct session *, struct window *, int);
 | 
					struct winlink	*session_attach(struct session *, struct window *, int);
 | 
				
			||||||
int		 session_detach(struct session *, struct winlink *);
 | 
					int		 session_detach(struct session *, struct winlink *);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user