[hackers] [wmii] Better still revert handling.

From: Kris Maglione <jg_AT_suckless.org>
Date: Fri Jan 25 02:05:36 2008

changeset: 2257:cbaecd18e094
user: Kris Maglione <jg_AT_suckless.org>
date: Wed Jan 23 22:31:22 2008 -0500
summary: Better still revert handling.

diff -r 7a5d108dd7cd -r cbaecd18e094 cmd/wmii/area.c
--- a/cmd/wmii/area.c Wed Jan 23 21:45:30 2008 -0500
+++ b/cmd/wmii/area.c Wed Jan 23 22:31:22 2008 -0500
@@ -150,24 +150,21 @@ area_destroy(Area *a) {
 
 void
 area_moveto(Area *to, Frame *f) {
- Rectangle tr;
         Area *from;
+ bool fromfloating;
 
         assert(to->view == f->view);
 
         from = f->area;
- if(to->floating != from->floating) {
- /* XXX: This must be changed. */
- tr = f->revert;
- f->revert = f->r;
- f->r = tr;
- }
+ fromfloating = from->floating;
 
         area_detach(f);
 
         /* Temporary kludge. */
- if(!to->floating && to->floating != from->floating) {
- column_attachrect(to, f, tr);
+ if(!to->floating
+ && to->floating != fromfloating
+ && !eqrect(f->colr, ZR)) {
+ column_attachrect(to, f, f->colr);
         }else
                 area_attach(to, f);
 }
@@ -200,15 +197,17 @@ area_attach(Area *a, Frame *f) {
 
 void
 area_detach(Frame *f) {
+ View *v;
         Area *a;
 
         a = f->area;
+ v = a->view;
 
         if(a->floating)
                 float_detach(f);
         else
                 column_detach(f);
- view_arrange(a->view);
+ view_arrange(v);
 }
 
 void
diff -r 7a5d108dd7cd -r cbaecd18e094 cmd/wmii/client.c
--- a/cmd/wmii/client.c Wed Jan 23 21:45:30 2008 -0500
+++ b/cmd/wmii/client.c Wed Jan 23 22:31:22 2008 -0500
@@ -318,10 +318,7 @@ client_grav(Client *c, Rectangle rd) {
 
         if(eqrect(rd, ZR)) {
                 if(c->sel) {
- if(c->sel->area->floating)
- r = c->sel->r;
- else
- r = c->sel->revert;
+ r = c->sel->floatr;
                 }else
                         r = frame_client2rect(nil, c->r);
                 r = gravitate(r, c->r, h->grav);
@@ -560,7 +557,7 @@ fullscreen(Client *c, int fullscreen) {
         if(!fullscreen)
                 for(f=c->frame; f; f=f->cnext) {
                         if(f->oldarea == 0) {
- frame_resize(f, f->oldr); /* XXX: oldr Replace with floatr */
+ frame_resize(f, f->floatr);
                                 if(f->view == screen->sel) /* FIXME */
                                         client_resize(f->client, f->r);
 
@@ -568,7 +565,6 @@ fullscreen(Client *c, int fullscreen) {
                         else if(f->oldarea > 0) {
                                 wassel = (f == f->area->sel);
                                 area_moveto(view_findarea(f->view, f->oldarea, true), f);
- f->revert = f->oldr; /* XXX: oldr */
                                 if(wassel)
                                         frame_focus(f);
                         }
@@ -780,7 +776,7 @@ configreq_event(Window *w, XConfigureReq
                 flushenterevents();
         }
         else {
- c->sel->revert = r;
+ c->sel->floatr = r;
                 client_configure(c);
         }
 }
diff -r 7a5d108dd7cd -r cbaecd18e094 cmd/wmii/column.c
--- a/cmd/wmii/column.c Wed Jan 23 21:45:30 2008 -0500
+++ b/cmd/wmii/column.c Wed Jan 23 22:31:22 2008 -0500
@@ -71,6 +71,8 @@ column_attach(Area *a, Frame *f) {
         column_insert(a, f, a->sel);
         column_arrange(a, false);
 }
+
+static void column_scale(Area*);
 
 void
 column_attachrect(Area *a, Frame *f, Rectangle r) {
@@ -88,7 +90,16 @@ column_attachrect(Area *a, Frame *f, Rec
                 if(abs(before) <= abs(after))
                         break;
         }
+ if(Dy(a->r) > Dy(r)) {
+ a->r.max.y -= Dy(r);
+ column_scale(a);
+ a->r.max.y += Dy(r);
+ }
         column_insert(a, f, pos);
+ for(fp=f->anext; fp; fp=fp->anext) {
+ fp->r.min.y += Dy(r);
+ fp->r.max.y += Dy(r);
+ }
         column_resizeframe(f, r);
 }
 
diff -r 7a5d108dd7cd -r cbaecd18e094 cmd/wmii/dat.h
--- a/cmd/wmii/dat.h Wed Jan 23 21:45:30 2008 -0500
+++ b/cmd/wmii/dat.h Wed Jan 23 22:31:22 2008 -0500
@@ -172,9 +172,9 @@ struct Frame {
         bool collapsed;
         float ratio;
         Rectangle r;
- Rectangle oldr;
+ Rectangle colr;
+ Rectangle floatr;
         Rectangle crect;
- Rectangle revert;
         Rectangle grabbox;
         Rectangle titlebar;
 };
diff -r 7a5d108dd7cd -r cbaecd18e094 cmd/wmii/float.c
--- a/cmd/wmii/float.c Wed Jan 23 21:45:30 2008 -0500
+++ b/cmd/wmii/float.c Wed Jan 23 22:31:22 2008 -0500
@@ -12,6 +12,7 @@ float_attach(Area *a, Frame *f) {
 
         f->client->floating = true;
 
+ f->r = f->floatr;
         float_placeframe(f);
         assert(a->sel != f);
         frame_insert(f, a->sel);
diff -r 7a5d108dd7cd -r cbaecd18e094 cmd/wmii/frame.c
--- a/cmd/wmii/frame.c Wed Jan 23 21:45:30 2008 -0500
+++ b/cmd/wmii/frame.c Wed Jan 23 22:31:22 2008 -0500
@@ -27,12 +27,12 @@ frame_create(Client *c, View *v) {
         f->view = v;
 
         if(c->sel) {
- f->revert = c->sel->revert;
+ f->floatr = c->sel->floatr;
                 f->r = c->sel->r;
         }
         else{
                 f->r = frame_client2rect(f, client_grav(c, ZR));
- f->revert = f->r;
+ f->floatr = f->r;
                 c->sel = f;
         }
         f->collapsed = false;
@@ -130,10 +130,6 @@ frame_restack(Frame *f, Frame *above) {
         }
         if(f->snext)
                 f->snext->sprev = f;
-
- for(fp=a->stack; fp; fp=fp->snext)
- print("[%C]%s\n", fp->client, clientname(fp->client));
- print("\n");
 
         return true;
 }
@@ -288,6 +284,7 @@ frame_client2rect(Frame *f, Rectangle r)
         return r;
 }
 
+/* FIXME: This is getting entirely too long! */
 void
 frame_resize(Frame *f, Rectangle r) {
         Client *c;
@@ -346,6 +343,12 @@ frame_resize(Frame *f, Rectangle r) {
 
         if(f->area->floating && !f->client->strut)
                 f->r = constrain(f->r);
+
+ if(f->area->floating)
+ f->floatr = f->r;
+ else
+ f->colr = f->r;
+
         pt.x = (Dx(f->r) - Dx(cr)) / 2;
         f->crect = rectaddpt(cr, pt);
 }
diff -r 7a5d108dd7cd -r cbaecd18e094 cmd/wmii/view.c
--- a/cmd/wmii/view.c Wed Jan 23 21:45:30 2008 -0500
+++ b/cmd/wmii/view.c Wed Jan 23 22:31:22 2008 -0500
@@ -174,7 +174,7 @@ view_focus(WMScreen *s, View *v) {
 view_focus(WMScreen *s, View *v) {
         Client *c;
         Frame *f, *fnext;
- Area *a;
+ Area *a, *an;
         bool fscrn;
         
         USED(s);
@@ -186,23 +186,22 @@ view_focus(WMScreen *s, View *v) {
         update_frame_selectors(v);
         div_update_all();
         fscrn = false;
- for(a=v->area; a; a=a->next)
+ for(a=v->area; a; a=an) {
+ an = a->next;
                 for(f=a->frame; f; f=fnext) {
                         fnext = f->anext;
                         if(f->client->fullscreen) {
                                 f->collapsed = false;
                                 fscrn = true;
                                 if(!f->area->floating) {
- f->oldr = f->revert;
                                         f->oldarea = area_idx(f->area);
                                         area_moveto(v->area, f);
                                         area_setsel(v->area, f);
- }else if(f->oldarea == -1) {
- f->oldr = f->r; /* XXX: oldr */
+ }else if(f->oldarea == -1)
                                         f->oldarea = 0;
- }
                         }
                 }
+ }
         for(c=client; c; c=c->next)
                 if((f = c->sel)) {
                         if(f->view == v)
Received on Fri Jan 25 2008 - 02:05:36 UTC

This archive was generated by hypermail 2.2.0 : Sun Jul 13 2008 - 15:59:08 UTC