diff options
author | okan | 2011-09-03 09:42:33 +0000 |
---|---|---|
committer | okan | 2011-09-03 09:42:33 +0000 |
commit | c3ab5d4f1316da4c6aba8acb4460121ee3e45b59 (patch) | |
tree | 418448f0e4caf5939426e4e63f92a58ec951dc9b | |
parent | 41d2656d3236f0988ac500f3899c14cfec52598c (diff) | |
download | cwm-c3ab5d4f1316da4c6aba8acb4460121ee3e45b59.tar.gz |
split off window hints from geometry so we don't need to carry them all
around when dealing with {,h,v}max. same idea from oga.
-rw-r--r-- | calmwm.h | 6 | ||||
-rw-r--r-- | client.c | 76 | ||||
-rw-r--r-- | mousefunc.c | 6 |
3 files changed, 45 insertions, 43 deletions
@@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: calmwm.h,v 1.138 2011/09/03 09:25:39 okan Exp $ + * $OpenBSD: calmwm.h,v 1.139 2011/09/03 09:42:33 okan Exp $ */ #ifndef _CALMWM_H_ @@ -121,6 +121,8 @@ struct client_ctx { int y; /* y position */ int width; /* width */ int height;/* height */ + } geom, savegeom; + struct { int basew; /* desired width */ int baseh; /* desired height */ int minw; /* minimum width */ @@ -131,7 +133,7 @@ struct client_ctx { int inch; /* height increment progression */ float mina; /* minimum aspect ratio */ float maxa; /* maximum aspect ratio */ - } geom, savegeom; + } hint; struct { int x; /* x position */ int y; /* y position */ @@ -15,7 +15,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: client.c,v 1.87 2011/09/03 09:20:58 okan Exp $ + * $OpenBSD: client.c,v 1.88 2011/09/03 09:42:33 okan Exp $ */ #include <sys/param.h> @@ -725,36 +725,36 @@ client_getsizehints(struct client_ctx *cc) cc->size->flags = PSize; if (cc->size->flags & PBaseSize) { - cc->geom.basew = cc->size->base_width; - cc->geom.baseh = cc->size->base_height; + cc->hint.basew = cc->size->base_width; + cc->hint.baseh = cc->size->base_height; } else if (cc->size->flags & PMinSize) { - cc->geom.basew = cc->size->min_width; - cc->geom.baseh = cc->size->min_height; + cc->hint.basew = cc->size->min_width; + cc->hint.baseh = cc->size->min_height; } if (cc->size->flags & PMinSize) { - cc->geom.minw = cc->size->min_width; - cc->geom.minh = cc->size->min_height; + cc->hint.minw = cc->size->min_width; + cc->hint.minh = cc->size->min_height; } else if (cc->size->flags & PBaseSize) { - cc->geom.minw = cc->size->base_width; - cc->geom.minh = cc->size->base_height; + cc->hint.minw = cc->size->base_width; + cc->hint.minh = cc->size->base_height; } if (cc->size->flags & PMaxSize) { - cc->geom.maxw = cc->size->max_width; - cc->geom.maxh = cc->size->max_height; + cc->hint.maxw = cc->size->max_width; + cc->hint.maxh = cc->size->max_height; } if (cc->size->flags & PResizeInc) { - cc->geom.incw = cc->size->width_inc; - cc->geom.inch = cc->size->height_inc; + cc->hint.incw = cc->size->width_inc; + cc->hint.inch = cc->size->height_inc; } - cc->geom.incw = MAX(1, cc->geom.incw); - cc->geom.inch = MAX(1, cc->geom.inch); + cc->hint.incw = MAX(1, cc->hint.incw); + cc->hint.inch = MAX(1, cc->hint.inch); if (cc->size->flags & PAspect) { if (cc->size->min_aspect.x > 0) - cc->geom.mina = (float)cc->size->min_aspect.y / + cc->hint.mina = (float)cc->size->min_aspect.y / cc->size->min_aspect.x; if (cc->size->max_aspect.y > 0) - cc->geom.maxa = (float)cc->size->max_aspect.x / + cc->hint.maxa = (float)cc->size->max_aspect.x / cc->size->max_aspect.y; } } @@ -763,48 +763,48 @@ client_applysizehints(struct client_ctx *cc) { Bool baseismin; - baseismin = (cc->geom.basew == cc->geom.minw) && - (cc->geom.baseh == cc->geom.minh); + baseismin = (cc->hint.basew == cc->hint.minw) && + (cc->hint.baseh == cc->hint.minh); /* temporarily remove base dimensions, ICCCM 4.1.2.3 */ if (!baseismin) { - cc->geom.width -= cc->geom.basew; - cc->geom.height -= cc->geom.baseh; + cc->geom.width -= cc->hint.basew; + cc->geom.height -= cc->hint.baseh; } /* adjust for aspect limits */ - if (cc->geom.mina > 0 && cc->geom.maxa > 0) { - if (cc->geom.maxa < + if (cc->hint.mina > 0 && cc->hint.maxa > 0) { + if (cc->hint.maxa < (float)cc->geom.width / cc->geom.height) - cc->geom.width = cc->geom.height * cc->geom.maxa; - else if (cc->geom.mina < + cc->geom.width = cc->geom.height * cc->hint.maxa; + else if (cc->hint.mina < (float)cc->geom.height / cc->geom.width) - cc->geom.height = cc->geom.width * cc->geom.mina; + cc->geom.height = cc->geom.width * cc->hint.mina; } /* remove base dimensions for increment */ if (baseismin) { - cc->geom.width -= cc->geom.basew; - cc->geom.height -= cc->geom.baseh; + cc->geom.width -= cc->hint.basew; + cc->geom.height -= cc->hint.baseh; } /* adjust for increment value */ - cc->geom.width -= cc->geom.width % cc->geom.incw; - cc->geom.height -= cc->geom.height % cc->geom.inch; + cc->geom.width -= cc->geom.width % cc->hint.incw; + cc->geom.height -= cc->geom.height % cc->hint.inch; /* restore base dimensions */ - cc->geom.width += cc->geom.basew; - cc->geom.height += cc->geom.baseh; + cc->geom.width += cc->hint.basew; + cc->geom.height += cc->hint.baseh; /* adjust for min width/height */ - cc->geom.width = MAX(cc->geom.width, cc->geom.minw); - cc->geom.height = MAX(cc->geom.height, cc->geom.minh); + cc->geom.width = MAX(cc->geom.width, cc->hint.minw); + cc->geom.height = MAX(cc->geom.height, cc->hint.minh); /* adjust for max width/height */ - if (cc->geom.maxw) - cc->geom.width = MIN(cc->geom.width, cc->geom.maxw); - if (cc->geom.maxh) - cc->geom.height = MIN(cc->geom.height, cc->geom.maxh); + if (cc->hint.maxw) + cc->geom.width = MIN(cc->geom.width, cc->hint.maxw); + if (cc->hint.maxh) + cc->geom.height = MIN(cc->geom.height, cc->hint.maxh); } static void diff --git a/mousefunc.c b/mousefunc.c index 9f44029..b897a7f 100644 --- a/mousefunc.c +++ b/mousefunc.c @@ -16,7 +16,7 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * - * $OpenBSD: mousefunc.c,v 1.32 2011/07/25 15:10:24 okan Exp $ + * $OpenBSD: mousefunc.c,v 1.33 2011/09/03 09:42:33 okan Exp $ */ #include <sys/param.h> @@ -58,8 +58,8 @@ mousefunc_sweep_draw(struct client_ctx *cc) int width, width_size, width_name; (void)snprintf(asize, sizeof(asize), "%dx%d", - (cc->geom.width - cc->geom.basew) / cc->geom.incw, - (cc->geom.height - cc->geom.baseh) / cc->geom.inch); + (cc->geom.width - cc->hint.basew) / cc->hint.incw, + (cc->geom.height - cc->hint.baseh) / cc->hint.inch); width_size = font_width(sc, asize, strlen(asize)) + 4; width_name = font_width(sc, cc->name, strlen(cc->name)) + 4; width = MAX(width_size, width_name); |