diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2007-10-05 18:25:05 +0000 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2007-10-05 18:25:05 +0000 |
commit | 6f2edda7856529de964326d70561a36e2fb57184 (patch) | |
tree | e9434ef87cb5ac357d12bbe0ec8e66e882b32e09 /resize.c | |
parent | 1e252b9e9a1535298d44f976a5cd42bf136fe575 (diff) |
Have resize update a SESSION_UNATTACHED flag.
Diffstat (limited to 'resize.c')
-rw-r--r-- | resize.c | 38 |
1 files changed, 26 insertions, 12 deletions
@@ -1,4 +1,4 @@ -/* $Id: resize.c,v 1.2 2007-10-04 20:01:10 nicm Exp $ */ +/* $Id: resize.c,v 1.3 2007-10-05 18:25:05 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -36,6 +36,11 @@ * * This is quite inefficient - better/additional data structures are needed * to make it better. + * + * As a side effect, this function updates the SESSION_UNATTACHED flag. This + * flag is necessary to make sure unattached sessions do not limit the size of + * windows that are attached both to them and to other sessions which are + * attached. */ void @@ -54,15 +59,21 @@ recalculate_sizes(void) ssx = ssy = UINT_MAX; for (j = 0; j < ARRAY_LENGTH(&clients); j++) { c = ARRAY_ITEM(&clients, j); - if (c == NULL || c->session != s) + if (c == NULL) continue; - if (c->sx < ssx) - ssx = c->sx; - if (c->sy < ssy) - ssy = c->sy; + if (c->session == s) { + if (c->sx < ssx) + ssx = c->sx; + if (c->sy < ssy) + ssy = c->sy; + } } - if (ssx == UINT_MAX || ssy == UINT_MAX) + if (ssx == UINT_MAX || ssy == UINT_MAX) { + s->flags |= SESSION_UNATTACHED; continue; + } + s->flags &= ~SESSION_UNATTACHED; + if (ssy < status_lines) ssy = status_lines + 1; ssy -= status_lines; @@ -84,15 +95,18 @@ recalculate_sizes(void) ssx = ssy = UINT_MAX; for (j = 0; j < ARRAY_LENGTH(&sessions); j++) { s = ARRAY_ITEM(&sessions, j); - if (s == NULL || !session_has(s, w)) + if (s == NULL || s->flags & SESSION_UNATTACHED) continue; - if (s->sx < ssx) - ssx = s->sx; - if (s->sy < ssy) - ssy = s->sy; + if (session_has(s, w)) { + if (s->sx < ssx) + ssx = s->sx; + if (s->sy < ssy) + ssy = s->sy; + } } if (ssx == UINT_MAX || ssy == UINT_MAX) continue; + if (w->screen.sx == ssx && w->screen.sy == ssy) continue; |