mirror of
https://github.com/tmux/tmux.git
synced 2026-06-20 09:25:12 +00:00
Merge branch 'obsd-master'
This commit is contained in:
16
cmd-find.c
16
cmd-find.c
@@ -147,6 +147,18 @@ cmd_find_session_better(struct session *s, struct session *than, int flags)
|
||||
return (timercmp(&s->activity_time, &than->activity_time, >));
|
||||
}
|
||||
|
||||
/* Can this session be usefully targeted? */
|
||||
static int
|
||||
cmd_find_session_valid(struct session *s)
|
||||
{
|
||||
if (!session_alive(s) ||
|
||||
s->curw == NULL ||
|
||||
s->curw->window == NULL ||
|
||||
s->curw->window->active == NULL)
|
||||
return (0);
|
||||
return (1);
|
||||
}
|
||||
|
||||
/* Find best session from a list, or all if list is NULL. */
|
||||
static struct session *
|
||||
cmd_find_best_session(struct session **slist, u_int ssize, int flags)
|
||||
@@ -159,11 +171,15 @@ cmd_find_best_session(struct session **slist, u_int ssize, int flags)
|
||||
s = NULL;
|
||||
if (slist != NULL) {
|
||||
for (i = 0; i < ssize; i++) {
|
||||
if (!cmd_find_session_valid(slist[i]))
|
||||
continue;
|
||||
if (cmd_find_session_better(slist[i], s, flags))
|
||||
s = slist[i];
|
||||
}
|
||||
} else {
|
||||
RB_FOREACH(s_loop, sessions, &sessions) {
|
||||
if (!cmd_find_session_valid(s_loop))
|
||||
continue;
|
||||
if (cmd_find_session_better(s_loop, s, flags))
|
||||
s = s_loop;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user