diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-06-03 07:51:25 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2009-06-03 07:51:25 +0000 |
commit | 5b409cc7f2319f90d943fd6eb3e8322e3bb2eb2a (patch) | |
tree | 9a87fa562fa40807edc55594904232b720320de1 | |
parent | 9f74c66d915634164cbd2f0923dda5c124061afe (diff) |
When swapping pane positions, swap the PANE_HIDDEN flag as well, otherwise tmux
crashes when trying to find the new active pane.
While here, nuke an unused pane flag.
Fixes PR 6160, reported by and a slightly different version of diff tested by
ralf.horstmann at gmx.de.
-rw-r--r-- | usr.bin/tmux/cmd-rotate-window.c | 15 | ||||
-rw-r--r-- | usr.bin/tmux/cmd-swap-pane.c | 13 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 5 |
3 files changed, 26 insertions, 7 deletions
diff --git a/usr.bin/tmux/cmd-rotate-window.c b/usr.bin/tmux/cmd-rotate-window.c index abe78fdd62b..8efa9a53c54 100644 --- a/usr.bin/tmux/cmd-rotate-window.c +++ b/usr.bin/tmux/cmd-rotate-window.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-rotate-window.c,v 1.1 2009/06/01 22:58:49 nicm Exp $ */ +/* $OpenBSD: cmd-rotate-window.c,v 1.2 2009/06/03 07:51:24 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -60,6 +60,7 @@ cmd_rotate_window_exec(struct cmd *self, struct cmd_ctx *ctx) struct window *w; struct window_pane *wp, *wp2; u_int sx, sy, xoff, yoff; + int flags; if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL) return (-1); @@ -71,14 +72,19 @@ cmd_rotate_window_exec(struct cmd *self, struct cmd_ctx *ctx) TAILQ_INSERT_HEAD(&w->panes, wp, entry); xoff = wp->xoff; yoff = wp->yoff; - sx = wp->sx; sy = wp->sy; + sx = wp->sx; sy = wp->sy; + flags = w->flags; TAILQ_FOREACH(wp, &w->panes, entry) { if ((wp2 = TAILQ_NEXT(wp, entry)) == NULL) break; wp->xoff = wp2->xoff; wp->yoff = wp2->yoff; + wp->flags &= ~PANE_HIDDEN; + wp->flags |= wp2->flags & PANE_HIDDEN; window_pane_resize(wp, wp2->sx, wp2->sy); } wp->xoff = xoff; wp->yoff = yoff; + wp->flags &= ~PANE_HIDDEN; + wp->flags |= flags & PANE_HIDDEN; window_pane_resize(wp, sx, sy); if ((wp = TAILQ_PREV(w->active, window_panes, entry)) == NULL) @@ -91,13 +97,18 @@ cmd_rotate_window_exec(struct cmd *self, struct cmd_ctx *ctx) xoff = wp->xoff; yoff = wp->yoff; sx = wp->sx; sy = wp->sy; + flags = w->flags; TAILQ_FOREACH_REVERSE(wp, &w->panes, window_panes, entry) { if ((wp2 = TAILQ_PREV(wp, window_panes, entry)) == NULL) break; wp->xoff = wp2->xoff; wp->yoff = wp2->yoff; + wp->flags &= ~PANE_HIDDEN; + wp->flags |= wp2->flags & PANE_HIDDEN; window_pane_resize(wp, wp2->sx, wp2->sy); } wp->xoff = xoff; wp->yoff = yoff; + wp->flags &= ~PANE_HIDDEN; + wp->flags |= flags & PANE_HIDDEN; window_pane_resize(wp, sx, sy); if ((wp = TAILQ_NEXT(w->active, entry)) == NULL) diff --git a/usr.bin/tmux/cmd-swap-pane.c b/usr.bin/tmux/cmd-swap-pane.c index 62852a198ed..332c2e3851a 100644 --- a/usr.bin/tmux/cmd-swap-pane.c +++ b/usr.bin/tmux/cmd-swap-pane.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd-swap-pane.c,v 1.1 2009/06/01 22:58:49 nicm Exp $ */ +/* $OpenBSD: cmd-swap-pane.c,v 1.2 2009/06/03 07:51:24 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott <nicm@users.sourceforge.net> @@ -158,6 +158,7 @@ cmd_swap_pane_exec(struct cmd *self, struct cmd_ctx *ctx) struct window *w; struct window_pane *tmp_wp, *src_wp, *dst_wp; u_int xx, yy; + int flags; if (data == NULL) return (0); @@ -209,10 +210,15 @@ cmd_swap_pane_exec(struct cmd *self, struct cmd_ctx *ctx) xx = src_wp->xoff; yy = src_wp->yoff; + flags = src_wp->flags; src_wp->xoff = dst_wp->xoff; src_wp->yoff = dst_wp->yoff; + src_wp->flags &= ~PANE_HIDDEN; + src_wp->flags |= dst_wp->flags & PANE_HIDDEN; dst_wp->xoff = xx; dst_wp->yoff = yy; + dst_wp->flags &= ~PANE_HIDDEN; + dst_wp->flags |= flags & PANE_HIDDEN; xx = src_wp->sx; yy = src_wp->sy; @@ -220,7 +226,10 @@ cmd_swap_pane_exec(struct cmd *self, struct cmd_ctx *ctx) window_pane_resize(dst_wp, xx, yy); if (!data->flag_detached) { - window_set_active_pane(w, dst_wp); + tmp_wp = dst_wp; + if (tmp_wp->flags & PANE_HIDDEN) + tmp_wp = src_wp; + window_set_active_pane(w, tmp_wp); layout_refresh(w, 0); } diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index f39f70f601c..18604a3206b 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.1 2009/06/01 22:58:49 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.2 2009/06/03 07:51:24 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -589,8 +589,7 @@ struct window_pane { int flags; #define PANE_HIDDEN 0x1 -#define PANE_RESTART 0x2 -#define PANE_REDRAW 0x4 +#define PANE_REDRAW 0x2 char *cmd; char *cwd; |