summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2015-12-07 09:47:42 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2015-12-07 09:47:42 +0000
commitd168ef8fbaf7a045136d58abbabe59665499a9eb (patch)
treebdf0dbf03a8ffa3e43f9dbe620b3851788d2565f /usr.bin
parent403489d4a2346ec2e013afe2ef03797a31864529 (diff)
Fix bell indicators across detach, reported by Torbjorn Lonnemark, diff
from Thomas Adam.
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/tmux/alerts.c46
-rw-r--r--usr.bin/tmux/cmd-attach-session.c3
-rw-r--r--usr.bin/tmux/tmux.h3
3 files changed, 38 insertions, 14 deletions
diff --git a/usr.bin/tmux/alerts.c b/usr.bin/tmux/alerts.c
index 1e3e2dcbe5f..d98aef8b5a9 100644
--- a/usr.bin/tmux/alerts.c
+++ b/usr.bin/tmux/alerts.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: alerts.c,v 1.7 2015/11/20 16:33:46 nicm Exp $ */
+/* $OpenBSD: alerts.c,v 1.8 2015/12/07 09:47:41 nicm Exp $ */
/*
* Copyright (c) 2015 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -29,6 +29,7 @@ int alerts_enabled(struct window *, int);
void alerts_callback(int, short, void *);
void alerts_reset(struct window *);
+int alerts_check_all(struct session *, struct winlink *);
int alerts_check_bell(struct session *, struct winlink *);
int alerts_check_activity(struct session *, struct winlink *);
int alerts_check_silence(struct session *, struct winlink *);
@@ -54,16 +55,14 @@ 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;
flags = w->flags;
- alerts = alerts_check_bell(s, wl);
- alerts |= alerts_check_activity(s, wl);
- alerts |= alerts_check_silence(s, wl);
- if (alerts != 0)
- server_status_session(s);
+ alerts = alerts_check_all(s, wl);
log_debug("%s:%d @%u alerts check, alerts %#x, "
"flags %#x", s->name, wl->idx, w->id,
@@ -75,6 +74,29 @@ alerts_callback(__unused int fd, __unused short events, __unused void *arg)
}
int
+alerts_check_all(struct session *s, struct winlink *wl)
+{
+ int alerts;
+
+ alerts = alerts_check_bell(s, wl);
+ alerts |= alerts_check_activity(s, wl);
+ alerts |= alerts_check_silence(s, wl);
+ if (alerts != 0)
+ server_status_session(s);
+
+ return (alerts);
+}
+
+void
+alerts_check_session(struct session *s)
+{
+ struct winlink *wl;
+
+ RB_FOREACH(wl, winlinks, &s->windows)
+ alerts_check_all(s, wl);
+}
+
+int
alerts_enabled(struct window *w, int flags)
{
if (flags & WINDOW_BELL)
@@ -143,12 +165,12 @@ alerts_check_bell(struct session *s, struct winlink *wl)
struct window *w = wl->window;
int action, visual;
- if (!(w->flags & WINDOW_BELL) || wl->flags & WINLINK_BELL)
+ if (!(w->flags & WINDOW_BELL))
return (0);
- if (s->curw != wl || s->flags & SESSION_UNATTACHED)
+ if (s->curw != wl) {
wl->flags |= WINLINK_BELL;
- if (s->flags & SESSION_UNATTACHED)
- return (0);
+ w->flags &= ~WINDOW_BELL;
+ }
if (s->curw->window == w)
w->flags &= ~WINDOW_BELL;
@@ -190,7 +212,7 @@ alerts_check_activity(struct session *s, struct winlink *wl)
if (!(w->flags & WINDOW_ACTIVITY) || wl->flags & WINLINK_ACTIVITY)
return (0);
- if (s->curw == wl && !(s->flags & SESSION_UNATTACHED))
+ if (s->curw == wl)
return (0);
if (!options_get_number(w->options, "monitor-activity"))
@@ -222,7 +244,7 @@ alerts_check_silence(struct session *s, struct winlink *wl)
if (!(w->flags & WINDOW_SILENCE) || wl->flags & WINLINK_SILENCE)
return (0);
- if (s->curw == wl && !(s->flags & SESSION_UNATTACHED))
+ if (s->curw == wl)
return (0);
if (options_get_number(w->options, "monitor-silence") == 0)
diff --git a/usr.bin/tmux/cmd-attach-session.c b/usr.bin/tmux/cmd-attach-session.c
index 731b6277c9b..b1f3cef4cb6 100644
--- a/usr.bin/tmux/cmd-attach-session.c
+++ b/usr.bin/tmux/cmd-attach-session.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-attach-session.c,v 1.49 2015/11/05 23:32:21 nicm Exp $ */
+/* $OpenBSD: cmd-attach-session.c,v 1.50 2015/12/07 09:47:41 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -162,6 +162,7 @@ cmd_attach_session(struct cmd_q *cmdq, const char *tflag, int dflag, int rflag,
cmdq->client_exit = 0;
}
recalculate_sizes();
+ alerts_check_session(s);
server_update_socket();
return (CMD_RETURN_NORMAL);
diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h
index 791f044db2f..3cad1742b29 100644
--- a/usr.bin/tmux/tmux.h
+++ b/usr.bin/tmux/tmux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tmux.h,v 1.593 2015/11/27 15:06:43 nicm Exp $ */
+/* $OpenBSD: tmux.h,v 1.594 2015/12/07 09:47:41 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -1757,6 +1757,7 @@ const char *key_string_lookup_key(key_code);
/* alerts.c */
void alerts_reset_all(void);
void alerts_queue(struct window *, int);
+void alerts_check_session(struct session *);
/* server.c */
extern struct tmuxproc *server_proc;