On Mon, Jul 28, 2003 at 08:56:58AM +0200, [EMAIL PROTECTED] wrote:
> Just toyed around with your
> changed keyboard resizing and found a little glitch.  

Fix attached (I hope).

> Another idea: what do you think of warping the mouse to the resized window
> if it has shrunk from under it and would loose focus otherway.

Maybe.

-- 
Tuomo
Index: split.c
===================================================================
RCS file: /share/cvsrepos/ion/ionws/split.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- split.c     27 Jul 2003 18:42:48 -0000      1.35
+++ split.c     28 Jul 2003 13:43:23 -0000      1.36
@@ -234,6 +234,7 @@
 
 
 
+/* Update size bounds for the split with root <node>. */
 static void split_tree_update_bounds(WObj *node, int dir, int *min, int *max)
 {
        int tlmax, tlmin, brmax, brmin;
@@ -268,6 +269,7 @@
 }
 
 
+/* Get the bounds calculated by the above function. */
 static void split_tree_get_bounds(WObj *node, int dir, int *min, int *max)
 {
        WWsSplit *split;
@@ -290,6 +292,13 @@
 }
 
 
+/* Get resize bounds for <from> due to <split> and all nodes towards the
+ * root. <from> must be a child node of <split> (->tl/br). The <*free>
+ * variables indicate the free space in that direction while the <*shrink>
+ * variables indicate the amount the object in that direction can grow
+ * (INT_MAX means no limit has been set). <minsize> and <maxsize> are
+ * size limits set by siblings in splits perpendicular to <dir>.
+ */
 static void get_bounds(WWsSplit *split, int dir, WObj *from,
                                           int *tlfree, int *brfree, int *maxsize,
                                           int *tlshrink, int *brshrink, int *minsize)
@@ -360,7 +369,14 @@
 }
 
 
-
+/* Resize (sub-)split tree with root <node> . <npos> and <nsize> indicate
+ * the new geometry of <node> in direction <dir> (vertical/horizontal). 
+ * If <primn> is ANY, the difference between old and new sizes is split
+ * proportionally between tl/br nodes modulo minimum maximum size constraints. 
+ * Otherwise the node indicated by <primn> is resized first and what is left 
+ * after size constraints is applied to the other node. The size bounds 
+ * must've been updated split_tree_updated_bounds before using this function.
+ */
 void split_tree_do_resize(WObj *node, int dir, int primn, int npos, int nsize)
 {
        WWsSplit *split;
@@ -426,8 +442,17 @@
 }
 
 
+/* Resize splits starting from <s> and going back to root in <dir> without
+ * touching <from>. Because this function may be called multiple times 
+ * without anything being done to <from> in between, the expected old size
+ * is also passed as a parameter and used insteaed of split_tree_size(from, 
+ * dir). If <primn> is ANY, any split on the path will be resized by what 
+ * can be done given minimum and maximum size bounds. If <primn> is 
+ * TOP_OR_LEFT/BOTTOM_OR_RIGHT, only splits where <from> is not the node
+ * corresponding <primn> are resized.
+ */
 static int do_resize_split(WWsSplit *split, int dir, WObj *from, int primn, 
-                                                  int amount)
+                                                  int amount, int fromoldsize)
 {
        WObj *other=(from==split->tl ? split->br : split->tl);
        int os=split_tree_size(other, dir);
@@ -438,7 +463,8 @@
                if(p==NULL){
                        pos=split_tree_pos((WObj*)split, dir);
                }else{
-                       pos=do_resize_split(p, dir, (WObj*)split, primn, amount);
+                       pos=do_resize_split(p, dir, (WObj*)split, primn, amount, 
+                                                               fromoldsize);
                        split_tree_do_resize(other, dir, ANY, pos, os+amount);
                }
                fpos=pos;
@@ -447,7 +473,7 @@
                bool res=(primn==ANY ||
                                  (primn==TOP_OR_LEFT && other==split->tl) ||
                                  (primn==BOTTOM_OR_RIGHT && other==split->br));
-               int osn=os, fsn=amount+split_tree_size(from, dir);
+               int osn=os, fsn=amount+fromoldsize;/*split_tree_size(from, dir);*/
                
                if(res){
                        int min, max;
@@ -458,7 +484,8 @@
                }
                
                if(amount!=0 && p!=NULL){
-                       pos=do_resize_split(p, dir, (WObj*)split, primn, amount);
+                       pos=do_resize_split(p, dir, (WObj*)split, primn, amount,
+                                                               fromoldsize+os);
                }else{
                        if(amount!=0){
                                warn("Split tree size calculation bug: resize amount 
%d!=0 "
@@ -499,7 +526,7 @@
                if(primn==TOP_OR_LEFT)
                        pos-=amount;
        }else{
-               pos=do_resize_split(p, dir, obj, primn, amount);
+               pos=do_resize_split(p, dir, obj, primn, amount, s);
        }
        
        split_tree_do_resize(obj, dir, ANY, pos, s+amount);
@@ -603,10 +630,14 @@
                int size=split_tree_size((WObj*)sub, dir);
                WWsSplit *split=split_of((WObj*)sub);
 
-               if(x1d!=0 && split!=NULL)
-                       do_resize_split(split, dir, (WObj*)sub, TOP_OR_LEFT, -x1d);
-               if(x2d!=0 && split!=NULL)
-                       do_resize_split(split, dir, (WObj*)sub, BOTTOM_OR_RIGHT, x2d);
+               if(x1d!=0 && split!=NULL){
+                       do_resize_split(split, dir, (WObj*)sub, TOP_OR_LEFT, -x1d, 
size);
+               }
+               
+               if(x2d!=0 && split!=NULL){
+                       do_resize_split(split, dir, (WObj*)sub, BOTTOM_OR_RIGHT, x2d, 
+                                                       size-x1d);
+               }
                
                split_tree_do_resize((WObj*)sub, dir, ANY, pos+x1d, size-x1d+x2d);
        }

Reply via email to