mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 09:26:05 +00:00 
			
		
		
		
	- Allow switching to hidden windows (for active-only layout).
- Don't update unnecessarily for other layouts when changing active pane doesn't matter.
This commit is contained in:
		@@ -1,4 +1,4 @@
 | 
				
			|||||||
/* $Id: cmd-down-pane.c,v 1.6 2009-04-01 18:33:19 nicm Exp $ */
 | 
					/* $Id: cmd-down-pane.c,v 1.7 2009-04-01 21:10:08 nicm Exp $ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
					 * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
				
			||||||
@@ -54,6 +54,7 @@ cmd_down_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
 | 
				
			|||||||
		w->active = TAILQ_NEXT(w->active, entry);
 | 
							w->active = TAILQ_NEXT(w->active, entry);
 | 
				
			||||||
		if (w->active == NULL)
 | 
							if (w->active == NULL)
 | 
				
			||||||
			w->active = TAILQ_FIRST(&w->panes);
 | 
								w->active = TAILQ_FIRST(&w->panes);
 | 
				
			||||||
 | 
							layout_refresh(w, 1);
 | 
				
			||||||
	} while (w->active->flags & PANE_HIDDEN);
 | 
						} while (w->active->flags & PANE_HIDDEN);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return (0);
 | 
						return (0);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,4 +1,4 @@
 | 
				
			|||||||
/* $Id: cmd-kill-pane.c,v 1.5 2009-04-01 18:21:24 nicm Exp $ */
 | 
					/* $Id: cmd-kill-pane.c,v 1.6 2009-04-01 21:10:08 nicm Exp $ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
					 * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
				
			||||||
@@ -67,6 +67,6 @@ cmd_kill_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	window_remove_pane(wl->window, wp);
 | 
						window_remove_pane(wl->window, wp);
 | 
				
			||||||
	server_redraw_window(wl->window);
 | 
						server_redraw_window(wl->window);
 | 
				
			||||||
	layout_refresh(wl->window);
 | 
						layout_refresh(wl->window, 0);
 | 
				
			||||||
	return (0);
 | 
						return (0);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,4 +1,4 @@
 | 
				
			|||||||
/* $Id: cmd-select-pane.c,v 1.3 2009-04-01 18:21:26 nicm Exp $ */
 | 
					/* $Id: cmd-select-pane.c,v 1.4 2009-04-01 21:10:08 nicm Exp $ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
					 * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
				
			||||||
@@ -63,7 +63,7 @@ cmd_select_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
 | 
				
			|||||||
		return (-1);
 | 
							return (-1);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	window_set_active_pane(wl->window, wp);
 | 
						window_set_active_pane(wl->window, wp);
 | 
				
			||||||
	layout_refresh(wl->window);
 | 
						layout_refresh(wl->window, 1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return (0);
 | 
						return (0);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,4 +1,4 @@
 | 
				
			|||||||
/* $Id: cmd-split-window.c,v 1.10 2009-04-01 18:21:28 nicm Exp $ */
 | 
					/* $Id: cmd-split-window.c,v 1.11 2009-04-01 21:10:08 nicm Exp $ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
					 * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
				
			||||||
@@ -178,7 +178,7 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx)
 | 
				
			|||||||
		server_redraw_session(s);
 | 
							server_redraw_session(s);
 | 
				
			||||||
	} else
 | 
						} else
 | 
				
			||||||
		server_status_session(s);
 | 
							server_status_session(s);
 | 
				
			||||||
	layout_refresh(w);
 | 
						layout_refresh(w, 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return (0);
 | 
						return (0);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,4 +1,4 @@
 | 
				
			|||||||
/* $Id: cmd-up-pane.c,v 1.6 2009-04-01 18:33:19 nicm Exp $ */
 | 
					/* $Id: cmd-up-pane.c,v 1.7 2009-04-01 21:10:08 nicm Exp $ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
					 * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
				
			||||||
@@ -54,6 +54,7 @@ cmd_up_pane_exec(struct cmd *self, struct cmd_ctx *ctx)
 | 
				
			|||||||
		w->active = TAILQ_PREV(w->active, window_panes, entry);
 | 
							w->active = TAILQ_PREV(w->active, window_panes, entry);
 | 
				
			||||||
		if (w->active == NULL)
 | 
							if (w->active == NULL)
 | 
				
			||||||
			w->active = TAILQ_LAST(&w->panes, window_panes);
 | 
								w->active = TAILQ_LAST(&w->panes, window_panes);
 | 
				
			||||||
 | 
							layout_refresh(w, 1);
 | 
				
			||||||
	} while (w->active->flags & PANE_HIDDEN);
 | 
						} while (w->active->flags & PANE_HIDDEN);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return (0);
 | 
						return (0);
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										46
									
								
								layout.c
									
									
									
									
									
								
							
							
						
						
									
										46
									
								
								layout.c
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
				
			|||||||
/* $Id: layout.c,v 1.2 2009-04-01 18:48:09 nicm Exp $ */
 | 
					/* $Id: layout.c,v 1.3 2009-04-01 21:10:08 nicm Exp $ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
					 * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
				
			||||||
@@ -20,15 +20,20 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
#include "tmux.h"
 | 
					#include "tmux.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void	layout_manual(struct window *);
 | 
					/*
 | 
				
			||||||
void	layout_active_only(struct window *);
 | 
					 * Layout functions: second argument (int) is 1 if definitely the /only/ change
 | 
				
			||||||
void	layout_even_horizontal(struct window *);
 | 
					 * has been the active pane has changed. If 0 then panes, active pane or both
 | 
				
			||||||
void	layout_even_vertical(struct window *);
 | 
					 * may have changed.
 | 
				
			||||||
void	layout_left_vertical(struct window *);
 | 
					 */
 | 
				
			||||||
 | 
					void	layout_manual(struct window *, int);
 | 
				
			||||||
 | 
					void	layout_active_only(struct window *, int);
 | 
				
			||||||
 | 
					void	layout_even_horizontal(struct window *, int);
 | 
				
			||||||
 | 
					void	layout_even_vertical(struct window *, int);
 | 
				
			||||||
 | 
					void	layout_left_vertical(struct window *, int);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const struct {
 | 
					const struct {
 | 
				
			||||||
	const char	*name;
 | 
						const char	*name;
 | 
				
			||||||
	void		(*fn)(struct window *);
 | 
						void		(*fn)(struct window *, int);
 | 
				
			||||||
} layouts[] = {
 | 
					} layouts[] = {
 | 
				
			||||||
	{ "manual", layout_manual },
 | 
						{ "manual", layout_manual },
 | 
				
			||||||
	{ "active-only", layout_active_only },
 | 
						{ "active-only", layout_active_only },
 | 
				
			||||||
@@ -47,23 +52,23 @@ layout_next(struct window *w)
 | 
				
			|||||||
		window_fit_panes(w);
 | 
							window_fit_panes(w);
 | 
				
			||||||
		window_update_panes(w);
 | 
							window_update_panes(w);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	layout_refresh(w);
 | 
						layout_refresh(w, 0);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
layout_refresh(struct window *w)
 | 
					layout_refresh(struct window *w, unused int active_changed)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	layouts[w->layout].fn(w);
 | 
						layouts[w->layout].fn(w, active_changed);
 | 
				
			||||||
	server_redraw_window(w);
 | 
						server_redraw_window(w);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
layout_manual(unused struct window *w)
 | 
					layout_manual(unused struct window *w, unused int active_changed)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
layout_active_only(struct window *w)
 | 
					layout_active_only(struct window *w, unused int active_changed)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct window_pane	*wp;
 | 
						struct window_pane	*wp;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
@@ -78,11 +83,14 @@ layout_active_only(struct window *w)
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
layout_even_horizontal(struct window *w)
 | 
					layout_even_horizontal(struct window *w, int active_changed)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct window_pane	*wp;
 | 
						struct window_pane	*wp;
 | 
				
			||||||
	u_int			 i, n, width, xoff;
 | 
						u_int			 i, n, width, xoff;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (active_changed)
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Get number of panes. */
 | 
						/* Get number of panes. */
 | 
				
			||||||
	n = window_count_panes(w);
 | 
						n = window_count_panes(w);
 | 
				
			||||||
	if (n == 0)
 | 
						if (n == 0)
 | 
				
			||||||
@@ -123,11 +131,14 @@ layout_even_horizontal(struct window *w)
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
layout_even_vertical(struct window *w)
 | 
					layout_even_vertical(struct window *w, int active_changed)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct window_pane	*wp;
 | 
						struct window_pane	*wp;
 | 
				
			||||||
	u_int			 i, n, height, yoff;
 | 
						u_int			 i, n, height, yoff;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (active_changed)
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Get number of panes. */
 | 
						/* Get number of panes. */
 | 
				
			||||||
	n = window_count_panes(w);
 | 
						n = window_count_panes(w);
 | 
				
			||||||
	if (n == 0)
 | 
						if (n == 0)
 | 
				
			||||||
@@ -168,11 +179,14 @@ layout_even_vertical(struct window *w)
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
layout_left_vertical(struct window *w)
 | 
					layout_left_vertical(struct window *w, int active_changed)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct window_pane	*wp;
 | 
						struct window_pane	*wp;
 | 
				
			||||||
	u_int			 i, n, height, yoff;
 | 
						u_int			 i, n, height, yoff;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (active_changed)
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Get number of panes. */
 | 
						/* Get number of panes. */
 | 
				
			||||||
	n = window_count_panes(w);
 | 
						n = window_count_panes(w);
 | 
				
			||||||
	if (n == 0)
 | 
						if (n == 0)
 | 
				
			||||||
@@ -180,7 +194,7 @@ layout_left_vertical(struct window *w)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	/* Need >1 pane and minimum columns; if fewer, display active only. */
 | 
						/* Need >1 pane and minimum columns; if fewer, display active only. */
 | 
				
			||||||
	if (n == 1 || w->sx < 82 + PANE_MINIMUM) {
 | 
						if (n == 1 || w->sx < 82 + PANE_MINIMUM) {
 | 
				
			||||||
		layout_active_only(w);
 | 
							layout_active_only(w, active_changed);
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	n--;
 | 
						n--;
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										5
									
								
								resize.c
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								resize.c
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
				
			|||||||
/* $Id: resize.c,v 1.20 2009-04-01 18:21:32 nicm Exp $ */
 | 
					/* $Id: resize.c,v 1.21 2009-04-01 21:10:08 nicm Exp $ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
					 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
				
			||||||
@@ -48,7 +48,6 @@ recalculate_sizes(void)
 | 
				
			|||||||
	struct session		*s;
 | 
						struct session		*s;
 | 
				
			||||||
	struct client		*c;
 | 
						struct client		*c;
 | 
				
			||||||
	struct window		*w;
 | 
						struct window		*w;
 | 
				
			||||||
	struct window_pane	*wp;
 | 
					 | 
				
			||||||
	u_int		 	 i, j, ssx, ssy, has, limit;
 | 
						u_int		 	 i, j, ssx, ssy, has, limit;
 | 
				
			||||||
	int		 	 flag;
 | 
						int		 	 flag;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -134,6 +133,6 @@ recalculate_sizes(void)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		window_resize(w, ssx, ssy);
 | 
							window_resize(w, ssx, ssy);
 | 
				
			||||||
		server_redraw_window(w);
 | 
							server_redraw_window(w);
 | 
				
			||||||
		layout_refresh(w);
 | 
							layout_refresh(w, 0);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								server.c
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								server.c
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
				
			|||||||
/* $Id: server.c,v 1.133 2009-04-01 18:21:35 nicm Exp $ */
 | 
					/* $Id: server.c,v 1.134 2009-04-01 21:10:08 nicm Exp $ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
					 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
				
			||||||
@@ -916,7 +916,7 @@ server_check_window(struct window *w)
 | 
				
			|||||||
		else if (!flag) {
 | 
							else if (!flag) {
 | 
				
			||||||
			window_remove_pane(w, wp);
 | 
								window_remove_pane(w, wp);
 | 
				
			||||||
			server_redraw_window(w);
 | 
								server_redraw_window(w);
 | 
				
			||||||
			layout_refresh(w);
 | 
								layout_refresh(w, 0);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		wp = wq;
 | 
							wp = wq;
 | 
				
			||||||
	} 
 | 
						} 
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								tmux.h
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								tmux.h
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
				
			|||||||
/* $Id: tmux.h,v 1.294 2009-04-01 18:21:42 nicm Exp $ */
 | 
					/* $Id: tmux.h,v 1.295 2009-04-01 21:10:08 nicm Exp $ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
					 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
				
			||||||
@@ -1527,7 +1527,7 @@ void		 window_pane_mouse(struct window_pane *,
 | 
				
			|||||||
    		     struct client *, u_char, u_char, u_char);
 | 
					    		     struct client *, u_char, u_char, u_char);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* layout.c */
 | 
					/* layout.c */
 | 
				
			||||||
void		 layout_refresh(struct window *);
 | 
					void		 layout_refresh(struct window *, int);
 | 
				
			||||||
void		 layout_next(struct window *);
 | 
					void		 layout_next(struct window *);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* window-clock.c */
 | 
					/* window-clock.c */
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user