1 
2 struct w
3 {
4   int top;
5   int left;
6   int height;
7   int width;
8   struct w *next;
9   struct w *parent;
10   struct w *child;
11 };
12 
13 extern struct w *Qnil;
14 
15 void
set_size(struct w * w,int new_size,int nodelete,int set_height)16 set_size (struct w *w, int new_size, int nodelete, int set_height)
17 {
18   int old_size = set_height? w->height : w->width;
19 
20   if (nodelete || w->parent == Qnil)
21     {
22       int last_pos, last_old_pos, pos, old_pos, first;
23       int div_val = old_size << 1;
24       struct w *c;
25 
26       last_pos = first = set_height? w->top : w->left;
27       last_old_pos = 0;
28 
29       for (c = w->child; c != Qnil; c = c->next)
30 	{
31 	  if (set_height)
32 	    old_pos = last_old_pos + c->height;
33 	  else
34 	    old_pos = last_old_pos + c->width;
35 
36 	  pos = (((old_pos * new_size) << 1) + old_size) / div_val;
37 	  set_size (c, pos + first - last_pos, 1, set_height);
38 	  last_pos = pos + first;
39 	  last_old_pos = old_pos;
40 	}
41 
42       if (!nodelete)
43 	for (c = w->child; c != Qnil; c = c->next)
44 	  use (c);
45     }
46 }
47 
48