X-Git-Url: https://git.decadent.org.uk/gitweb/?p=ion3.git;a=blobdiff_plain;f=ioncore%2Fsizepolicy.c;fp=ioncore%2Fsizepolicy.c;h=e1ee0c0fddb41d6f07ef4cb4175734f87faac2bb;hp=87a3573e3a9ea741ce59286ff3b60daa8eb151b1;hb=2948134dc6273f6d3ea089c4cc273b69e2f8d51e;hpb=69ec7e63f6c39c98c82e8878e672215792ecfd7b diff --git a/ioncore/sizepolicy.c b/ioncore/sizepolicy.c index 87a3573..e1ee0c0 100644 --- a/ioncore/sizepolicy.c +++ b/ioncore/sizepolicy.c @@ -268,9 +268,24 @@ void sizepolicy(WSizePolicy *szplcy, WRegion *reg, break; case SIZEPOLICY_FREE: + if(reg!=NULL) + region_size_hints_correct(reg, &tmp.w, &tmp.h, FALSE); rectangle_constrain(&tmp, &(fp->g)); + fp->g=tmp; + break; + + case SIZEPOLICY_VISIBILITY_CONSTRAINED: if(reg!=NULL) region_size_hints_correct(reg, &tmp.w, &tmp.h, FALSE); + { + /* Constraint such that at least min(size, CF_VISIBILITY_CONSTRAINT) + * much is visible at each border. + */ + int dx=maxof(0, tmp.w-CF_VISIBILITY_CONSTRAINT); + int dy=maxof(0, tmp.h-CF_VISIBILITY_CONSTRAINT); + tmp.x=maxof(fp->g.x-dx, minof(tmp.x, fp->g.x+fp->g.w+dx-tmp.w)); + tmp.y=maxof(fp->g.y-dy, minof(tmp.y, fp->g.y+fp->g.h+dy-tmp.h)); + } fp->g=tmp; break; @@ -321,6 +336,7 @@ static StringIntMap szplcy_specs[] = { {"free_glue_southwest", SIZEPOLICY_FREE_GLUE__SOUTHWEST}, {"free_glue_south", SIZEPOLICY_FREE_GLUE__SOUTH}, {"free_glue_southeast", SIZEPOLICY_FREE_GLUE__SOUTHEAST}, + {"visibility_constrained", SIZEPOLICY_VISIBILITY_CONSTRAINED}, {"unconstrained", SIZEPOLICY_UNCONSTRAINED}, { NULL, SIZEPOLICY_DEFAULT} /* end marker */ };