From 91bc6836f7f4c5a983b12be233a279d7dfd4ec99 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Wed, 1 Apr 2009 21:10:08 +0000 Subject: [PATCH] - Allow switching to hidden windows (for active-only layout). - Don't update unnecessarily for other layouts when changing active pane doesn't matter. --- cmd-down-pane.c | 3 ++- cmd-kill-pane.c | 4 ++-- cmd-select-pane.c | 4 ++-- cmd-split-window.c | 4 ++-- cmd-up-pane.c | 3 ++- layout.c | 46 ++++++++++++++++++++++++++++++---------------- resize.c | 5 ++--- server.c | 4 ++-- tmux.h | 4 ++-- 9 files changed, 46 insertions(+), 31 deletions(-) diff --git a/cmd-down-pane.c b/cmd-down-pane.c index cd150349..af67bbac 100644 --- a/cmd-down-pane.c +++ b/cmd-down-pane.c @@ -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 @@ -54,6 +54,7 @@ cmd_down_pane_exec(struct cmd *self, struct cmd_ctx *ctx) w->active = TAILQ_NEXT(w->active, entry); if (w->active == NULL) w->active = TAILQ_FIRST(&w->panes); + layout_refresh(w, 1); } while (w->active->flags & PANE_HIDDEN); return (0); diff --git a/cmd-kill-pane.c b/cmd-kill-pane.c index a91d7c07..202bfd5f 100644 --- a/cmd-kill-pane.c +++ b/cmd-kill-pane.c @@ -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 @@ -67,6 +67,6 @@ cmd_kill_pane_exec(struct cmd *self, struct cmd_ctx *ctx) window_remove_pane(wl->window, wp); server_redraw_window(wl->window); - layout_refresh(wl->window); + layout_refresh(wl->window, 0); return (0); } diff --git a/cmd-select-pane.c b/cmd-select-pane.c index 16cdc95b..71175942 100644 --- a/cmd-select-pane.c +++ b/cmd-select-pane.c @@ -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 @@ -63,7 +63,7 @@ cmd_select_pane_exec(struct cmd *self, struct cmd_ctx *ctx) return (-1); } window_set_active_pane(wl->window, wp); - layout_refresh(wl->window); + layout_refresh(wl->window, 1); return (0); } diff --git a/cmd-split-window.c b/cmd-split-window.c index b79bcc82..f9727099 100644 --- a/cmd-split-window.c +++ b/cmd-split-window.c @@ -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 @@ -178,7 +178,7 @@ cmd_split_window_exec(struct cmd *self, struct cmd_ctx *ctx) server_redraw_session(s); } else server_status_session(s); - layout_refresh(w); + layout_refresh(w, 0); return (0); } diff --git a/cmd-up-pane.c b/cmd-up-pane.c index c9b45030..0b14fe24 100644 --- a/cmd-up-pane.c +++ b/cmd-up-pane.c @@ -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 @@ -54,6 +54,7 @@ cmd_up_pane_exec(struct cmd *self, struct cmd_ctx *ctx) w->active = TAILQ_PREV(w->active, window_panes, entry); if (w->active == NULL) w->active = TAILQ_LAST(&w->panes, window_panes); + layout_refresh(w, 1); } while (w->active->flags & PANE_HIDDEN); return (0); diff --git a/layout.c b/layout.c index 4a332140..64cf771c 100644 --- a/layout.c +++ b/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 @@ -20,15 +20,20 @@ #include "tmux.h" -void layout_manual(struct window *); -void layout_active_only(struct window *); -void layout_even_horizontal(struct window *); -void layout_even_vertical(struct window *); -void layout_left_vertical(struct window *); +/* + * Layout functions: second argument (int) is 1 if definitely the /only/ change + * has been the active pane has changed. If 0 then panes, active pane or both + * may have changed. + */ +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 char *name; - void (*fn)(struct window *); + void (*fn)(struct window *, int); } layouts[] = { { "manual", layout_manual }, { "active-only", layout_active_only }, @@ -47,23 +52,23 @@ layout_next(struct window *w) window_fit_panes(w); window_update_panes(w); } - layout_refresh(w); + layout_refresh(w, 0); } 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); } void -layout_manual(unused struct window *w) +layout_manual(unused struct window *w, unused int active_changed) { } void -layout_active_only(struct window *w) +layout_active_only(struct window *w, unused int active_changed) { struct window_pane *wp; @@ -78,11 +83,14 @@ layout_active_only(struct window *w) } void -layout_even_horizontal(struct window *w) +layout_even_horizontal(struct window *w, int active_changed) { struct window_pane *wp; u_int i, n, width, xoff; + if (active_changed) + return; + /* Get number of panes. */ n = window_count_panes(w); if (n == 0) @@ -123,11 +131,14 @@ layout_even_horizontal(struct window *w) } void -layout_even_vertical(struct window *w) +layout_even_vertical(struct window *w, int active_changed) { struct window_pane *wp; u_int i, n, height, yoff; + if (active_changed) + return; + /* Get number of panes. */ n = window_count_panes(w); if (n == 0) @@ -168,11 +179,14 @@ layout_even_vertical(struct window *w) } void -layout_left_vertical(struct window *w) +layout_left_vertical(struct window *w, int active_changed) { struct window_pane *wp; u_int i, n, height, yoff; + if (active_changed) + return; + /* Get number of panes. */ n = window_count_panes(w); if (n == 0) @@ -180,7 +194,7 @@ layout_left_vertical(struct window *w) /* Need >1 pane and minimum columns; if fewer, display active only. */ if (n == 1 || w->sx < 82 + PANE_MINIMUM) { - layout_active_only(w); + layout_active_only(w, active_changed); return; } n--; diff --git a/resize.c b/resize.c index 26aabbb0..e6c73222 100644 --- a/resize.c +++ b/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 @@ -48,7 +48,6 @@ recalculate_sizes(void) struct session *s; struct client *c; struct window *w; - struct window_pane *wp; u_int i, j, ssx, ssy, has, limit; int flag; @@ -134,6 +133,6 @@ recalculate_sizes(void) window_resize(w, ssx, ssy); server_redraw_window(w); - layout_refresh(w); + layout_refresh(w, 0); } } diff --git a/server.c b/server.c index 173b1cda..e217ee5b 100644 --- a/server.c +++ b/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 @@ -916,7 +916,7 @@ server_check_window(struct window *w) else if (!flag) { window_remove_pane(w, wp); server_redraw_window(w); - layout_refresh(w); + layout_refresh(w, 0); } wp = wq; } diff --git a/tmux.h b/tmux.h index e9c35367..79c97e72 100644 --- a/tmux.h +++ b/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 @@ -1527,7 +1527,7 @@ void window_pane_mouse(struct window_pane *, struct client *, u_char, u_char, u_char); /* layout.c */ -void layout_refresh(struct window *); +void layout_refresh(struct window *, int); void layout_next(struct window *); /* window-clock.c */