summaryrefslogtreecommitdiffstats
path: root/window-tree.c
diff options
context:
space:
mode:
authornicm <nicm>2017-11-02 18:43:51 +0000
committernicm <nicm>2017-11-02 18:43:51 +0000
commit95850e1aca6697df784d02c24a0ca997f82f90f7 (patch)
tree1a065e881718d2db8c73048c3410ccf520c4bfdc /window-tree.c
parentc1f62f1fdebc3bd000b81bd93dcae6f1a539f345 (diff)
Tweak previous slightly so that current session is chosen if it is in
the group rather than first.
Diffstat (limited to 'window-tree.c')
-rw-r--r--window-tree.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/window-tree.c b/window-tree.c
index 8765628a..563c64e0 100644
--- a/window-tree.c
+++ b/window-tree.c
@@ -399,9 +399,11 @@ window_tree_build(void *modedata, u_int sort_type, uint64_t *tag,
{
struct window_tree_modedata *data = modedata;
struct session *s, **l;
- struct session_group *sg;
+ struct session_group *sg, *current;
u_int n, i;
+ current = session_group_contains(data->fs.s);
+
for (i = 0; i < data->item_size; i++)
window_tree_free_item(data->item_list[i]);
free(data->item_list);
@@ -412,9 +414,11 @@ window_tree_build(void *modedata, u_int sort_type, uint64_t *tag,
n = 0;
RB_FOREACH(s, sessions, &sessions) {
if (data->squash_groups &&
- (sg = session_group_contains(s)) != NULL &&
- s != TAILQ_FIRST(&sg->sessions))
- continue;
+ (sg = session_group_contains(s)) != NULL) {
+ if ((sg == current && s != data->fs.s) ||
+ (sg != current && s != TAILQ_FIRST(&sg->sessions)))
+ continue;
+ }
l = xreallocarray(l, n + 1, sizeof *l);
l[n++] = s;
}