Have resize update a SESSION_UNATTACHED flag.

This commit is contained in:
Nicholas Marriott 2007-10-05 18:25:05 +00:00
parent 1e252b9e9a
commit 6f2edda785
2 changed files with 30 additions and 13 deletions

View File

@ -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;

5
tmux.h
View File

@ -1,4 +1,4 @@
/* $Id: tmux.h,v 1.51 2007-10-05 14:23:28 nicm Exp $ */
/* $Id: tmux.h,v 1.52 2007-10-05 18:25:05 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -423,6 +423,9 @@ struct session {
struct window *window;
struct window *last;
struct windows windows;
#define SESSION_UNATTACHED 0x1 /* not attached to any clients */
int flags;
};
ARRAY_DECL(sessions, struct session *);