diff options
author | 2016-10-16 22:18:04 +0000 | |
---|---|---|
committer | 2016-10-16 22:18:04 +0000 | |
commit | aff3adff5a384916f6cbc3d13d59bc012e31020c (patch) | |
tree | 97e7c323a1273035b043d659d34658308566ff2f /usr.bin | |
parent | Fix trailing whitespace and shorten long lines. (diff) | |
download | wireguard-openbsd-aff3adff5a384916f6cbc3d13d59bc012e31020c.tar.xz wireguard-openbsd-aff3adff5a384916f6cbc3d13d59bc012e31020c.zip |
Use notifys for alerts too.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/tmux/alerts.c | 13 | ||||
-rw-r--r-- | usr.bin/tmux/notify.c | 58 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 3 |
3 files changed, 45 insertions, 29 deletions
diff --git a/usr.bin/tmux/alerts.c b/usr.bin/tmux/alerts.c index 253b414ca81..c2bd6464f63 100644 --- a/usr.bin/tmux/alerts.c +++ b/usr.bin/tmux/alerts.c @@ -1,4 +1,4 @@ -/* $OpenBSD: alerts.c,v 1.12 2016/10/03 22:52:11 nicm Exp $ */ +/* $OpenBSD: alerts.c,v 1.13 2016/10/16 22:18:04 nicm Exp $ */ /* * Copyright (c) 2015 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -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/usr.bin/tmux/notify.c b/usr.bin/tmux/notify.c index 8d006fa2d46..9b272ba9bf1 100644 --- a/usr.bin/tmux/notify.c +++ b/usr.bin/tmux/notify.c @@ -1,4 +1,4 @@ -/* $OpenBSD: notify.c,v 1.18 2016/10/16 22:06:40 nicm Exp $ */ +/* $OpenBSD: notify.c,v 1.19 2016/10/16 22:18:04 nicm Exp $ */ /* * Copyright (c) 2012 George Nachman <tmux@georgester.com> @@ -113,8 +113,8 @@ notify_callback(struct cmdq_item *item, void *data) } static void -notify_add(const char *name, struct client *c, struct session *s, - struct window *w, struct window_pane *wp) +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; @@ -138,17 +138,7 @@ notify_add(const char *name, struct client *c, struct session *s, if (w != NULL) w->references++; - cmd_find_clear_state(&ne->fs, NULL, 0); - if (s != NULL && w != NULL) - cmd_find_from_session_window(&ne->fs, s, w); - else if (w != NULL) - cmd_find_from_window(&ne->fs, w); - else if (s != NULL && session_alive(s)) - cmd_find_from_session(&ne->fs, s); - else if (wp != NULL) - cmd_find_from_pane(&ne->fs, wp); - else - cmd_find_current(&ne->fs, NULL, CMD_FIND_QUIET); + cmd_find_copy_state(&ne->fs, fs); if (ne->fs.s != NULL) ne->fs.s->references++; /* cmd_find_valid_state need session */ @@ -170,29 +160,59 @@ notify_input(struct window_pane *wp, struct evbuffer *input) void notify_client(const char *name, struct client *c) { - notify_add(name, c, NULL, NULL, NULL); + struct cmd_find_state fs; + + 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_session(const char *name, struct session *s) { - notify_add(name, NULL, s, NULL, NULL); + struct cmd_find_state fs; + + 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_winlink(const char *name, struct session *s, struct winlink *wl) +{ + struct cmd_find_state fs; + + cmd_find_from_winlink(&fs, s, wl); + notify_add(name, &fs, NULL, s, wl->window, NULL); } void notify_session_window(const char *name, struct session *s, struct window *w) { - notify_add(name, NULL, s, w, NULL); + struct cmd_find_state fs; + + cmd_find_from_session_window(&fs, s, w); + notify_add(name, &fs, NULL, s, w, NULL); } void notify_window(const char *name, struct window *w) { - notify_add(name, NULL, NULL, w, NULL); + struct cmd_find_state fs; + + cmd_find_from_window(&fs, w); + notify_add(name, &fs, NULL, NULL, w, NULL); } void notify_pane(const char *name, struct window_pane *wp) { - notify_add(name, NULL, NULL, NULL, wp); + struct cmd_find_state fs; + + cmd_find_from_pane(&fs, wp); + notify_add(name, &fs, NULL, NULL, NULL, wp); } diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 17732bd522f..d153881036a 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.671 2016/10/16 22:06:40 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.672 2016/10/16 22:18:04 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -1585,6 +1585,7 @@ enum mode_key_cmd mode_key_lookup(struct mode_key_data *, key_code); void notify_input(struct window_pane *, struct evbuffer *); 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 *); |