summaryrefslogtreecommitdiffstats
path: root/alerts.c
diff options
context:
space:
mode:
authornicm <nicm>2016-01-16 00:36:53 +0000
committernicm <nicm>2016-01-16 00:36:53 +0000
commitc9815307ebe8b729504d383904ae3ef3b862cf11 (patch)
tree172486debb60fc07e4a72393e218c89957f3e780 /alerts.c
parentd551ab8e5cfb00fbb7a79e7f0c3f4f2780fc6824 (diff)
Add hooks for alerts (bell, silence, activity), from Thomas Adam.
Diffstat (limited to 'alerts.c')
-rw-r--r--alerts.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/alerts.c b/alerts.c
index 536ea750..d1fb0fce 100644
--- a/alerts.c
+++ b/alerts.c
@@ -29,6 +29,7 @@ int alerts_enabled(struct window *, int);
void alerts_callback(int, short, void *);
void alerts_reset(struct window *);
+void alerts_run_hook(struct session *, struct winlink *, int);
int alerts_check_all(struct session *, struct winlink *);
int alerts_check_bell(struct session *, struct winlink *);
int alerts_check_activity(struct session *, struct winlink *);
@@ -55,8 +56,6 @@ alerts_callback(__unused int fd, __unused short events, __unused void *arg)
RB_FOREACH(w, windows, &windows) {
RB_FOREACH(s, sessions, &sessions) {
- if (s->flags & SESSION_UNATTACHED)
- continue;
RB_FOREACH(wl, winlinks, &s->windows) {
if (wl->window != w)
continue;
@@ -73,6 +72,22 @@ alerts_callback(__unused int fd, __unused short events, __unused void *arg)
alerts_fired = 0;
}
+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");
+ if (flags & WINDOW_SILENCE)
+ hooks_run(s->hooks, NULL, &fs, "alert-silence");
+ if (flags & WINDOW_ACTIVITY)
+ hooks_run(s->hooks, NULL, &fs, "alert-activity");
+}
+
int
alerts_check_all(struct session *s, struct winlink *wl)
{
@@ -81,8 +96,10 @@ alerts_check_all(struct session *s, struct winlink *wl)
alerts = alerts_check_bell(s, wl);
alerts |= alerts_check_activity(s, wl);
alerts |= alerts_check_silence(s, wl);
- if (alerts != 0)
+ if (alerts != 0) {
+ alerts_run_hook(s, wl, alerts);
server_status_session(s);
+ }
return (alerts);
}