summaryrefslogtreecommitdiffstats
path: root/session.c
diff options
context:
space:
mode:
authornicm <nicm>2016-10-19 09:22:07 +0000
committernicm <nicm>2016-10-19 09:22:07 +0000
commit899e629bf0bc6053112cec5b65a63f1dd2330001 (patch)
tree7fb2b4739ce08ba6a6b894022dfb028585f259e5 /session.c
parentbc27451e156c0a4af73d016ea04827710ea70d5b (diff)
Alerts are too slow, so rather than walking all sessions and windows,
add a link of winlinks to each window and a pointer to the session to each winlink. Also rewrite the alerts processing to return to the old behaviour (alert in any window sets the flag on any winlink).
Diffstat (limited to 'session.c')
-rw-r--r--session.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/session.c b/session.c
index fa43a74e..19a6f139 100644
--- a/session.c
+++ b/session.c
@@ -337,6 +337,7 @@ session_new(struct session *s, const char *name, int argc, char **argv,
xasprintf(cause, "index in use: %d", idx);
return (NULL);
}
+ wl->session = s;
env = environ_create();
environ_copy(global_environ, env);
@@ -373,6 +374,7 @@ session_attach(struct session *s, struct window *w, int idx, char **cause)
xasprintf(cause, "index in use: %d", idx);
return (NULL);
}
+ wl->session = s;
winlink_set_window(wl, w);
notify_session_window("window-linked", s, w);
@@ -409,8 +411,8 @@ session_has(struct session *s, struct window *w)
{
struct winlink *wl;
- RB_FOREACH(wl, winlinks, &s->windows) {
- if (wl->window == w)
+ TAILQ_FOREACH(wl, &w->winlinks, wentry) {
+ if (wl->session == s)
return (1);
}
return (0);
@@ -679,6 +681,7 @@ session_group_synchronize1(struct session *target, struct session *s)
/* Link all the windows from the target. */
RB_FOREACH(wl, winlinks, ww) {
wl2 = winlink_add(&s->windows, wl->idx);
+ wl2->session = s;
winlink_set_window(wl2, wl->window);
notify_session_window("window-linked", s, wl2->window);
wl2->flags |= wl->flags & WINLINK_ALERTFLAGS;
@@ -729,6 +732,7 @@ session_renumber_windows(struct session *s)
/* Go through the winlinks and assign new indexes. */
RB_FOREACH(wl, winlinks, &old_wins) {
wl_new = winlink_add(&s->windows, new_idx);
+ wl_new->session = s;
winlink_set_window(wl_new, wl->window);
wl_new->flags |= wl->flags & WINLINK_ALERTFLAGS;