summaryrefslogtreecommitdiffstats
path: root/session.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicholas.marriott@gmail.com>2007-08-27 12:05:15 +0000
committerNicholas Marriott <nicholas.marriott@gmail.com>2007-08-27 12:05:15 +0000
commit6e210bb005ee5193fe030f5e8cfe8877aac6260d (patch)
tree8bbecf8301dd9334c925ee8cf9e9be188d81cd3c /session.c
parent7000277f949a11b6176d3f97cb1bf154c52b1009 (diff)
If a session is destroyed, safely kill all other clients attached to it.
Diffstat (limited to 'session.c')
-rw-r--r--session.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/session.c b/session.c
index 169a04cd..7066d624 100644
--- a/session.c
+++ b/session.c
@@ -1,4 +1,4 @@
-/* $Id: session.c,v 1.3 2007-08-27 09:53:38 nicm Exp $ */
+/* $Id: session.c,v 1.4 2007-08-27 12:05:15 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -119,7 +119,7 @@ session_attach(struct session *s, struct window *w)
}
/* Detach a window from a session. */
-int
+void
session_detach(struct session *s, struct window *w)
{
if (s->window == w) {
@@ -128,13 +128,20 @@ session_detach(struct session *s, struct window *w)
}
window_remove(&s->windows, w);
- if (ARRAY_EMPTY(&s->windows)) {
- session_destroy(s);
- return (1);
- }
return (0);
}
+/* Flush session if it is empty. */
+int
+session_flush(struct session *s)
+{
+ if (!ARRAY_EMPTY(&s->windows))
+ return (0);
+
+ session_destroy(s);
+ return (1);
+}
+
/* Return if session has window. */
int
session_has(struct session *s, struct window *w)