summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/cmd-swap-window.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2009-10-10 10:02:49 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2009-10-10 10:02:49 +0000
commit1a7d94b31f73fd2780347ed40c36a275984d82f5 (patch)
treec75a5b36b46e37774308415dee9f0d21d80cf252 /usr.bin/tmux/cmd-swap-window.c
parent930bee8dee77f0a986fac1edcc836ff0d62c5165 (diff)
Add "grouped sessions" which have independent name, options, current window and
so on but where the linked windows are synchronized (ie creating, killing windows and so on are mirrored between the sessions). A grouped session may be created by passing -t to new-session. Had this around for a while, tested by a couple of people.
Diffstat (limited to 'usr.bin/tmux/cmd-swap-window.c')
-rw-r--r--usr.bin/tmux/cmd-swap-window.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/usr.bin/tmux/cmd-swap-window.c b/usr.bin/tmux/cmd-swap-window.c
index e51609f6e47..0c06d4d5c60 100644
--- a/usr.bin/tmux/cmd-swap-window.c
+++ b/usr.bin/tmux/cmd-swap-window.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-swap-window.c,v 1.3 2009/07/26 12:58:44 nicm Exp $ */
+/* $OpenBSD: cmd-swap-window.c,v 1.4 2009/10/10 10:02:48 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -44,6 +44,7 @@ cmd_swap_window_exec(struct cmd *self, struct cmd_ctx *ctx)
{
struct cmd_srcdst_data *data = self->data;
struct session *src, *dst;
+ struct session_group *sg_src, *sg_dst;
struct winlink *wl_src, *wl_dst;
struct window *w;
@@ -52,6 +53,14 @@ cmd_swap_window_exec(struct cmd *self, struct cmd_ctx *ctx)
if ((wl_dst = cmd_find_window(ctx, data->dst, &dst)) == NULL)
return (-1);
+ sg_src = session_group_find(src);
+ sg_dst = session_group_find(dst);
+ if (src != dst &&
+ sg_src != NULL && sg_dst != NULL && sg_src == sg_dst) {
+ ctx->error(ctx, "can't move window, sessions are grouped");
+ return (-1);
+ }
+
if (wl_dst->window == wl_src->window)
return (0);
@@ -64,9 +73,12 @@ cmd_swap_window_exec(struct cmd *self, struct cmd_ctx *ctx)
if (src != dst)
session_select(src, wl_src->idx);
}
- server_redraw_session(src);
- if (src != dst)
- server_redraw_session(dst);
+ session_group_synchronize_from(src);
+ server_redraw_session_group(src);
+ if (src != dst) {
+ session_group_synchronize_from(dst);
+ server_redraw_session_group(dst);
+ }
recalculate_sizes();
return (0);