diff options
author | Nicholas Marriott <nicm@openbsd.org> | 2009-10-10 10:02:48 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@openbsd.org> | 2009-10-10 10:02:48 +0000 |
commit | 9dd72b958366c44b6d62680836983c58d2a0a42f (patch) | |
tree | 6690d38f157a2e357c9aef70f72149f4ce244cae /server-fn.c | |
parent | b7d031cc92a1d9ac3ca8c2a71b76b0a78ea77465 (diff) | |
download | rtmux-9dd72b958366c44b6d62680836983c58d2a0a42f.tar.gz rtmux-9dd72b958366c44b6d62680836983c58d2a0a42f.tar.bz2 rtmux-9dd72b958366c44b6d62680836983c58d2a0a42f.zip |
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.c | 73 |
1 files changed, 60 insertions, 13 deletions
diff --git a/server-fn.c b/server-fn.c index 4e3e12ec..beaae07a 100644 --- a/server-fn.c +++ b/server-fn.c @@ -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 |