X-Git-Url: https://git.decadent.org.uk/gitweb/?p=ion3.git;a=blobdiff_plain;f=ioncore%2Fsizepolicy.c;h=8c42327669236d6e5b56f08f1dd733e4b130bf14;hp=e2cb4de2437b50972bb8841fe3b61b0c64ebda80;hb=e3aec18706513a87eaa7839dfdaf7e0fcd0d8d2a;hpb=a6561c9679cd701b0d50c3cfd44e4664f7df2b2f diff --git a/ioncore/sizepolicy.c b/ioncore/sizepolicy.c index e2cb4de..8c42327 100644 --- a/ioncore/sizepolicy.c +++ b/ioncore/sizepolicy.c @@ -1,7 +1,7 @@ /* * ion/ioncore/sizepolicy.c * - * Copyright (c) Tuomo Valkonen 1999-2007. + * Copyright (c) Tuomo Valkonen 1999-2009. * * See the included file LICENSE for details. */ @@ -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,8 @@ 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 */ };