[hackers] [wmii] Better relaxing code.

From: Kris Maglione <jg_AT_suckless.org>
Date: Fri, 01 Jun 2007 01:09:54 -0000

changeset: 2110:88829cce497d
user: Kris Maglione <jg_AT_suckless.org>
date: Sat Apr 21 23:56:09 2007 -0400
summary: Better relaxing code.

diff -r 0b51728c2e71 -r 88829cce497d cmd/wmii/column.c
--- a/cmd/wmii/column.c Sat Apr 21 22:04:11 2007 -0400
+++ b/cmd/wmii/column.c Sat Apr 21 23:56:09 2007 -0400
@@ -228,6 +228,7 @@ scale_column(Area *a) {
 
         surplus = Dy(a->r) - (ncol * colh) - (nuncol * uncolh);
 
+ /* Collapse until there is room */
         if(surplus < 0) {
                 i = ceil((float)(-surplus) / (uncolh - colh));
                 if(i >= nuncol)
@@ -236,6 +237,7 @@ scale_column(Area *a) {
                 ncol += i;
                 surplus += i * (uncolh - colh);
         }
+ /* Push to the floating layer until there is room */
         if(surplus < 0) {
                 i = ceil((float)(-surplus)/colh);
                 if(i > ncol)
@@ -244,69 +246,77 @@ scale_column(Area *a) {
                 surplus += i * colh;
         }
 
+ j = nuncol - 1;
         i = ncol - 1;
- j = nuncol - 1;
- for(f=a->frame; f; f=f->anext) {
+ /* Decide which to collapse, float */
+ for(fp=&a->frame; *fp;) {
+ f = *fp;
                 if(f == a->sel)
- j++;
+ i++, j++;
                 if(!f->collapsed) {
                         if(j < 0 && (f != a->sel))
                                 f->collapsed = True;
- else {
- if(Dy(f->crect) <= minh)
- f->crect.max.y = 1;
- else
- f->crect.max.y -= minh;
- }
                         j--;
                 }
- }
- for(fp=&a->frame; *fp;) {
- f = *fp;
- if(f == a->sel)
- i++;
                 if(f->collapsed) {
- if(i < 0 && f != a->sel) {
+ if(i < 0 && (f != a->sel)) {
                                 f->collapsed = False;
                                 send_to_area(f->view->area, f);
                                 continue;
                         }
                         i--;
- f->r.max.y = colh;
- }
-
+ }
+ /* Doesn't change if we 'continue' */
+ fp=&f->anext;
+ }
+
+ surplus = 0;
+ for(f=a->frame; f; f=f->anext) {
                 f->r = rectsubpt(f->r, f->r.min);
                 f->crect = rectsubpt(f->crect, f->crect.min);
                 f->r.max.x = Dx(a->r);
- if(!f->collapsed) {
+
+ if(f->collapsed) {
+ f->r.max.y = colh;
+ }else {
+ f->r.max.y = uncolh;
                         dy += Dy(f->crect);
- f->r.max.y = uncolh;
- }
- fp=&f->anext;
+ surplus += Dy(f->r);
+ }
         }
         for(f = a->frame; f; f = f->anext)
                 f->ratio = (float)Dy(f->crect)/dy;
 
         j = 0;
- while(surplus != j) {
+ surplus = Dy(a->r) - surplus;
+ while(surplus > 0 && surplus != j) {
                 j = surplus;
                 dy = 0;
                 for(f=a->frame; f; f=f->anext) {
                         if(!f->collapsed) {
                                 f->r.max.y += f->ratio * surplus;
                                 resize_frame(f, f->r);
- f->r.max.y = Dy(f->crect) + frame_delta_h();
+ f->r.max.y = Dy(f->crect) + labelh(def.font) + 1;
                         }
                         dy += Dy(f->r);
                 }
                 surplus = Dy(a->r) - dy;
+ }
+ for(f=a->frame; f && surplus > 0; f=f->anext) {
+ if(!f->collapsed) {
+ dy = Dy(f->r);
+ f->r.max.y += surplus;
+ resize_frame(f, f->r);
+ f->r.max.y = Dy(f->crect) + labelh(def.font) + 1;
+ surplus -= Dy(f->r) - dy;
+ }
         }
 
         yoff = a->r.min.y;
         i = nuncol;
         for(f=a->frame; f; f=f->anext) {
                 f->r = rectaddpt(f->r, Pt(a->r.min.x, yoff));
- f->r.max.x = a->r.max.x;
+
                 if(!f->collapsed) {
                         i--;
                         f->r.max.y += surplus / nuncol;
diff -r 0b51728c2e71 -r 88829cce497d cmd/wmii/mouse.c
--- a/cmd/wmii/mouse.c Sat Apr 21 22:04:11 2007 -0400
+++ b/cmd/wmii/mouse.c Sat Apr 21 23:56:09 2007 -0400
@@ -272,7 +272,7 @@ horiz:
                 case ButtonRelease:
                         switch(ev.xbutton.button) {
                         case 1:
- if(f->anext && (!f->aprev || fw->fp != f->aprev || fw->fp != f->aprev->aprev)) {
+ if(f->anext && (!f->aprev || (fw->fp != f->aprev && fw->fp != f->aprev->aprev))) {
                                         f->anext->r.min.y = f->r.min.y;
                                         resize_frame(f->anext, f->anext->r);
                                 }
Received on Fri Jun 01 2007 - 03:09:53 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:57:01 UTC