version 1.9, 2009/07/14 19:03:16 |
version 1.10, 2009/07/18 14:59:25 |
|
|
struct client *server_accept_client(int); |
struct client *server_accept_client(int); |
void server_handle_client(struct client *); |
void server_handle_client(struct client *); |
void server_handle_window(struct window *, struct window_pane *); |
void server_handle_window(struct window *, struct window_pane *); |
int server_check_window_bell(struct session *, struct window *, |
int server_check_window_bell(struct session *, struct window *); |
struct window_pane *); |
|
int server_check_window_activity(struct session *, |
int server_check_window_activity(struct session *, |
struct window *); |
struct window *); |
int server_check_window_content(struct session *, struct window *, |
int server_check_window_content(struct session *, struct window *, |
|
|
if (s == NULL || !session_has(s, w)) |
if (s == NULL || !session_has(s, w)) |
continue; |
continue; |
|
|
update += server_check_window_bell(s, w, wp); |
update += server_check_window_bell(s, w); |
update += server_check_window_activity(s, w); |
update += server_check_window_activity(s, w); |
update += server_check_window_content(s, w, wp); |
update += server_check_window_content(s, w, wp); |
} |
} |
|
|
} |
} |
|
|
int |
int |
server_check_window_bell( |
server_check_window_bell(struct session *s, struct window *w) |
struct session *s, struct window *w, struct window_pane *wp) |
|
{ |
{ |
struct client *c; |
struct client *c; |
u_int i; |
u_int i; |
int action; |
int action, visual; |
|
|
if (!(w->flags & WINDOW_BELL)) |
if (!(w->flags & WINDOW_BELL)) |
return (0); |
return (0); |
|
|
case BELL_ANY: |
case BELL_ANY: |
if (s->flags & SESSION_UNATTACHED) |
if (s->flags & SESSION_UNATTACHED) |
break; |
break; |
|
visual = options_get_number(&s->options, "visual-bell"); |
for (i = 0; i < ARRAY_LENGTH(&clients); i++) { |
for (i = 0; i < ARRAY_LENGTH(&clients); i++) { |
c = ARRAY_ITEM(&clients, i); |
c = ARRAY_ITEM(&clients, i); |
if (c != NULL && c->session == s) |
if (c == NULL || c->session != s) |
|
continue; |
|
if (!visual) { |
tty_putcode(&c->tty, TTYC_BEL); |
tty_putcode(&c->tty, TTYC_BEL); |
|
continue; |
|
} |
|
if (c->session->curw->window == w) { |
|
status_message_set(c, "Bell in current window"); |
|
continue; |
|
} |
|
status_message_set(c, "Bell in window %u", |
|
winlink_find_by_window(&s->windows, w)->idx); |
} |
} |
break; |
break; |
case BELL_CURRENT: |
case BELL_CURRENT: |
if (w->active != wp) |
if (s->flags & SESSION_UNATTACHED) |
break; |
break; |
|
visual = options_get_number(&s->options, "visual-bell"); |
for (i = 0; i < ARRAY_LENGTH(&clients); i++) { |
for (i = 0; i < ARRAY_LENGTH(&clients); i++) { |
c = ARRAY_ITEM(&clients, i); |
c = ARRAY_ITEM(&clients, i); |
if (c != NULL && c->session == s) |
if (c == NULL || c->session != s) |
|
continue; |
|
if (c->session->curw->window != w) |
|
continue; |
|
if (!visual) { |
tty_putcode(&c->tty, TTYC_BEL); |
tty_putcode(&c->tty, TTYC_BEL); |
|
continue; |
|
} |
|
status_message_set(c, "Bell in current window"); |
} |
} |
break; |
break; |
} |
} |
|
|
int |
int |
server_check_window_activity(struct session *s, struct window *w) |
server_check_window_activity(struct session *s, struct window *w) |
{ |
{ |
|
struct client *c; |
|
u_int i; |
|
|
if (!(w->flags & WINDOW_ACTIVITY)) |
if (!(w->flags & WINDOW_ACTIVITY)) |
return (0); |
return (0); |
|
|
if (!options_get_number(&w->options, "monitor-activity")) |
if (!options_get_number(&w->options, "monitor-activity")) |
return (0); |
return (0); |
|
|
if (session_alert_has_window(s, w, WINDOW_ACTIVITY)) |
if (session_alert_has_window(s, w, WINDOW_ACTIVITY)) |
return (0); |
return (0); |
|
if (s->curw->window == w) |
|
return (0); |
|
|
session_alert_add(s, w, WINDOW_ACTIVITY); |
session_alert_add(s, w, WINDOW_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); |
|
if (c == NULL || c->session != s) |
|
continue; |
|
status_message_set(c, "Activity in window %u", |
|
winlink_find_by_window(&s->windows, w)->idx); |
|
} |
|
} |
|
|
return (1); |
return (1); |
} |
} |
|
|
|
|
server_check_window_content( |
server_check_window_content( |
struct session *s, struct window *w, struct window_pane *wp) |
struct session *s, struct window *w, struct window_pane *wp) |
{ |
{ |
char *found, *ptr; |
struct client *c; |
|
u_int i; |
|
char *found, *ptr; |
|
|
|
if (!(w->flags & WINDOW_ACTIVITY)) /* activity for new content */ |
|
return (0); |
|
|
if (!(w->flags & WINDOW_CONTENT)) |
ptr = options_get_string(&w->options, "monitor-content"); |
|
if (ptr == NULL || *ptr == '\0') |
return (0); |
return (0); |
if ((ptr = options_get_string(&w->options, "monitor-content")) == NULL) |
|
return (0); |
|
if (*ptr == '\0') |
|
return (0); |
|
if (session_alert_has_window(s, w, WINDOW_CONTENT)) |
if (session_alert_has_window(s, w, WINDOW_CONTENT)) |
return (0); |
return (0); |
|
if (s->curw->window == w) |
|
return (0); |
|
|
if ((found = window_pane_search(wp, ptr, NULL)) == NULL) |
if ((found = window_pane_search(wp, ptr, NULL)) == NULL) |
return (0); |
return (0); |
session_alert_add(s, w, WINDOW_CONTENT); |
|
xfree(found); |
xfree(found); |
|
|
|
session_alert_add(s, w, WINDOW_CONTENT); |
|
if (s->flags & SESSION_UNATTACHED) |
|
return (0); |
|
if (options_get_number(&s->options, "visual-content")) { |
|
for (i = 0; i < ARRAY_LENGTH(&clients); i++) { |
|
c = ARRAY_ITEM(&clients, i); |
|
if (c == NULL || c->session != s) |
|
continue; |
|
status_message_set(c, "Content in window %u", |
|
winlink_find_by_window(&s->windows, w)->idx); |
|
} |
|
} |
|
|
return (1); |
return (1); |
} |
} |
|
|