summaryrefslogtreecommitdiffstats
path: root/cmd-swap-window.c
diff options
context:
space:
mode:
authorTiago Cunha <tcunha@gmx.com>2009-10-11 23:38:16 +0000
committerTiago Cunha <tcunha@gmx.com>2009-10-11 23:38:16 +0000
commit6a1ebb11df452e570b430ba16192c38b0e3a0f90 (patch)
treef2165e41abebbb503f4f8feba689468128a96cf7 /cmd-swap-window.c
parent1fd3a405e69c7478ab29d29cd56ac5b23f2f4f71 (diff)
Sync OpenBSD patchset 371:
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 'cmd-swap-window.c')
-rw-r--r--cmd-swap-window.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/cmd-swap-window.c b/cmd-swap-window.c
index fdd25ce6..8d6e0b32 100644
--- a/cmd-swap-window.c
+++ b/cmd-swap-window.c
@@ -1,4 +1,4 @@
-/* $Id: cmd-swap-window.c,v 1.17 2009-07-28 22:12:16 tcunha Exp $ */
+/* $Id: cmd-swap-window.c,v 1.18 2009-10-11 23:38:16 tcunha 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);