summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Adam <thomas@xteddy.org>2016-10-17 00:01:11 +0100
committerThomas Adam <thomas@xteddy.org>2016-10-17 00:01:11 +0100
commitd54e990c4ffb576aa3d82306b970dc64bdd4cda6 (patch)
tree14657ab6804e8dcb4ee696afd823e19e46e0631f
parent1a6e696b08113ca17ee8e881844167cf94276846 (diff)
parentfe106842c879c8f2d0419afba4f90ce0c62c5e80 (diff)
Merge branch 'obsd-master'
-rw-r--r--alerts.c11
-rw-r--r--cmd-attach-session.c6
-rw-r--r--cmd-find.c2
-rw-r--r--cmd-join-pane.c4
-rw-r--r--cmd-new-session.c2
-rw-r--r--cmd-new-window.c2
-rw-r--r--cmd-rename-session.c2
-rw-r--r--cmd-split-window.c2
-rw-r--r--control-notify.c2
-rw-r--r--layout-custom.c2
-rw-r--r--layout.c4
-rw-r--r--notify.c159
-rw-r--r--resize.c2
-rw-r--r--server-client.c4
-rw-r--r--server-fn.c20
-rw-r--r--session.c16
-rw-r--r--tmux.17
-rw-r--r--tmux.h16
-rw-r--r--window.c6
19 files changed, 131 insertions, 138 deletions
diff --git a/alerts.c b/alerts.c
index bcca8f3d..ef869ae8 100644
--- a/alerts.c
+++ b/alerts.c
@@ -75,17 +75,12 @@ alerts_callback(__unused int fd, __unused short events, __unused void *arg)
static void
alerts_run_hook(struct session *s, struct winlink *wl, int flags)
{
- struct cmd_find_state fs;
-
- if (cmd_find_from_winlink(&fs, s, wl) != 0)
- return;
-
if (flags & WINDOW_BELL)
- hooks_run(s->hooks, NULL, &fs, "alert-bell");
+ notify_winlink("alert-bell", s, wl);
if (flags & WINDOW_SILENCE)
- hooks_run(s->hooks, NULL, &fs, "alert-silence");
+ notify_winlink("alert-silence", s, wl);
if (flags & WINDOW_ACTIVITY)
- hooks_run(s->hooks, NULL, &fs, "alert-activity");
+ notify_winlink("alert-activity", s, wl);
}
static int
diff --git a/cmd-attach-session.c b/cmd-attach-session.c
index d999eb76..5807eefc 100644
--- a/cmd-attach-session.c
+++ b/cmd-attach-session.c
@@ -105,7 +105,7 @@ cmd_attach_session(struct cmdq_item *item, int dflag, int rflag,
c->session = s;
server_client_set_key_table(c, NULL);
status_timer_start(c);
- notify_attached_session_changed(c);
+ notify_client("client-session-changed", c);
session_update_activity(s, NULL);
gettimeofday(&s->last_attached_time, NULL);
server_redraw_client(c);
@@ -137,7 +137,7 @@ cmd_attach_session(struct cmdq_item *item, int dflag, int rflag,
c->session = s;
server_client_set_key_table(c, NULL);
status_timer_start(c);
- notify_attached_session_changed(c);
+ notify_client("client-session-changed", c);
session_update_activity(s, NULL);
gettimeofday(&s->last_attached_time, NULL);
server_redraw_client(c);
@@ -145,7 +145,7 @@ cmd_attach_session(struct cmdq_item *item, int dflag, int rflag,
if (~c->flags & CLIENT_CONTROL)
proc_send(c->peer, MSG_READY, -1, NULL, 0);
- hooks_run(c->session->hooks, c, NULL, "client-attached");
+ notify_client("client-attached", c);
c->flags |= CLIENT_ATTACHED;
}
recalculate_sizes();
diff --git a/cmd-find.c b/cmd-find.c
index a2f9aa4e..46551e2d 100644
--- a/cmd-find.c
+++ b/cmd-find.c
@@ -227,7 +227,7 @@ cmd_find_best_winlink_with_window(struct cmd_find_state *fs)
struct winlink *wl, *wl_loop;
wl = NULL;
- if (fs->s->curw->window == fs->w)
+ if (fs->s->curw != NULL && fs->s->curw->window == fs->w)
wl = fs->s->curw;
else {
RB_FOREACH(wl_loop, winlinks, &fs->s->windows) {
diff --git a/cmd-join-pane.c b/cmd-join-pane.c
index 557de091..b6cee1b5 100644
--- a/cmd-join-pane.c
+++ b/cmd-join-pane.c
@@ -152,8 +152,8 @@ cmd_join_pane_exec(struct cmd *self, struct cmdq_item *item)
if (window_count_panes(src_w) == 0)
server_kill_window(src_w);
else
- notify_window_layout_changed(src_w);
- notify_window_layout_changed(dst_w);
+ notify_window("window-layout-changed", src_w);
+ notify_window("window-layout-changed", dst_w);
return (CMD_RETURN_NORMAL);
}
diff --git a/cmd-new-session.c b/cmd-new-session.c
index f6e728e4..ca0a1c17 100644
--- a/cmd-new-session.c
+++ b/cmd-new-session.c
@@ -281,7 +281,7 @@ cmd_new_session_exec(struct cmd *self, struct cmdq_item *item)
c->session = s;
server_client_set_key_table(c, NULL);
status_timer_start(c);
- notify_attached_session_changed(c);
+ notify_client("client-session-changed", c);
session_update_activity(s, NULL);
gettimeofday(&s->last_attached_time, NULL);
server_redraw_client(c);
diff --git a/cmd-new-window.c b/cmd-new-window.c
index 3e7f82d5..2e032c40 100644
--- a/cmd-new-window.c
+++ b/cmd-new-window.c
@@ -112,7 +112,7 @@ cmd_new_window_exec(struct cmd *self, struct cmdq_item *item)
* Can't use session_detach as it will destroy session if this
* makes it empty.
*/
- notify_window_unlinked(s, wl->window);
+ notify_session_window("window-unlinked", s, wl->window);
wl->flags &= ~WINLINK_ALERTFLAGS;
winlink_stack_remove(&s->lastw, wl);
winlink_remove(&s->windows, wl);
diff --git a/cmd-rename-session.c b/cmd-rename-session.c
index bcc896b2..bf180f91 100644
--- a/cmd-rename-session.c
+++ b/cmd-rename-session.c
@@ -65,7 +65,7 @@ cmd_rename_session_exec(struct cmd *self, struct cmdq_item *item)
RB_INSERT(sessions, &sessions, s);
server_status_session(s);
- notify_session_renamed(s);
+ notify_session("session-renamed", s);
return (CMD_RETURN_NORMAL);
}
diff --git a/cmd-split-window.c b/cmd-split-window.c
index 5a724c36..213770c4 100644
--- a/cmd-split-window.c
+++ b/cmd-split-window.c
@@ -177,7 +177,7 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item)
format_free(ft);
}
- notify_window_layout_changed(w);
+ notify_window("window-layout-changed", w);
if (to_free != NULL)
free((void *)to_free);
diff --git a/control-notify.c b/control-notify.c
index e544139b..9158ce2c 100644
--- a/control-notify.c
+++ b/control-notify.c
@@ -158,7 +158,7 @@ control_notify_window_renamed(struct window *w)
}
void
-control_notify_attached_session_changed(struct client *c)
+control_notify_client_session_changed(struct client *c)
{
struct session *s;
diff --git a/layout-custom.c b/layout-custom.c
index 205e1fca..1b8f576e 100644
--- a/layout-custom.c
+++ b/layout-custom.c
@@ -175,7 +175,7 @@ layout_parse(struct window *w, const char *layout)
layout_print_cell(lc, __func__, 0);
- notify_window_layout_changed(w);
+ notify_window("window-layout-changed", w);
return (0);
diff --git a/layout.c b/layout.c
index 490dbf0b..47d01851 100644
--- a/layout.c
+++ b/layout.c
@@ -578,7 +578,7 @@ layout_resize_pane(struct window_pane *wp, enum layout_type type, int change,
/* Fix cell offsets. */
layout_fix_offsets(wp->window->layout_root);
layout_fix_panes(wp->window, wp->window->sx, wp->window->sy);
- notify_window_layout_changed(wp->window);
+ notify_window("window-layout-changed", wp->window);
}
/* Helper function to grow pane. */
@@ -980,5 +980,5 @@ layout_close_pane(struct window_pane *wp)
layout_fix_offsets(w->layout_root);
layout_fix_panes(w, w->sx, w->sy);
}
- notify_window_layout_changed(w);
+ notify_window("window-layout-changed", w);
}
diff --git a/notify.c b/notify.c
index 92939c5e..5ff9c604 100644
--- a/notify.c
+++ b/notify.c
@@ -19,72 +19,43 @@
#include <sys/types.h>
#include <stdlib.h>
+#include <string.h>
#include "tmux.h"
-enum notify_type {
- NOTIFY_WINDOW_LAYOUT_CHANGED,
- NOTIFY_WINDOW_UNLINKED,
- NOTIFY_WINDOW_LINKED,
- NOTIFY_WINDOW_RENAMED,
- NOTIFY_ATTACHED_SESSION_CHANGED,
- NOTIFY_SESSION_RENAMED,
- NOTIFY_SESSION_CREATED,
- NOTIFY_SESSION_CLOSED
-};
-
-static const char *notify_hooks[] = {
- "window-layout-changed",
- NULL, /* "window-unlinked", */
- NULL, /* "window-linked", */
- "window-renamed",
- NULL, /* "attached-session-changed", */
- "session-renamed",
- "session-created",
- "session-closed"
-};
-
struct notify_entry {
- enum notify_type type;
+ const char *name;
struct client *client;
struct session *session;
struct window *window;
+ int pane;
+
+ struct cmd_find_state fs;
};
static void
notify_hook(struct cmdq_item *item, struct notify_entry *ne)
{
- const char *name;
struct cmd_find_state fs;
struct hook *hook;
struct cmdq_item *new_item;
struct session *s = ne->session;
struct window *w = ne->window;
- name = notify_hooks[ne->type];
- if (name == NULL)
- return;
-
cmd_find_clear_state(&fs, NULL, 0);
- if (s != NULL && w != NULL)
- cmd_find_from_session_window(&fs, s, w);
- else if (w != NULL)
- cmd_find_from_window(&fs, w);
- else if (s != NULL && session_alive(s))
- cmd_find_from_session(&fs, s);
- else
+ if (cmd_find_empty_state(&ne->fs) || !cmd_find_valid_state(&ne->fs))
cmd_find_current(&fs, item, CMD_FIND_QUIET);
- if (cmd_find_empty_state(&fs) || !cmd_find_valid_state(&fs))
- return;
+ else
+ cmd_find_copy_state(&fs, &ne->fs);
- hook = hooks_find(fs.s->hooks, name);
+ hook = hooks_find(hooks_get(fs.s), ne->name);
if (hook == NULL)
return;
- log_debug("notify hook %s", name);
+ log_debug("notify hook %s", ne->name);
new_item = cmdq_get_command(hook->cmdlist, &fs, NULL, CMDQ_NOHOOKS);
- cmdq_format(new_item, "hook", "%s", name);
+ cmdq_format(new_item, "hook", "%s", ne->name);
if (s != NULL) {
cmdq_format(new_item, "hook_session", "$%u", s->id);
@@ -94,6 +65,8 @@ notify_hook(struct cmdq_item *item, struct notify_entry *ne)
cmdq_format(new_item, "hook_window", "@%u", w->id);
cmdq_format(new_item, "hook_window_name", "%s", w->name);
}
+ if (ne->pane != -1)
+ cmdq_format(new_item, "hook_pane", "%%%d", ne->pane);
cmdq_insert_after(item, new_item);
}
@@ -103,32 +76,23 @@ notify_callback(struct cmdq_item *item, void *data)
{
struct notify_entry *ne = data;
- switch (ne->type) {
- case NOTIFY_WINDOW_LAYOUT_CHANGED:
+ if (strcmp(ne->name, "window-layout-changed") == 0)
control_notify_window_layout_changed(ne->window);
- break;
- case NOTIFY_WINDOW_UNLINKED:
+ if (strcmp(ne->name, "window-unlinked") == 0)
control_notify_window_unlinked(ne->session, ne->window);
- break;
- case NOTIFY_WINDOW_LINKED:
+ if (strcmp(ne->name, "window-linked") == 0)
control_notify_window_linked(ne->session, ne->window);
- break;
- case NOTIFY_WINDOW_RENAMED:
+ if (strcmp(ne->name, "window-renamed") == 0)
control_notify_window_renamed(ne->window);
- break;
- case NOTIFY_ATTACHED_SESSION_CHANGED:
- control_notify_attached_session_changed(ne->client);
- break;
- case NOTIFY_SESSION_RENAMED:
+ if (strcmp(ne->name, "client-session-changed") == 0)
+ control_notify_client_session_changed(ne->client);
+ if (strcmp(ne->name, "session-renamed") == 0)
control_notify_session_renamed(ne->session);
- break;
- case NOTIFY_SESSION_CREATED:
+ if (strcmp(ne->name, "session-created") == 0)
control_notify_session_created(ne->session);
- break;
- case NOTIFY_SESSION_CLOSED:
+ if (strcmp(ne->name, "session-closed") == 0)
control_notify_session_closed(ne->session);
- break;
- }
+
notify_hook(item, ne);
if (ne->client != NULL)
@@ -137,24 +101,35 @@ notify_callback(struct cmdq_item *item, void *data)
session_unref(ne->session);
if (ne->window != NULL)
window_remove_ref(ne->window);
+
+ if (ne->fs.s != NULL)
+ session_unref(ne->fs.s);
+
+ free((void *)ne->name);
free(ne);
return (CMD_RETURN_NORMAL);
}
static void
-notify_add(enum notify_type type, struct client *c, struct session *s,
- struct window *w)
+notify_add(const char *name, struct cmd_find_state *fs, struct client *c,
+ struct session *s, struct window *w, struct window_pane *wp)
{
struct notify_entry *ne;
struct cmdq_item *new_item;
ne = xcalloc(1, sizeof *ne);
- ne->type = type;
+ ne->name = xstrdup(name);
+
ne->client = c;
ne->session = s;
ne->window = w;
+ if (wp != NULL)
+ ne->pane = wp->id;
+ else
+ ne->pane = -1;
+
if (c != NULL)
c->references++;
if (s != NULL)
@@ -162,6 +137,10 @@ notify_add(enum notify_type type, struct client *c, struct session *s,
if (w != NULL)
w->references++;
+ cmd_find_copy_state(&ne->fs, fs);
+ if (ne->fs.s != NULL)
+ ne->fs.s->references++; /* cmd_find_valid_state need session */
+
new_item = cmdq_get_callback(notify_callback, ne);
cmdq_append(NULL, new_item);
}
@@ -178,49 +157,61 @@ notify_input(struct window_pane *wp, struct evbuffer *input)
}
void
-notify_window_layout_changed(struct window *w)
+notify_client(const char *name, struct client *c)
{
- notify_add(NOTIFY_WINDOW_LAYOUT_CHANGED, NULL, NULL, w);
-}
+ struct cmd_find_state fs;
-void
-notify_window_unlinked(struct session *s, struct window *w)
-{
- notify_add(NOTIFY_WINDOW_UNLINKED, NULL, s, w);
+ if (c->session != NULL)
+ cmd_find_from_session(&fs, c->session);
+ else
+ cmd_find_current(&fs, NULL, CMD_FIND_QUIET);
+ notify_add(name, &fs, c, NULL, NULL, NULL);
}
void
-notify_window_linked(struct session *s, struct window *w)
+notify_session(const char *name, struct session *s)
{
- notify_add(NOTIFY_WINDOW_LINKED, NULL, s, w);
-}
+ struct cmd_find_state fs;
-void
-notify_window_renamed(struct window *w)
-{
- notify_add(NOTIFY_WINDOW_RENAMED, NULL, NULL, w);
+ if (session_alive(s))
+ cmd_find_from_session(&fs, s);
+ else
+ cmd_find_current(&fs, NULL, CMD_FIND_QUIET);
+ notify_add(name, &fs, NULL, s, NULL, NULL);
}
void
-notify_attached_session_changed(struct client *c)
+notify_winlink(const char *name, struct session *s, struct winlink *wl)
{
- notify_add(NOTIFY_ATTACHED_SESSION_CHANGED, c, NULL, NULL);
+ struct cmd_find_state fs;
+
+ cmd_find_from_winlink(&fs, s, wl);
+ notify_add(name, &fs, NULL, s, wl->window, NULL);
}
void
-notify_session_renamed(struct session *s)
+notify_session_window(const char *name, struct session *s, struct window *w)
{
- notify_add(NOTIFY_SESSION_RENAMED, NULL, s, NULL);
+ struct cmd_find_state fs;
+
+ cmd_find_from_session_window(&fs, s, w);
+ notify_add(name, &fs, NULL, s, w, NULL);
}
void
-notify_session_created(struct session *s)
+notify_window(const char *name, struct window *w)
{
- notify_add(NOTIFY_SESSION_CREATED, NULL, s, NULL);
+ struct cmd_find_state fs;
+
+ cmd_find_from_window(&fs, w);
+ notify_add(name, &fs, NULL, NULL, w, NULL);
}
void
-notify_session_closed(struct session *s)
+notify_pane(const char *name, struct window_pane *wp)
{
- notify_add(NOTIFY_SESSION_CLOSED, NULL, s, NULL);
+ struct cmd_find_state fs;
+
+ cmd_find_from_pane(&fs, wp);
+ notify_add(name, &fs, NULL, NULL, NULL, wp);
}
diff --git a/resize.c b/resize.c
index 831302b1..2d3f02cc 100644
--- a/resize.c
+++ b/resize.c
@@ -156,6 +156,6 @@ recalculate_sizes(void)
}
server_redraw_window(w);
- notify_window_layout_changed(w);
+ notify_window("window-layout-changed", w);
}
}
diff --git a/server-client.c b/server-client.c
index 4437fe75..846ff4df 100644
--- a/server-client.c
+++ b/server-client.c
@@ -290,7 +290,7 @@ server_client_detach(struct client *c, enum msgtype msgtype)
if (s == NULL)
return;
- hooks_run(c->session->hooks, c, NULL, "client-detached");
+ notify_client("client-detached", c);
proc_send_s(c->peer, msgtype, s->name);
}
@@ -1218,7 +1218,7 @@ server_client_dispatch(struct imsg *imsg, void *arg)
server_redraw_client(c);
}
if (c->session != NULL)
- hooks_run(c->session->hooks, c, NULL, "client-resized");
+ notify_client("client-resized", c);
break;
case MSG_EXITING:
if (datalen != 0)
diff --git a/server-fn.c b/server-fn.c
index 70569945..83b3fe86 100644
--- a/server-fn.c
+++ b/server-fn.c
@@ -256,7 +256,8 @@ server_link_window(struct session *src, struct winlink *srcwl,
* Can't use session_detach as it will destroy session
* if this makes it empty.
*/
- notify_window_unlinked(dst, dstwl->window);
+ notify_session_window("window-unlinked", dst,
+ dstwl->window);
dstwl->flags &= ~WINLINK_ALERTFLAGS;
winlink_stack_remove(&dst->lastw, dstwl);
winlink_remove(&dst->windows, dstwl);
@@ -292,13 +293,12 @@ server_unlink_window(struct session *s, struct winlink *wl)
}
void
-server_destroy_pane(struct window_pane *wp, int hooks)
+server_destroy_pane(struct window_pane *wp, int notify)
{
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) {
@@ -313,6 +313,10 @@ server_destroy_pane(struct window_pane *wp, int hooks)
if (options_get_number(w->options, "remain-on-exit")) {
if (old_fd == -1)
return;
+
+ if (notify)
+ notify_pane("pane-died", wp);
+
screen_write_start(&ctx, wp, &wp->base);
screen_write_scrollregion(&ctx, 0, screen_size_y(ctx.s) - 1);
screen_write_cursormove(&ctx, 0, screen_size_y(ctx.s) - 1);
@@ -323,18 +327,16 @@ server_destroy_pane(struct window_pane *wp, int hooks)
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;
}
+ if (notify)
+ notify_pane("pane-exited", wp);
+
server_unzoom_window(w);
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
@@ -395,7 +397,7 @@ server_destroy_session(struct session *s)
c->session = s_new;
server_client_set_key_table(c, NULL);
status_timer_start(c);
- notify_attached_session_changed(c);
+ notify_client("client-session-changed", c);
session_update_activity(s_new, NULL);
gettimeofday(&s_new->last_attached_time, NULL);
server_redraw_client(c);
diff --git a/session.c b/session.c
index 4998b284..758932e3 100644
--- a/session.c
+++ b/session.c
@@ -168,7 +168,7 @@ session_create(const char *name, int argc, char **argv, const char *path,
}
log_debug("session %s created", s->name);
- notify_session_created(s);
+ notify_session("session-created", s);
return (s);
}
@@ -213,7 +213,7 @@ session_destroy(struct session *s)
s->curw = NULL;
RB_REMOVE(sessions, &sessions, s);
- notify_session_closed(s);
+ notify_session("session-closed", s);
free(s->tio);
@@ -226,7 +226,7 @@ session_destroy(struct session *s)
winlink_stack_remove(&s->lastw, TAILQ_FIRST(&s->lastw));
while (!RB_EMPTY(&s->windows)) {
wl = RB_ROOT(&s->windows);
- notify_window_unlinked(s, wl->window);
+ notify_session_window("window-unlinked", s, wl->window);
winlink_remove(&s->windows, wl);
}
@@ -356,7 +356,7 @@ session_new(struct session *s, const char *name, int argc, char **argv,
return (NULL);
}
winlink_set_window(wl, w);
- notify_window_linked(s, w);
+ notify_session_window("window-linked", s, w);
environ_free(env);
session_group_synchronize_from(s);
@@ -374,7 +374,7 @@ session_attach(struct session *s, struct window *w, int idx, char **cause)
return (NULL);
}
winlink_set_window(wl, w);
- notify_window_linked(s, w);
+ notify_session_window("window-linked", s, w);
session_group_synchronize_from(s);
return (wl);
@@ -390,7 +390,7 @@ session_detach(struct session *s, struct winlink *wl)
session_next(s, 0);
wl->flags &= ~WINLINK_ALERTFLAGS;
- notify_window_unlinked(s, wl->window);
+ notify_session_window("window-unlinked", s, wl->window);
winlink_stack_remove(&s->lastw, wl);
winlink_remove(&s->windows, wl);
@@ -680,7 +680,7 @@ session_group_synchronize1(struct session *target, struct session *s)
RB_FOREACH(wl, winlinks, ww) {
wl2 = winlink_add(&s->windows, wl->idx);
winlink_set_window(wl2, wl->window);
- notify_window_linked(s, wl2->window);
+ notify_session_window("window-linked", s, wl2->window);
wl2->flags |= wl->flags & WINLINK_ALERTFLAGS;
}
@@ -704,7 +704,7 @@ session_group_synchronize1(struct session *target, struct session *s)
wl = RB_ROOT(&old_windows);
wl2 = winlink_find_by_window_id(&s->windows, wl->window->id);
if (wl2 == NULL)
- notify_window_unlinked(s, wl->window);
+ notify_session_window("window-unlinked", s, wl->window);
winlink_remove(&old_windows, wl);
}
}
diff --git a/tmux.1 b/tmux.1
index dc621e63..037c357a 100644
--- a/tmux.1
+++ b/tmux.1
@@ -3242,6 +3242,8 @@ Run when a client is attached.
Run when a client is detached
.It client-resized
Run when a client is resized.
+.It client-session-changed
+Run when a client's attached session is changed.
.It pane-died
Run when the program running in a pane exits, but
.Ic remain-on-exit
@@ -3254,8 +3256,12 @@ Run when a new session created.
Run when a session closed.
.It session-renamed
Run when a session is renamed.
+.It window-linked
+Run when a window is linked into a session.
.It window-renamed
Run when a window is renamed.
+.It window-unlinked
+Run when a window is unlinked from a session.
.El
.Pp
Hooks are managed with these commands:
@@ -3475,6 +3481,7 @@ The following variables are available, where appropriate:
.It Li "history_limit" Ta "" Ta "Maximum window history lines"
.It Li "history_size" Ta "" Ta "Size of history in bytes"
.It Li "hook" Ta "" Ta "Name of running hook, if any"
+.It Li "hook_pane" Ta "" Ta "ID of pane where hook was run, if any"
.It Li "hook_session" Ta "" Ta "ID of session where hook was run, if any"
.It Li "hook_session_name" Ta "" Ta "Name of session where hook was run, if any"
.It Li "hook_window" Ta "" Ta "ID of window where hook was run, if any"
diff --git a/tmux.h b/tmux.h
index 1c25e2a7..ed349330 100644
--- a/tmux.h
+++ b/tmux.h
@@ -1585,14 +1585,12 @@ enum mode_key_cmd mode_key_lookup(struct mode_key_data *, key_code);
/* notify.c */
void notify_input(struct window_pane *, struct evbuffer *);
-void notify_window_layout_changed(struct window *);
-void notify_window_unlinked(struct session *, struct window *);
-void notify_window_linked(struct session *, struct window *);
-void notify_window_renamed(struct window *);
-void notify_attached_session_changed(struct client *);
-void notify_session_renamed(struct session *);
-void notify_session_created(struct session *);
-void notify_session_closed(struct session *);
+void notify_client(const char *, struct client *);
+void notify_session(const char *, struct session *);
+void notify_winlink(const char *, struct session *, struct winlink *);
+void notify_session_window(const char *, struct session *, struct window *);
+void notify_window(const char *, struct window *);
+void notify_pane(const char *, struct window_pane *);
/* options.c */
struct options *options_create(struct options *);
@@ -2211,7 +2209,7 @@ void control_notify_window_layout_changed(struct window *);
void control_notify_window_unlinked(struct session *, struct window *);
void control_notify_window_linked(struct session *, struct window *);
void control_notify_window_renamed(struct window *);
-void control_notify_attached_session_changed(struct client *);
+void control_notify_client_session_changed(struct client *);
void control_notify_session_renamed(struct session *);
void control_notify_session_created(struct session *);
void control_notify_session_closed(struct session *);
diff --git a/window.c b/window.c
index 9ec99f3a..8b215d78 100644
--- a/window.c
+++ b/window.c
@@ -390,7 +390,7 @@ window_set_name(struct window *w, const char *new_name)
{
free(w->name);
w->name = xstrdup(new_name);
- notify_window_renamed(w);
+ notify_window("window-renamed", w);
}
void
@@ -532,7 +532,7 @@ window_zoom(struct window_pane *wp)
w->saved_layout_root = w->layout_root;
layout_init(w, wp);
w->flags |= WINDOW_ZOOMED;
- notify_window_layout_changed(w);
+ notify_window("window-layout-changed", w);
return (0);
}
@@ -555,7 +555,7 @@ window_unzoom(struct window *w)
wp->saved_layout_cell = NULL;
}
layout_fix_panes(w, w->sx, w->sy);
- notify_window_layout_changed(w);
+ notify_window("window-layout-changed", w);
return (0);
}