summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/cmd-kill-window.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2009-07-15 08:00:50 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2009-07-15 08:00:50 +0000
commitb5a445e0538feb2ae2cfef81cfa9558a23d3a236 (patch)
tree2c59f77fb7070726e93751674760d03c18682798 /usr.bin/tmux/cmd-kill-window.c
parente6e0d89314764ea4c22a4fe6c5b31e9442e7034c (diff)
The man page says that kill-window removes the window entirely, unlinking it
from any sessions. In fact the implementation only affected the current session, making it the same as unlink-window but destroying the window if it was linked into only one session (unlinkw gives an error). Change the behaviour to match what it documented and was originally intended.
Diffstat (limited to 'usr.bin/tmux/cmd-kill-window.c')
-rw-r--r--usr.bin/tmux/cmd-kill-window.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/usr.bin/tmux/cmd-kill-window.c b/usr.bin/tmux/cmd-kill-window.c
index 9aaacfcc497..a083e0caf4f 100644
--- a/usr.bin/tmux/cmd-kill-window.c
+++ b/usr.bin/tmux/cmd-kill-window.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-kill-window.c,v 1.2 2009/07/13 23:11:35 nicm Exp $ */
+/* $OpenBSD: cmd-kill-window.c,v 1.3 2009/07/15 08:00:49 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -44,24 +44,35 @@ cmd_kill_window_exec(struct cmd *self, struct cmd_ctx *ctx)
{
struct cmd_target_data *data = self->data;
struct winlink *wl;
+ struct window *w;
struct session *s;
struct client *c;
- u_int i;
+ u_int i, j;
int destroyed;
- if ((wl = cmd_find_window(ctx, data->target, &s)) == NULL)
+ if ((wl = cmd_find_window(ctx, data->target, NULL)) == NULL)
return (-1);
+ w = wl->window;
- destroyed = session_detach(s, wl);
- for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
- c = ARRAY_ITEM(&clients, i);
- if (c == NULL || c->session != s)
+ for (i = 0; i < ARRAY_LENGTH(&sessions); i++) {
+ s = ARRAY_ITEM(&sessions, i);
+ if (s == NULL || !session_has(s, w))
continue;
- if (destroyed) {
- c->session = NULL;
- server_write_client(c, MSG_EXIT, NULL, 0);
- } else
- server_redraw_client(c);
+ 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();