summaryrefslogtreecommitdiffstats
path: root/session.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2012-03-17 22:35:09 +0000
committerNicholas Marriott <nicm@openbsd.org>2012-03-17 22:35:09 +0000
commit46210344a62b079ff61435b978da41a0f92caf3a (patch)
treedb1d29f00e52472ad2e2d200cc583845ad8a5e12 /session.c
parent4f480c901de715a2fa0ec450c57d4881d662413f (diff)
Add notify hooks for various events, the functions are currently empty
stubs but will be filled in for control mode later. From George Nachman.
Diffstat (limited to 'session.c')
-rw-r--r--session.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/session.c b/session.c
index 2545d868..0109fd5d 100644
--- a/session.c
+++ b/session.c
@@ -142,6 +142,7 @@ session_create(const char *name, const char *cmd, const char *cwd,
}
log_debug("session %s created", s->name);
+ notify_session_created(s);
return (s);
}
@@ -150,9 +151,11 @@ session_create(const char *name, const char *cmd, const char *cwd,
void
session_destroy(struct session *s)
{
+ struct winlink *wl;
log_debug("session %s destroyed", s->name);
RB_REMOVE(sessions, &sessions, s);
+ notify_session_closed(s);
if (s->tio != NULL)
xfree(s->tio);
@@ -163,8 +166,11 @@ session_destroy(struct session *s)
while (!TAILQ_EMPTY(&s->lastw))
winlink_stack_remove(&s->lastw, TAILQ_FIRST(&s->lastw));
- while (!RB_EMPTY(&s->windows))
- winlink_remove(&s->windows, RB_ROOT(&s->windows));
+ while (!RB_EMPTY(&s->windows)) {
+ wl = RB_ROOT(&s->windows);
+ notify_window_unlinked(s, wl->window);
+ winlink_remove(&s->windows, wl);
+ }
xfree(s->cwd);
@@ -254,6 +260,7 @@ session_new(struct session *s,
return (NULL);
}
winlink_set_window(wl, w);
+ notify_window_linked(s, w);
environ_free(&env);
if (options_get_number(&s->options, "set-remain-on-exit"))
@@ -274,6 +281,7 @@ session_attach(struct session *s, struct window *w, int idx, char **cause)
return (NULL);
}
winlink_set_window(wl, w);
+ notify_window_linked(s, w);
session_group_synchronize_from(s);
return (wl);
@@ -288,6 +296,7 @@ session_detach(struct session *s, struct winlink *wl)
session_next(s, 0);
wl->flags &= ~WINLINK_ALERTFLAGS;
+ notify_window_unlinked(s, wl->window);
winlink_stack_remove(&s->lastw, wl);
winlink_remove(&s->windows, wl);
session_group_synchronize_from(s);
@@ -555,6 +564,7 @@ session_group_synchronize1(struct session *target, struct session *s)
RB_FOREACH(wl, winlinks, ww) {
wl2 = winlink_add(&s->windows, wl->idx);
winlink_set_window(wl2, wl->window);
+ notify_window_linked(s, wl2->window);
wl2->flags |= wl->flags & WINLINK_ALERTFLAGS;
}
@@ -576,6 +586,8 @@ session_group_synchronize1(struct session *target, struct session *s)
/* Then free the old winlinks list. */
while (!RB_EMPTY(&old_windows)) {
wl = RB_ROOT(&old_windows);
+ if (winlink_find_by_window_id(&s->windows, wl->window->id) == NULL)
+ notify_window_unlinked(s, wl->window);
winlink_remove(&old_windows, wl);
}
}