Better respect minw on column_resizeframe; fix a possible crash with grow command.

This commit is contained in:
Kris Maglione 2008-05-21 19:32:25 -04:00
parent 9f87971cc1
commit 00701a72b8
4 changed files with 64 additions and 11 deletions

View File

@ -386,6 +386,7 @@ client_groupframe(Client *c, View *v) {
Rectangle
frame_hints(Frame *f, Rectangle r, Align sticky) {
Rectangle or;
WinHints h;
Point p;
Client *c;
@ -394,9 +395,8 @@ frame_hints(Frame *f, Rectangle r, Align sticky) {
return r;
or = r;
r = frame_rect2client(c, r, f->area->floating);
r = sizehint(c->w.hints, r);
r = frame_client2rect(c, r, f->area->floating);
h = frame_gethints(f);
r = sizehint(&h, r);
if(!f->area->floating) {
/* Not allowed to grow */

View File

@ -136,6 +136,8 @@ column_detach(Frame *f) {
area_destroy(a);
}
/* This is impossibly long and tortuous. We can do better.
*/
static void
column_scale(Area *a) {
Frame *f, **fp;
@ -254,12 +256,10 @@ column_scale(Area *a) {
}
/* Distribute the surplus.
* When a frame doesn't accept its allocation, don't try to
* allocate to it again. Keep going until we have no more
* surplus, or no more frames will accept it.
*/
osurplus = 0;
while(surplus != osurplus) {
/* More on this later. */
//while(surplus != osurplus) {
osurplus = surplus;
dy = 0;
for(f=a->frame; f; f=f->anext)
@ -278,13 +278,15 @@ column_scale(Area *a) {
if(f->dy == i)
f->dy = 0;
}
}
//}
/* Now, try to give each frame, in turn, the entirety of the
* surplus that we have left. A single frame might be able
* to fill its increment gap with all of what's left, but
* not with its fair share.
*/
#if 0
No, don''t. Causes too much trouble, the way things are now.
for(f=a->frame; f && surplus > 0; f=f->anext)
if(!f->collapsed) {
dy = Dy(f->r);
@ -293,6 +295,7 @@ column_scale(Area *a) {
f->r.max.y = Dy(f->crect) + colh + 1;
surplus -= Dy(f->r) - dy;
}
#endif
if(surplus < 0) {
print("Badness: surplus = %d\n", surplus);
@ -437,13 +440,17 @@ column_resizeframe(Frame *f, Rectangle r) {
if(al)
r.min.x = max(r.min.x, al->r.min.x + minw);
else
else { /* Hm... */
r.min.x = max(r.min.x, v->r.min.x);
r.max.x = max(r.max.x, r.min.x + minw);
}
if(ar)
r.max.x = min(r.max.x, ar->r.max.x - minw);
else
else {
r.max.x = min(r.max.x, v->r.max.x);
r.min.x = min(r.min.x, r.max.x - minw);
}
a->r.min.x = r.min.x;
a->r.max.x = r.max.x;

View File

@ -134,8 +134,9 @@ int ingrabbox_p(Frame*, int x, int y);
void move_focus(Frame*, Frame*);
Rectangle constrain(Rectangle);
Rectangle frame_client2rect(Client*, Rectangle, bool);
Rectangle frame_rect2client(Client*, Rectangle, bool);
WinHints frame_gethints(Frame*);
Rectangle frame_hints(Frame*, Rectangle, Align);
Rectangle frame_rect2client(Client*, Rectangle, bool);
/* fs.c */
void fs_attach(Ixp9Req*);

View File

@ -246,6 +246,51 @@ Handlers framehandler = {
.motion = motion_event,
};
WinHints
frame_gethints(Frame *f) {
WinHints h;
Client *c;
Point d;
int minh;
minh = labelh(def.font);
c = f->client;
h = *c->w.hints;
d.y = labelh(def.font);
if(f->area->floating) {
d.x = 2*def.border;
d.y += def.border;
}else {
d.x = 2;
d.y += 2;
}
if(h.min.x < 2*minh)
h.min.x = minh + (2*minh) % h.inc.x;
if(h.min.y < minh)
h.min.y = minh + minh % h.inc.y;
h.min.x += d.x;
h.min.y += d.y;
if(h.max.x + d.x > h.max.x)
h.max.x += d.x;
if(h.max.y + d.y > h.max.y)
h.max.y += d.y;
h.base.x += d.x;
h.base.y += d.y;
h.baspect.x += d.x;
h.baspect.y += d.y;
h.group = 0;
h.grav = ZP;
h.gravstatic = 0;
h.position = 0;
return h;
}
Rectangle
frame_rect2client(Client *c, Rectangle r, bool floating) {