aboutsummaryrefslogtreecommitdiff
path: root/server-fn.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 /server-fn.c
parent1fd3a405e69c7478ab29d29cd56ac5b23f2f4f71 (diff)
downloadrtmux-6a1ebb11df452e570b430ba16192c38b0e3a0f90.tar.gz
rtmux-6a1ebb11df452e570b430ba16192c38b0e3a0f90.tar.bz2
rtmux-6a1ebb11df452e570b430ba16192c38b0e3a0f90.zip
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 'server-fn.c')
-rw-r--r--server-fn.c75
1 files changed, 61 insertions, 14 deletions
diff --git a/server-fn.c b/server-fn.c
index 03c14c35..f34c8aec 100644
--- a/server-fn.c
+++ b/server-fn.c
@@ -1,4 +1,4 @@
-/* $Id: server-fn.c,v 1.92 2009-10-05 18:23:31 tcunha Exp $ */
+/* $Id: server-fn.c,v 1.93 2009-10-11 23:38:16 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -105,6 +105,19 @@ server_redraw_session(struct session *s)
}
void
+server_redraw_session_group(struct session *s)
+{
+ struct session_group *sg;
+
+ if ((sg = session_group_find(s)) == NULL)
+ server_redraw_session(s);
+ else {
+ TAILQ_FOREACH(s, &sg->sessions, gentry)
+ server_redraw_session(s);
+ }
+}
+
+void
server_status_session(struct session *s)
{
struct client *c;
@@ -120,6 +133,19 @@ server_status_session(struct session *s)
}
void
+server_status_session_group(struct session *s)
+{
+ struct session_group *sg;
+
+ if ((sg = session_group_find(s)) == NULL)
+ server_status_session(s);
+ else {
+ TAILQ_FOREACH(s, &sg->sessions, gentry)
+ server_status_session(s);
+ }
+}
+
+void
server_redraw_window(struct window *w)
{
struct client *c;
@@ -220,18 +246,27 @@ server_kill_window(struct window *w)
continue;
if (session_detach(s, wl))
- server_destroy_session(s);
- else
+ server_destroy_session_group(s);
+ else {
server_redraw_session(s);
+ server_status_session_group(s);
+ }
}
}
int
-server_link_window(
- struct winlink *srcwl, struct session *dst, int dstidx,
- int killflag, int selectflag, char **cause)
+server_link_window(struct session *src, struct winlink *srcwl,
+ struct session *dst, int dstidx, int killflag, int selectflag, char **cause)
{
- struct winlink *dstwl;
+ struct winlink *dstwl;
+ struct session_group *srcsg, *dstsg;
+
+ srcsg = session_group_find(src);
+ dstsg = session_group_find(dst);
+ if (src != dst && srcsg != NULL && dstsg != NULL && srcsg == dstsg) {
+ xasprintf(cause, "sessions are grouped");
+ return (-1);
+ }
dstwl = NULL;
if (dstidx != -1)
@@ -260,12 +295,9 @@ server_link_window(
if (dstwl == NULL)
return (-1);
- if (!selectflag)
- server_status_session(dst);
- else {
+ if (selectflag)
session_select(dst, dstwl->idx);
- server_redraw_session(dst);
- }
+ server_redraw_session_group(dst);
return (0);
}
@@ -274,9 +306,24 @@ void
server_unlink_window(struct session *s, struct winlink *wl)
{
if (session_detach(s, wl))
- server_destroy_session(s);
+ server_destroy_session_group(s);
else
- server_redraw_session(s);
+ server_redraw_session_group(s);
+}
+
+void
+server_destroy_session_group(struct session *s)
+{
+ struct session_group *sg;
+
+ if ((sg = session_group_find(s)) == NULL)
+ server_destroy_session(s);
+ else {
+ TAILQ_FOREACH(s, &sg->sessions, gentry)
+ server_destroy_session(s);
+ TAILQ_REMOVE(&session_groups, sg, entry);
+ xfree(sg);
+ }
}
void