From 8d66f4fba4972d45be64d108c7c8d952f85016a8 Mon Sep 17 00:00:00 2001 From: nicm Date: Wed, 22 Apr 2015 15:30:11 +0000 Subject: Change the windows array into an RB tree and fix some places where we were only looking at the first winlink for a window in a session. --- resize.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'resize.c') diff --git a/resize.c b/resize.c index 9ad73c81..5b89b093 100644 --- a/resize.c +++ b/resize.c @@ -49,7 +49,7 @@ recalculate_sizes(void) struct client *c; struct window *w; struct window_pane *wp; - u_int i, j, ssx, ssy, has, limit; + u_int i, ssx, ssy, has, limit; int flag, has_status, is_zoomed, forced; RB_FOREACH(s, sessions, &sessions) { @@ -57,8 +57,8 @@ recalculate_sizes(void) s->attached = 0; ssx = ssy = UINT_MAX; - for (j = 0; j < ARRAY_LENGTH(&clients); j++) { - c = ARRAY_ITEM(&clients, j); + for (i = 0; i < ARRAY_LENGTH(&clients); i++) { + c = ARRAY_ITEM(&clients, i); if (c == NULL || c->flags & CLIENT_SUSPENDED) continue; if (c->session == s) { @@ -92,9 +92,8 @@ recalculate_sizes(void) s->sy = ssy; } - for (i = 0; i < ARRAY_LENGTH(&windows); i++) { - w = ARRAY_ITEM(&windows, i); - if (w == NULL || w->active == NULL) + RB_FOREACH(w, windows, &windows) { + if (w->active == NULL) continue; flag = options_get_number(&w->options, "aggressive-resize"); -- cgit From 9a453dd3546b2c3053e8e34bf4d6775b1a05d3a8 Mon Sep 17 00:00:00 2001 From: nicm Date: Wed, 22 Apr 2015 15:32:33 +0000 Subject: Make session_has return a flag, returning the first winlink found is a recipe for errors. --- resize.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'resize.c') diff --git a/resize.c b/resize.c index 5b89b093..330c37b5 100644 --- a/resize.c +++ b/resize.c @@ -104,7 +104,7 @@ recalculate_sizes(void) if (flag) has = s->curw->window == w; else - has = session_has(s, w) != NULL; + has = session_has(s, w); if (has) { if (s->sx < ssx) ssx = s->sx; -- cgit From aeedb464a6ee038289ddcfefae437928ab020cb1 Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 24 Apr 2015 23:17:11 +0000 Subject: Convert clients list into a TAILQ. --- resize.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'resize.c') diff --git a/resize.c b/resize.c index 330c37b5..3606bfeb 100644 --- a/resize.c +++ b/resize.c @@ -49,7 +49,7 @@ recalculate_sizes(void) struct client *c; struct window *w; struct window_pane *wp; - u_int i, ssx, ssy, has, limit; + u_int ssx, ssy, has, limit; int flag, has_status, is_zoomed, forced; RB_FOREACH(s, sessions, &sessions) { @@ -57,9 +57,8 @@ recalculate_sizes(void) s->attached = 0; ssx = ssy = UINT_MAX; - for (i = 0; i < ARRAY_LENGTH(&clients); i++) { - c = ARRAY_ITEM(&clients, i); - if (c == NULL || c->flags & CLIENT_SUSPENDED) + TAILQ_FOREACH(c, &clients, entry) { + if (c->flags & CLIENT_SUSPENDED) continue; if (c->session == s) { if (c->tty.sx < ssx) -- cgit