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.
This commit is contained in:
okan 2011-09-03 09:42:33 +00:00
parent 325129c6ba
commit b852a73a60
3 changed files with 42 additions and 40 deletions

View File

@ -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 */

View File

@ -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

View File

@ -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);