Having a list of winlinks->alerts for each session is stupid, just store

the alert flags directly in the winlink itself.
This commit is contained in:
Nicholas Marriott
2010-06-21 01:27:46 +00:00
parent 447a07e9f8
commit e63f0546a1
8 changed files with 78 additions and 180 deletions

View File

@ -24,10 +24,10 @@
#include "tmux.h"
int server_window_backoff(struct window_pane *);
int server_window_check_bell(struct session *, struct window *);
int server_window_check_activity(struct session *, struct window *);
int server_window_check_bell(struct session *, struct winlink *);
int server_window_check_activity(struct session *, struct winlink *);
int server_window_check_content(
struct session *, struct window *, struct window_pane *);
struct session *, struct winlink *, struct window_pane *);
/* Check if this window should suspend reading. */
int
@ -59,6 +59,7 @@ void
server_window_loop(void)
{
struct window *w;
struct winlink *wl;
struct window_pane *wp;
struct session *s;
u_int i, j;
@ -81,33 +82,37 @@ server_window_loop(void)
for (j = 0; j < ARRAY_LENGTH(&sessions); j++) {
s = ARRAY_ITEM(&sessions, j);
if (s == NULL || !session_has(s, w))
if (s == NULL)
continue;
wl = session_has(s, w);
if (wl == NULL)
continue;
if (server_window_check_bell(s, w) ||
server_window_check_activity(s, w))
if (server_window_check_bell(s, wl) ||
server_window_check_activity(s, wl))
server_status_session(s);
TAILQ_FOREACH(wp, &w->panes, entry)
server_window_check_content(s, w, wp);
server_window_check_content(s, wl, wp);
}
w->flags &= ~(WINDOW_BELL|WINDOW_ACTIVITY|WINDOW_CONTENT);
w->flags &= ~(WINDOW_BELL|WINDOW_ACTIVITY);
}
}
/* Check for bell in window. */
int
server_window_check_bell(struct session *s, struct window *w)
server_window_check_bell(struct session *s, struct winlink *wl)
{
struct client *c;
struct window *w = wl->window;
u_int i;
int action, visual;
if (!(w->flags & WINDOW_BELL))
if (!(w->flags & WINDOW_BELL) || wl->flags & WINLINK_BELL)
return (0);
if (s->curw == wl)
return (0);
if (session_alert_has_window(s, w, WINDOW_BELL))
return (0);
session_alert_add(s, w, WINDOW_BELL);
wl->flags |= WINLINK_BELL;
action = options_get_number(&s->options, "bell-action");
switch (action) {
@ -155,25 +160,22 @@ server_window_check_bell(struct session *s, struct window *w)
/* Check for activity in window. */
int
server_window_check_activity(struct session *s, struct window *w)
server_window_check_activity(struct session *s, struct winlink *wl)
{
struct client *c;
struct window *w = wl->window;
u_int i;
if (!(w->flags & WINDOW_ACTIVITY))
if (!(w->flags & WINDOW_ACTIVITY) || wl->flags & WINLINK_ACTIVITY)
return (0);
if (s->curw->window == w)
if (s->curw == wl)
return (0);
if (!options_get_number(&w->options, "monitor-activity"))
return (0);
if (session_alert_has_window(s, w, WINDOW_ACTIVITY))
return (0);
session_alert_add(s, w, WINDOW_ACTIVITY);
wl->flags |= WINLINK_ACTIVITY;
if (s->flags & SESSION_UNATTACHED)
return (0);
if (options_get_number(&s->options, "visual-activity")) {
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
c = ARRAY_ITEM(&clients, i);
@ -190,31 +192,28 @@ server_window_check_activity(struct session *s, struct window *w)
/* Check for content change in window. */
int
server_window_check_content(
struct session *s, struct window *w, struct window_pane *wp)
struct session *s, struct winlink *wl, struct window_pane *wp)
{
struct client *c;
struct window *w = wl->window;
u_int i;
char *found, *ptr;
if (!(w->flags & WINDOW_ACTIVITY)) /* activity for new content */
/* Activity flag must be set for new content. */
if (!(w->flags & WINDOW_ACTIVITY) || wl->flags & WINLINK_CONTENT)
return (0);
if (s->curw->window == w)
if (s->curw == wl)
return (0);
ptr = options_get_string(&w->options, "monitor-content");
if (ptr == NULL || *ptr == '\0')
return (0);
if (session_alert_has_window(s, w, WINDOW_CONTENT))
return (0);
if ((found = window_pane_search(wp, ptr, NULL)) == NULL)
return (0);
xfree(found);
session_alert_add(s, w, WINDOW_CONTENT);
if (s->flags & SESSION_UNATTACHED)
return (0);
wl->flags |= WINLINK_CONTENT;
if (options_get_number(&s->options, "visual-content")) {
for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
c = ARRAY_ITEM(&clients, i);