diff options
author | Nicholas Marriott <nicm@openbsd.org> | 2009-07-17 20:37:03 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@openbsd.org> | 2009-07-17 20:37:03 +0000 |
commit | 0ca6f667e3e6f26e92db01ee2a769d0ba49509ca (patch) | |
tree | f9538add19095eefbcfb7aaaf4569e1cdfdb1491 /server-fn.c | |
parent | 6f5150a943425d7d5d65ae443f956931fcb82d0b (diff) |
Make it so using kill-pane to destroy the last pane in a window destroys the
window instead of being an error.
Diffstat (limited to 'server-fn.c')
-rw-r--r-- | server-fn.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/server-fn.c b/server-fn.c index d6cec8f9..3080bed4 100644 --- a/server-fn.c +++ b/server-fn.c @@ -228,3 +228,36 @@ wrong: return (-1); } + +void +server_kill_window(struct window *w) +{ + struct session *s; + struct winlink *wl; + struct client *c; + u_int i, j; + int destroyed; + + + for (i = 0; i < ARRAY_LENGTH(&sessions); i++) { + s = ARRAY_ITEM(&sessions, i); + if (s == NULL || !session_has(s, w)) + continue; + if ((wl = winlink_find_by_window(&s->windows, w)) == NULL) + continue; + + destroyed = session_detach(s, wl); + for (j = 0; j < ARRAY_LENGTH(&clients); j++) { + c = ARRAY_ITEM(&clients, j); + if (c == NULL || c->session != s) + continue; + + if (destroyed) { + c->session = NULL; + server_write_client(c, MSG_EXIT, NULL, 0); + } else + server_redraw_client(c); + } + } + recalculate_sizes(); +} |