From 6b42d0176ec2792d55afab9cc6d2424601c24ac5 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Wed, 23 Jan 2008 22:31:22 -0500 Subject: [PATCH] Better still revert handling. --- cmd/wmii/area.c | 19 +++++++++---------- cmd/wmii/client.c | 10 +++------- cmd/wmii/column.c | 11 +++++++++++ cmd/wmii/dat.h | 4 ++-- cmd/wmii/float.c | 1 + cmd/wmii/frame.c | 15 +++++++++------ cmd/wmii/view.c | 11 +++++------ 7 files changed, 40 insertions(+), 31 deletions(-) diff --git a/cmd/wmii/area.c b/cmd/wmii/area.c index 21ba1ea6..80d62d4c 100644 --- a/cmd/wmii/area.c +++ b/cmd/wmii/area.c @@ -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 --git a/cmd/wmii/client.c b/cmd/wmii/client.c index 5bc94882..1bde91e1 100644 --- a/cmd/wmii/client.c +++ b/cmd/wmii/client.c @@ -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, XConfigureRequestEvent *e) { flushenterevents(); } else { - c->sel->revert = r; + c->sel->floatr = r; client_configure(c); } } diff --git a/cmd/wmii/column.c b/cmd/wmii/column.c index 55392010..79053b56 100644 --- a/cmd/wmii/column.c +++ b/cmd/wmii/column.c @@ -72,6 +72,8 @@ column_attach(Area *a, Frame *f) { column_arrange(a, false); } +static void column_scale(Area*); + void column_attachrect(Area *a, Frame *f, Rectangle r) { Frame *fp, *pos; @@ -88,7 +90,16 @@ column_attachrect(Area *a, Frame *f, Rectangle r) { 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 --git a/cmd/wmii/dat.h b/cmd/wmii/dat.h index b242a8b1..443b06c3 100644 --- a/cmd/wmii/dat.h +++ b/cmd/wmii/dat.h @@ -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 --git a/cmd/wmii/float.c b/cmd/wmii/float.c index c98a8104..f9b4d6cc 100644 --- a/cmd/wmii/float.c +++ b/cmd/wmii/float.c @@ -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 --git a/cmd/wmii/frame.c b/cmd/wmii/frame.c index 36c4da7d..347e2291 100644 --- a/cmd/wmii/frame.c +++ b/cmd/wmii/frame.c @@ -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; @@ -131,10 +131,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 --git a/cmd/wmii/view.c b/cmd/wmii/view.c index d69ec3bd..2ae2d226 100644 --- a/cmd/wmii/view.c +++ b/cmd/wmii/view.c @@ -174,7 +174,7 @@ void 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)