OK I have applied the main diff and also tried to fix the problem you saw. Both changes are in OpenBSD now, they will be in GitHub later, let me know if you see any problems.
Thanks! On Wed, Jul 26, 2017 at 05:05:21PM +0200, Yvain Thonnart wrote: > Sorry, missed the two important lines from the bash prompt: > in .tmux.conf: > ----------------- > set -g activity-action other > set -g silence-action current > set -g visual-activity on > set -g visual-silence on > at bash prompt within tmux: > ------------------------------------ > tmux setw monitor-silence 10 > tmux setw monitor-activity on > while true; do echo hello; sleep 1 ; done > hello > hello > [...] > hello > [Silence in window 0] > 2017-07-26 17:00 GMT+02:00 Yvain Thonnart <[email protected]>: > > Thank you. > I've been testing this patch for different configurations, it's very > flexible. > It runs fine on my side in all reasonable configurations. > I'd be glad that you would merge it to master somedaya*| > To be thorough, though, I've found a configuration which is totally > unreasonable, but which reports invalid alerts: > in .tmux.conf: > ----------------- > set -g activity-action other > set -g silence-action current > set -g visual-activity on > set -g visual-silence on > at bash prompt within tmux: > ------------------------------------ > while true; do echo hello; sleep 1 ; done > hello > hello > [...] > hello > [Silence in window 0] > It is the combination of both monitor-silence and monitor-activity which > apparently resets the alert timer due to activity, which then fires > after 10 seconds, falsely reporting silence. > I haven't managed to get the whole callback flow in your code to give > you more clues. > I attached the server log in case this matters to you. > I guess somebody at least as retort as myself might bump on this if > using this in his/her .tmux.conf: > set -g activity-action other > set -g silence-action current > set -g visual-activity on > set -g visual-silence on > set -g monitor-silence 10 > set -g monitor-activity on > Hoping that the filter on activity->other and silence->current will hide > the events set by default on any window. > Yet as this configuration is unreasonable, this may not need to be > fixed... > Thanks again for this, and for all your impressive work on this program, > Best regards, > Yvain > 2017-07-26 14:43 GMT+02:00 Nicholas Marriott > <[email protected]>: > > Hi > > OK the problem with making it work exactly like bell-action is that > bell-action "none" suppresses visual bell as well - this means that if > the default for bell-on-alert is "none" then anyone who currently uses > monitor-activity will need to add the option which is not ideal. > > Also it means bell-on-alert no longer serves its original purpose of > allowing both visual and bell for activity and silence. > > And bell-on-alert is not a good name for it now. > > So here is what I suggest: > > - We remove bell-on-alert entirely. > > - Instead we add activity-action and silence-action which are > equivalent > A to bell-action but can default to "other" instead of "any". > > - We add a new value to visual-* "both" so it is still possible to get > a > A bell and a message. > > This way all three are consistent. > > I don't much like adding a new option but it is less confusing. > > Please try this: > > Index: alerts.c > =================================================================== > RCS file: /cvs/src/usr.bin/tmux/alerts.c,v > retrieving revision 1.20 > diff -u -p -r1.20 alerts.c > --- alerts.cA A 28 Jun 2017 06:45:31 -0000A A A 1.20 > +++ alerts.cA A 26 Jul 2017 12:42:57 -0000 > @@ -34,9 +34,8 @@ static intA A alerts_check_all(struct windo > A static intA A A alerts_check_bell(struct window *); > A static intA A A alerts_check_activity(struct window *); > A static intA A A alerts_check_silence(struct window *); > -static void printflike(2, 3) alerts_set_message(struct session *, > const char *, > -A A A A A A A A A A ...); > -static voidA A alerts_ring_bell(struct session *); > +static voidA A alerts_set_message(struct session *, struct window > *, > +A A A A A A A A A A struct winlink *, const char *, int, > int); > > A static TAILQ_HEAD(, window) alerts_list = > TAILQ_HEAD_INITIALIZER(alerts_list); > > @@ -162,11 +161,8 @@ alerts_queue(struct window *w, int flags > A static int > A alerts_check_bell(struct window *w) > A { > -A A A A struct windowA A *ws; > A A A A struct winlinkA *wl; > A A A A struct sessionA *s; > -A A A A struct clientA A *c; > -A A A A intA A A A A A A action, visual; > > A A A A if (~w->flags & WINDOW_BELL) > A A A A A A A A return (0); > @@ -187,33 +183,9 @@ alerts_check_bell(struct window *w) > A A A A A A A A A A A A continue; > A A A A A A A A s->flags |= SESSION_ALERTED; > > -A A A A A A A A action = options_get_number(s->options, > "bell-action"); > -A A A A A A A A if (action == BELL_NONE) > -A A A A A A A A A A A A return (0); > - > -A A A A A A A A visual = options_get_number(s->options, > "visual-bell"); > -A A A A A A A A TAILQ_FOREACH(c, &clients, entry) { > -A A A A A A A A A A A A if (c->session != s || c->flags & > CLIENT_CONTROL) > -A A A A A A A A A A A A A A A A continue; > -A A A A A A A A A A A A ws = c->session->curw->window; > - > -A A A A A A A A A A A A if (action == BELL_CURRENT && ws > != w) > -A A A A A A A A A A A A A A A A action = BELL_NONE; > -A A A A A A A A A A A A if (action == BELL_OTHER && ws != > w) > -A A A A A A A A A A A A A A A A action = BELL_NONE; > - > -A A A A A A A A A A A A if (!visual) { > -A A A A A A A A A A A A A A A A if (action != > BELL_NONE) > -A A A A A A A A A A A A A A A A A A A > A tty_putcode(&c->tty, TTYC_BEL); > -A A A A A A A A A A A A A A A A continue; > -A A A A A A A A A A A A } > -A A A A A A A A A A A A if (action == BELL_CURRENT) > -A A A A A A A A A A A A A A A A status_message_set(c, > "Bell in current window"); > -A A A A A A A A A A A A else if (action != BELL_NONE) { > -A A A A A A A A A A A A A A A A status_message_set(c, > "Bell in window %d", > -A A A A A A A A A A A A A A A A A A wl->idx); > -A A A A A A A A A A A A } > -A A A A A A A A } > +A A A A A A A A alerts_set_message(s, w, wl, "Bell", > +A A A A A A A A A A options_get_number(s->options, > "bell-action"), > +A A A A A A A A A A options_get_number(s->options, > "visual-bell")); > A A A A } > > A A A A return (WINDOW_BELL); > @@ -237,20 +209,18 @@ alerts_check_activity(struct window *w) > A A A A A A A A if (wl->flags & WINLINK_ACTIVITY) > A A A A A A A A A A A A continue; > A A A A A A A A s = wl->session; > -A A A A A A A A if (s->curw == wl) > -A A A A A A A A A A A A continue; > - > -A A A A A A A A wl->flags |= WINLINK_ACTIVITY; > -A A A A A A A A notify_winlink("alert-activity", wl); > +A A A A A A A A if (s->curw != wl) { > +A A A A A A A A A A A A wl->flags |= WINLINK_ACTIVITY; > +A A A A A A A A A A A A notify_winlink("alert-activity", > wl); > +A A A A A A A A } > > A A A A A A A A if (s->flags & SESSION_ALERTED) > A A A A A A A A A A A A continue; > A A A A A A A A s->flags |= SESSION_ALERTED; > > -A A A A A A A A if (options_get_number(s->options, > "bell-on-alert")) > -A A A A A A A A A A A A alerts_ring_bell(s); > -A A A A A A A A if (options_get_number(s->options, > "visual-activity")) > -A A A A A A A A A A A A alerts_set_message(s, "Activity in > window %d", wl->idx); > +A A A A A A A A alerts_set_message(s, w, wl, "Activity", > +A A A A A A A A A A options_get_number(s->options, > "activity-action"), > +A A A A A A A A A A options_get_number(s->options, > "visual-activity")); > A A A A } > > A A A A return (WINDOW_ACTIVITY); > @@ -264,7 +234,7 @@ alerts_check_silence(struct window *w) > A A A A if (~w->flags & WINDOW_SILENCE) > A A A A A A A A return (0); > -A A A A if (!options_get_number(w->options, "monitor-silence")) > +A A A A if (options_get_number(w->options, "monitor-silence") == > 0) > A A A A A A A A return (0); > > A A A A TAILQ_FOREACH(wl, &w->winlinks, wentry) > @@ -274,50 +244,66 @@ alerts_check_silence(struct window *w) > A A A A A A A A if (wl->flags & WINLINK_SILENCE) > A A A A A A A A A A A A continue; > A A A A A A A A s = wl->session; > -A A A A A A A A if (s->curw == wl) > -A A A A A A A A A A A A continue; > -A A A A A A A A wl->flags |= WINLINK_SILENCE; > -A A A A A A A A notify_winlink("alert-silence", wl); > +A A A A A A A A if (s->curw != wl) { > +A A A A A A A A A A A A wl->flags |= WINLINK_SILENCE; > +A A A A A A A A A A A A notify_winlink("alert-silence", > wl); > +A A A A A A A A } > > A A A A A A A A if (s->flags & SESSION_ALERTED) > A A A A A A A A A A A A continue; > A A A A A A A A s->flags |= SESSION_ALERTED; > > -A A A A A A A A if (options_get_number(s->options, > "bell-on-alert")) > -A A A A A A A A A A A A alerts_ring_bell(s); > -A A A A A A A A if (options_get_number(s->options, > "visual-silence")) > -A A A A A A A A A A A A alerts_set_message(s, "Silence in > window %d", wl->idx); > +A A A A A A A A alerts_set_message(s, w, wl, "Silence", > +A A A A A A A A A A options_get_number(s->options, > "silence-action"), > +A A A A A A A A A A options_get_number(s->options, > "visual-silence")); > A A A A } > > A A A A return (WINDOW_SILENCE); > A } > > A static void > -alerts_set_message(struct session *s, const char *fmt, ...) > +alerts_set_message(struct session *s, struct window *w, struct > winlink *wl, > +A A const char *type, int action, int visual) > A { > A A A A struct clientA A *c; > -A A A A va_listA A A A A ap; > -A A A A charA A A A A A *message; > +A A A A intA A A A A A A flag; > > -A A A A va_start(ap, fmt); > -A A A A xvasprintf(&message, fmt, ap); > -A A A A va_end(ap); > +A A A A /* > +A A A A * We have found an alert (bell, activity or silence), so > we need > +A A A A * to notify the user. For each client attached to this > session, > +A A A A * decide whether a bell (or visual message) is needed. > +A A A A * > +A A A A * {bell,activity,silence}-action determines when we > notify: none means > +A A A A * nothing happens, current means we only do something for > the current > +A A A A * window and other means only for windows other than the > current. > +A A A A * > +A A A A * If visual-{bell,activity,silence} is on, then a message > is > +A A A A * substituted for a bell; if it is off, a bell is sent as > normal; both > +A A A A * mean both a bell and visual message is sent. > +A A A A */ > +A A A A if (action == BELL_NONE) > +A A A A A A A A return; > A A A A TAILQ_FOREACH(c, &clients, entry) { > -A A A A A A A A if (c->session == s) > -A A A A A A A A A A A A status_message_set(c, "%s", > message); > -A A A A } > - > -A A A A free(message); > -} > - > -static void > -alerts_ring_bell(struct session *s) > -{ > -A A A A struct clientA A *c; > +A A A A A A A A if (c->session != s || c->flags & > CLIENT_CONTROL) > +A A A A A A A A A A A A continue; > +A A A A A A A A flag = 0; > +A A A A A A A A if (action == BELL_ANY) > +A A A A A A A A A A A A flag = 1; > +A A A A A A A A else if (action == BELL_CURRENT) > +A A A A A A A A A A A A flag = (c->session->curw->window > == w); > +A A A A A A A A else if (action == BELL_OTHER) > +A A A A A A A A A A A A flag = (c->session->curw->window > != w); > +A A A A A A A A if (!flag) > +A A A A A A A A A A A A continue; > > -A A A A TAILQ_FOREACH(c, &clients, entry) { > -A A A A A A A A if (c->session == s && !(c->flags & > CLIENT_CONTROL)) > +A A A A A A A A if (visual == VISUAL_OFF || visual == > VISUAL_BOTH) > A A A A A A A A A A A A tty_putcode(&c->tty, TTYC_BEL); > +A A A A A A A A if (visual == VISUAL_OFF) > +A A A A A A A A A A A A continue; > +A A A A A A A A if (c->session->curw->window == w) > +A A A A A A A A A A A A status_message_set(c, "%s in > current window", type); > +A A A A A A A A else > +A A A A A A A A A A A A status_message_set(c, "%s in > window %d", type, wl->idx); > A A A A } > A } > Index: options-table.c > =================================================================== > RCS file: /cvs/src/usr.bin/tmux/options-table.c,v > retrieving revision 1.90 > diff -u -p -r1.90 options-table.c > --- options-table.cA A A 23 Jun 2017 15:36:52 -0000A A A 1.90 > +++ options-table.cA A A 26 Jul 2017 12:42:57 -0000 > @@ -51,6 +51,9 @@ static const char *options_table_status_ > A static const char *options_table_bell_action_list[] = { > A A A A "none", "any", "current", "other", NULL > A }; > +static const char *options_table_visual_bell_list[] = { > +A A A A "off", "on", "both", NULL > +}; > A static const char *options_table_pane_status_list[] = { > A A A A "off", "top", "bottom", NULL > A }; > @@ -143,6 +146,13 @@ const struct options_table_entry options > A A A A A .separator = "," > A A A A }, > > +A A A A { .name = "activity-action", > +A A A A A .type = OPTIONS_TABLE_CHOICE, > +A A A A A .scope = OPTIONS_TABLE_SESSION, > +A A A A A .choices = options_table_bell_action_list, > +A A A A A .default_num = BELL_OTHER > +A A A A }, > + > A A A A { .name = "assume-paste-time", > A A A A A .type = OPTIONS_TABLE_NUMBER, > A A A A A .scope = OPTIONS_TABLE_SESSION, > @@ -166,12 +176,6 @@ const struct options_table_entry options > A A A A A .default_num = BELL_ANY > A A A A }, > > -A A A A { .name = "bell-on-alert", > -A A A A A .type = OPTIONS_TABLE_FLAG, > -A A A A A .scope = OPTIONS_TABLE_SESSION, > -A A A A A .default_num = 0 > -A A A A }, > - > A A A A { .name = "default-command", > A A A A A .type = OPTIONS_TABLE_STRING, > A A A A A .scope = OPTIONS_TABLE_SESSION, > @@ -350,6 +354,13 @@ const struct options_table_entry options > A A A A A .default_str = "#S:#I:#W - \"#T\" #{session_alerts}" > A A A A }, > > +A A A A { .name = "silence-action", > +A A A A A .type = OPTIONS_TABLE_CHOICE, > +A A A A A .scope = OPTIONS_TABLE_SESSION, > +A A A A A .choices = options_table_bell_action_list, > +A A A A A .default_num = BELL_OTHER > +A A A A }, > + > A A A A { .name = "status", > A A A A A .type = OPTIONS_TABLE_FLAG, > A A A A A .scope = OPTIONS_TABLE_SESSION, > @@ -502,21 +513,24 @@ const struct options_table_entry options > A A A A }, > > A A A A { .name = "visual-activity", > -A A A A A .type = OPTIONS_TABLE_FLAG, > +A A A A A .type = OPTIONS_TABLE_CHOICE, > A A A A A .scope = OPTIONS_TABLE_SESSION, > -A A A A A .default_num = 0 > +A A A A A .choices = options_table_visual_bell_list, > +A A A A A .default_num = VISUAL_OFF > A A A A }, > > A A A A { .name = "visual-bell", > -A A A A A .type = OPTIONS_TABLE_FLAG, > +A A A A A .type = OPTIONS_TABLE_CHOICE, > A A A A A .scope = OPTIONS_TABLE_SESSION, > -A A A A A .default_num = 0 > +A A A A A .choices = options_table_visual_bell_list, > +A A A A A .default_num = VISUAL_OFF > A A A A }, > > A A A A { .name = "visual-silence", > -A A A A A .type = OPTIONS_TABLE_FLAG, > +A A A A A .type = OPTIONS_TABLE_CHOICE, > A A A A A .scope = OPTIONS_TABLE_SESSION, > -A A A A A .default_num = 0 > +A A A A A .choices = options_table_visual_bell_list, > +A A A A A .default_num = VISUAL_OFF > A A A A }, > > A A A A { .name = "word-separators", > Index: tmux.1 > =================================================================== > RCS file: /cvs/src/usr.bin/tmux/tmux.1,v > retrieving revision 1.568 > diff -u -p -r1.568 tmux.1 > --- tmux.1A A A 21 Jul 2017 09:17:19 -0000A A A 1.568 > +++ tmux.1A A A 26 Jul 2017 12:42:58 -0000 > @@ -2515,6 +2515,25 @@ before interpretation. > A .Pp > A Available session options are: > A .Bl -tag -width Ds > +.It Xo Ic activity-action > +.Op Ic any | none | current | other > +.Xc > +Set action on window activity when > +.Ic monitor-activity > +is on. > +.Ic any > +means activity in any window linked to a session causes a bell or > message > +(depending on > +.Ic visual-activity ) > +in the current window of that session, > +.Ic none > +means all activity is ignored (equivalent to > +.Ic monitor-activity > +being off), > +.Ic current > +means only activity in windows other than the current window are > ignored and > +.Ic other > +means activity in the current window is ignored but not those in > other windows. > A .It Ic assume-paste-time Ar milliseconds > A If keys are entered faster than one in > A .Ar milliseconds , > @@ -2530,20 +2549,8 @@ The default is zero. > A .Op Ic any | none | current | other > A .Xc > A Set action on window bell. > -.Ic any > -means a bell in any window linked to a session causes a bell in the > current > -window of that session, > -.Ic none > -means all bells are ignored, > -.Ic current > -means only bells in windows other than the current window are ignored > and > -.Ic other > -means bells in the current window are ignored but not those in other > windows. > -.It Xo Ic bell-on-alert > -.Op Ic on | off > -.Xc > -If on, ring the terminal bell when an alert > -occurs. > +The values are the same as those for > +.Ic activity-action . > A .It Ic default-command Ar shell-command > A Set the command used for new windows (if not specified when the > window is > A created) to > @@ -2759,6 +2766,15 @@ is on. > A Formats are expanded, see the > A .Sx FORMATS > A section. > +.It Xo Ic silence-action > +.Op Ic any | none | current | other > +.Xc > +Set action on window silence when > +.Ic monitor-silence > +is on. > +The values are the same as those for > +.Ic activity-action . > +.Pp > A .It Xo Ic status > A .Op Ic on | off > A .Xc > @@ -2884,26 +2900,30 @@ set -s user-keys[0] '\e[5;30012~' > A bind User0 resize-pane -L 3 > A .Ed > A .It Xo Ic visual-activity > -.Op Ic on | off > +.Op Ic on | off | both > A .Xc > -If on, display a status line message when activity occurs in a window > -for which the > +If on, display a message instead of sending a bell when activity > occurs in a > +window for which the > A .Ic monitor-activity > A window option is enabled. > +If set to both, a bell and a message are produced. > A .It Xo Ic visual-bell > -.Op Ic on | off > +.Op Ic on | off | both > A .Xc > -If this option is on, a message is shown on a bell instead of it > being passed > -through to the terminal (which normally makes a sound). > +If on, a message is shown on a bell instead of it being passed > through to the > +terminal (which normally makes a sound). > +If set to both, a bell and a message are produced. > A Also see the > A .Ic bell-action > A option. > A .It Xo Ic visual-silence > -.Op Ic on | off > +.Op Ic on | off | both > A .Xc > A If > A .Ic monitor-silence > -is enabled, prints a message after the interval has expired on a > given window. > +is enabled, prints a message after the interval has expired on a > given window > +instead of sending a bell. > +If set to both, a bell and a message are produced. > A .It Ic word-separators Ar string > A Sets the session's conception of what characters are considered word > A separators, for the purposes of the next and previous word commands > in > Index: tmux.h > =================================================================== > RCS file: /cvs/src/usr.bin/tmux/tmux.h,v > retrieving revision 1.796 > diff -u -p -r1.796 tmux.h > --- tmux.hA A A 14 Jul 2017 18:49:07 -0000A A A 1.796 > +++ tmux.hA A A 26 Jul 2017 12:42:58 -0000 > @@ -83,6 +83,11 @@ struct tmuxproc; > A #define BELL_CURRENT 2 > A #define BELL_OTHER 3 > > +/* Visual option values. */ > +#define VISUAL_OFF 0 > +#define VISUAL_ON 1 > +#define VISUAL_BOTH 2 > + > A /* Special key codes. */ > A #define KEYC_NONE 0xffff00000000ULL > A #define KEYC_UNKNOWN 0xfffe00000000ULL -- You received this message because you are subscribed to the Google Groups "tmux-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
