aboutsummaryrefslogtreecommitdiff
path: root/server-fn.c
diff options
context:
space:
mode:
authorTiago Cunha <tcunha@gmx.com>2009-09-20 22:15:32 +0000
committerTiago Cunha <tcunha@gmx.com>2009-09-20 22:15:32 +0000
commit7335ef5792791e803b090fb9d54718604a0d7dab (patch)
tree5e3d96dc3abf3cac92ea27120266aa3806947333 /server-fn.c
parent3266fb5441e99c809ee56806a0eb8d113a4d099f (diff)
downloadrtmux-7335ef5792791e803b090fb9d54718604a0d7dab.tar.gz
rtmux-7335ef5792791e803b090fb9d54718604a0d7dab.tar.bz2
rtmux-7335ef5792791e803b090fb9d54718604a0d7dab.zip
Sync OpenBSD patchset 333:
Move some common and untidy code for window link/unlink into generic functions instead of duplicating it in move/link window..
Diffstat (limited to 'server-fn.c')
-rw-r--r--server-fn.c56
1 files changed, 54 insertions, 2 deletions
diff --git a/server-fn.c b/server-fn.c
index 0af2a16b..99c1d36d 100644
--- a/server-fn.c
+++ b/server-fn.c
@@ -1,4 +1,4 @@
-/* $Id: server-fn.c,v 1.88 2009-09-20 22:11:27 tcunha Exp $ */
+/* $Id: server-fn.c,v 1.89 2009-09-20 22:15:32 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -292,7 +292,59 @@ server_kill_window(struct window *w)
else
server_redraw_session(s);
}
- recalculate_sizes();
+}
+
+int
+server_link_window(
+ struct winlink *srcwl, struct session *dst, int dstidx,
+ int killflag, int selectflag, char **cause)
+{
+ struct winlink *dstwl;
+
+ dstwl = NULL;
+ if (dstidx != -1)
+ dstwl = winlink_find_by_index(&dst->windows, dstidx);
+ if (dstwl != NULL) {
+ if (dstwl->window == srcwl->window)
+ return (0);
+ if (killflag) {
+ /*
+ * Can't use session_detach as it will destroy session
+ * if this makes it empty.
+ */
+ session_alert_cancel(dst, dstwl);
+ winlink_stack_remove(&dst->lastw, dstwl);
+ winlink_remove(&dst->windows, dstwl);
+
+ /* Force select/redraw if current. */
+ if (dstwl == dst->curw)
+ selectflag = 1;
+ }
+ }
+
+ if (dstidx == -1)
+ dstidx = -1 - options_get_number(&dst->options, "base-index");
+ dstwl = session_attach(dst, srcwl->window, dstidx, cause);
+ if (dstwl == NULL)
+ return (-1);
+
+ if (!selectflag)
+ server_status_session(dst);
+ else {
+ session_select(dst, dstwl->idx);
+ server_redraw_session(dst);
+ }
+
+ return (0);
+}
+
+void
+server_unlink_window(struct session *s, struct winlink *wl)
+{
+ if (session_detach(s, wl))
+ server_destroy_session(s);
+ else
+ server_redraw_session(s);
}
void