summaryrefslogtreecommitdiffstats
path: root/server-fn.c
diff options
context:
space:
mode:
authornicm <nicm>2015-12-16 21:50:37 +0000
committernicm <nicm>2015-12-16 21:50:37 +0000
commit021c64310daa4ae4c4e8af08f17c994f21237758 (patch)
tree7f0556b343bba058dec19c87c8f52f215cdbd2eb /server-fn.c
parent8eb1a7d5dc8d66ca7d17c72e4d8d0e58d6fd2824 (diff)
Add infrastructure to work out the best target given a pane or window
alone and use it to add pane_died and pane_exited hooks.
Diffstat (limited to 'server-fn.c')
-rw-r--r--server-fn.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/server-fn.c b/server-fn.c
index a4c2dfea..0f35aaaf 100644
--- a/server-fn.c
+++ b/server-fn.c
@@ -293,12 +293,13 @@ server_unlink_window(struct session *s, struct winlink *wl)
}
void
-server_destroy_pane(struct window_pane *wp)
+server_destroy_pane(struct window_pane *wp, int hooks)
{
struct window *w = wp->window;
int old_fd;
struct screen_write_ctx ctx;
struct grid_cell gc;
+ struct cmd_find_state fs;
old_fd = wp->fd;
if (wp->fd != -1) {
@@ -319,6 +320,9 @@ server_destroy_pane(struct window_pane *wp)
screen_write_puts(&ctx, &gc, "Pane is dead");
screen_write_stop(&ctx);
wp->flags |= PANE_REDRAW;
+
+ if (hooks && cmd_find_from_pane(&fs, wp) == 0)
+ hooks_run(hooks_get(fs.s), NULL, &fs, "pane-died");
return;
}
@@ -326,6 +330,9 @@ server_destroy_pane(struct window_pane *wp)
layout_close_pane(wp);
window_remove_pane(w, wp);
+ if (hooks && cmd_find_from_window(&fs, w) == 0)
+ hooks_run(hooks_get(fs.s), NULL, &fs, "pane-exited");
+
if (TAILQ_EMPTY(&w->panes))
server_kill_window(w);
else