Hi,

This work breaks the ""bell-action current"" setting in my .tmux.conf file - 
can we have this reverted, please?

Jason


________________________________
 From: Thomas Adam <tho...@xteddy.org>
To: tmux-users@lists.sourceforge.net 
Cc: Thomas Adam <tho...@xteddy.org> 
Sent: Sunday, June 17, 2012 6:35 PM
Subject: [PATCH 2/2] Clear WINLINK_ALERTFLAGS across all sessions
 

When a winlink is linked in to multiple sessions, make the alert appear
across all sessions where that winlink is linked to, and on clearing it,
ensure *all* instances of that alert are cleared.
---
trunk/server-window.c |    5 ++---
trunk/session.c       |    8 ++++----
trunk/tmux.h          |    2 ++
trunk/window.c        |   31 +++++++++++++++++++++++++++++++
4 files changed, 39 insertions(+), 7 deletions(-)

diff --git a/trunk/server-window.c b/trunk/server-window.c
index 2fc0e21..543f17f 100644
--- a/trunk/server-window.c
+++ b/trunk/server-window.c
@@ -56,9 +56,6 @@ server_window_loop(void)
                server_status_session(s);
            TAILQ_FOREACH(wp, &w->panes, entry)
                server_window_check_content(s, wl, wp);
-
-            if (!(s->flags & SESSION_UNATTACHED))
-                w->flags &= ~(WINDOW_BELL|WINDOW_ACTIVITY);
        }
    }
}
@@ -78,6 +75,8 @@ server_window_check_bell(struct session *s, struct winlink 
*wl)
        wl->flags |= WINLINK_BELL;
    if (s->flags & SESSION_UNATTACHED)
        return (1);
+    if (s->curw->window == wl->window)
+        w->flags &= ~WINDOW_BELL;

    visual = options_get_number(&s->options, "visual-bell");
    action = options_get_number(&s->options, "bell-action");
diff --git a/trunk/session.c b/trunk/session.c
index 0d3b8dd..13be0c7 100644
--- a/trunk/session.c
+++ b/trunk/session.c
@@ -352,7 +352,7 @@ session_next(struct session *s, int alert)
    winlink_stack_remove(&s->lastw, wl);
    winlink_stack_push(&s->lastw, s->curw);
    s->curw = wl;
-    wl->flags &= ~WINLINK_ALERTFLAGS;
+    winlink_clear_flags(wl);
    return (0);
}

@@ -389,7 +389,7 @@ session_previous(struct session *s, int alert)
    winlink_stack_remove(&s->lastw, wl);
    winlink_stack_push(&s->lastw, s->curw);
    s->curw = wl;
-    wl->flags &= ~WINLINK_ALERTFLAGS;
+    winlink_clear_flags(wl);
    return (0);
}

@@ -407,7 +407,7 @@ session_select(struct session *s, int idx)
    winlink_stack_remove(&s->lastw, wl);
    winlink_stack_push(&s->lastw, s->curw);
    s->curw = wl;
-    wl->flags &= ~WINLINK_ALERTFLAGS;
+    winlink_clear_flags(wl);
    return (0);
}

@@ -426,7 +426,7 @@ session_last(struct session *s)
    winlink_stack_remove(&s->lastw, wl);
    winlink_stack_push(&s->lastw, s->curw);
    s->curw = wl;
-    wl->flags &= ~WINLINK_ALERTFLAGS;
+    winlink_clear_flags(wl);
    return (0);
}

diff --git a/trunk/tmux.h b/trunk/tmux.h
index d0dc122..455affb 100644
--- a/trunk/tmux.h
+++ b/trunk/tmux.h
@@ -2054,6 +2054,8 @@ struct window_pane *window_pane_find_down(struct 
window_pane *);
struct window_pane *window_pane_find_left(struct window_pane *);
struct window_pane *window_pane_find_right(struct window_pane *);
void         window_set_name(struct window *, const char *);
+void         winlink_clear_flags(struct winlink *);
+

/* layout.c */
u_int         layout_count_cells(struct layout_cell *);
diff --git a/trunk/window.c b/trunk/window.c
index 8eb11f2..c1ba0aa 100644
--- a/trunk/window.c
+++ b/trunk/window.c
@@ -1174,3 +1174,34 @@ window_pane_find_right(struct window_pane *wp)
    }
    return (NULL);
}
+
+/* Clear alert flags for a winlink */
+void
+winlink_clear_flags(struct winlink *wl)
+{
+    struct winlink    *wm;
+    struct session    *s;
+    struct window    *w;
+    u_int         i;
+
+    for (i = 0; i < ARRAY_LENGTH(&windows); i++)
+    {
+        if ((w = ARRAY_ITEM(&windows, i)) == NULL)
+            continue;
+
+        RB_FOREACH(s, sessions, &sessions)
+        {
+            if ((wm = session_has(s, w)) == NULL)
+                continue;
+
+            if (wm->flags & WINLINK_ALERTFLAGS &&
+                wm->window == wl->window)
+            {
+                wm->flags &= ~WINLINK_ALERTFLAGS;
+                w->flags &= ~(WINDOW_BELL|WINDOW_ACTIVITY);
+
+                server_redraw_session(s);
+            }
+        }
+    }
+}
-- 
1.7.10


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users
------------------------------------------------------------------------------
Try New Relic Now & We'll Send You this Cool Shirt
New Relic is the only SaaS-based application performance monitoring service 
that delivers powerful full stack analytics. Optimize and monitor your
browser, app, & servers with just a few lines of code. Try New Relic
and get this awesome Nerd Life shirt! http://p.sf.net/sfu/newrelic_d2d_apr
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to