Better still revert handling.

This commit is contained in:
Kris Maglione 2008-01-23 22:31:22 -05:00
parent 46948c279d
commit 6b42d0176e
7 changed files with 40 additions and 31 deletions

View File

@ -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

View File

@ -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);
}
}

View File

@ -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);
}

View File

@ -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;
};

View File

@ -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);

View File

@ -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);
}

View File

@ -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)