X-Git-Url: https://git.decadent.org.uk/gitweb/?p=ion3.git;a=blobdiff_plain;f=ioncore%2Ffloat-placement.c;h=3f6a64d0089ed8b6a10b81ff277a143e4d364ae0;hp=8d5fb2119cdc862972b18fa544d1855258f39681;hb=20070318;hpb=803afbc1cd633f6c025bcd9537e9b7e9aedadd0d diff --git a/ioncore/float-placement.c b/ioncore/float-placement.c index 8d5fb21..3f6a64d 100644 --- a/ioncore/float-placement.c +++ b/ioncore/float-placement.c @@ -34,18 +34,34 @@ static void ggeom(WRegion *reg, WRectangle *geom) } +static bool st_filt(WStacking *st, void *lvl) +{ + uint level=*(uint*)lvl; + + return (st->reg!=NULL && + REGION_IS_MAPPED(st->reg) && + st->level==level); +} + + +#define FOR_ALL_STACKING_NODES(VAR, WS, LVL, TMP) \ + for(stacking_iter_init(&(TMP), group_get_stacking(ws), \ + st_filt, &LVL), \ + VAR=stacking_iter_nodes(&(TMP)); \ + VAR!=NULL; \ + VAR=stacking_iter_nodes(&(TMP))) + + #define IGNORE_ST(ST, WS) ((ST)->reg==NULL || (ST)==(WS)->bottom) -static WRegion* is_occupied(WGroup *ws, const WRectangle *r) + +static WRegion* is_occupied(WGroup *ws, uint level, const WRectangle *r) { - WGroupIterTmp tmp; + WStackingIterTmp tmp; WStacking *st; WRectangle p; - FOR_ALL_NODES_IN_GROUP(ws, st, tmp){ - if(IGNORE_ST(st, ws)) - continue; - + FOR_ALL_STACKING_NODES(st, ws, level, tmp){ ggeom(st->reg, &p); if(r->x>=p.x+p.w) @@ -63,17 +79,14 @@ static WRegion* is_occupied(WGroup *ws, const WRectangle *r) } -static int next_least_x(WGroup *ws, int x) +static int next_least_x(WGroup *ws, uint level, int x) { WRectangle p; int retx=REGION_GEOM(ws).x+REGION_GEOM(ws).w; - WGroupIterTmp tmp; + WStackingIterTmp tmp; WStacking *st; - FOR_ALL_NODES_IN_GROUP(ws, st, tmp){ - if(IGNORE_ST(st, ws)) - continue; - + FOR_ALL_STACKING_NODES(st, ws, level, tmp){ ggeom(st->reg, &p); if(p.x+p.w>x && p.x+p.wreg, &p); if(p.y+p.h>y && p.y+p.hx=r.x; g->y=r.y; return TRUE; }else{ - r.x=next_least_x(ws, r.x); + r.x=next_least_x(ws, level, r.x); r.y=0; } } }else{ while(r.yx=r.x; g->y=r.y; return TRUE; }else{ - r.y=next_lowest_y(ws, r.y); + r.y=next_lowest_y(ws, level, r.y); r.x=0; } } @@ -159,10 +170,10 @@ static bool tiling_placement(WGroup *ws, WRectangle *g) } -void group_calc_placement(WGroup *ws, WRectangle *geom) +void group_calc_placement(WGroup *ws, uint level, WRectangle *geom) { if(ioncore_placement_method!=PLACEMENT_RANDOM){ - if(tiling_placement(ws, geom)) + if(tiling_placement(ws, level, geom)) return; } random_placement(REGION_GEOM(ws), geom);