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 y; /* y position */
int width; /* width */ int width; /* width */
int height;/* height */ int height;/* height */
} geom, savegeom;
struct {
int basew; /* desired width */ int basew; /* desired width */
int baseh; /* desired height */ int baseh; /* desired height */
int minw; /* minimum width */ int minw; /* minimum width */
@ -131,7 +133,7 @@ struct client_ctx {
int inch; /* height increment progression */ int inch; /* height increment progression */
float mina; /* minimum aspect ratio */ float mina; /* minimum aspect ratio */
float maxa; /* maximum aspect ratio */ float maxa; /* maximum aspect ratio */
} geom, savegeom; } hint;
struct { struct {
int x; /* x position */ int x; /* x position */
int y; /* y position */ int y; /* y position */

View File

@ -725,36 +725,36 @@ client_getsizehints(struct client_ctx *cc)
cc->size->flags = PSize; cc->size->flags = PSize;
if (cc->size->flags & PBaseSize) { if (cc->size->flags & PBaseSize) {
cc->geom.basew = cc->size->base_width; cc->hint.basew = cc->size->base_width;
cc->geom.baseh = cc->size->base_height; cc->hint.baseh = cc->size->base_height;
} else if (cc->size->flags & PMinSize) { } else if (cc->size->flags & PMinSize) {
cc->geom.basew = cc->size->min_width; cc->hint.basew = cc->size->min_width;
cc->geom.baseh = cc->size->min_height; cc->hint.baseh = cc->size->min_height;
} }
if (cc->size->flags & PMinSize) { if (cc->size->flags & PMinSize) {
cc->geom.minw = cc->size->min_width; cc->hint.minw = cc->size->min_width;
cc->geom.minh = cc->size->min_height; cc->hint.minh = cc->size->min_height;
} else if (cc->size->flags & PBaseSize) { } else if (cc->size->flags & PBaseSize) {
cc->geom.minw = cc->size->base_width; cc->hint.minw = cc->size->base_width;
cc->geom.minh = cc->size->base_height; cc->hint.minh = cc->size->base_height;
} }
if (cc->size->flags & PMaxSize) { if (cc->size->flags & PMaxSize) {
cc->geom.maxw = cc->size->max_width; cc->hint.maxw = cc->size->max_width;
cc->geom.maxh = cc->size->max_height; cc->hint.maxh = cc->size->max_height;
} }
if (cc->size->flags & PResizeInc) { if (cc->size->flags & PResizeInc) {
cc->geom.incw = cc->size->width_inc; cc->hint.incw = cc->size->width_inc;
cc->geom.inch = cc->size->height_inc; cc->hint.inch = cc->size->height_inc;
} }
cc->geom.incw = MAX(1, cc->geom.incw); cc->hint.incw = MAX(1, cc->hint.incw);
cc->geom.inch = MAX(1, cc->geom.inch); cc->hint.inch = MAX(1, cc->hint.inch);
if (cc->size->flags & PAspect) { if (cc->size->flags & PAspect) {
if (cc->size->min_aspect.x > 0) 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; cc->size->min_aspect.x;
if (cc->size->max_aspect.y > 0) 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; cc->size->max_aspect.y;
} }
} }
@ -763,48 +763,48 @@ client_applysizehints(struct client_ctx *cc)
{ {
Bool baseismin; Bool baseismin;
baseismin = (cc->geom.basew == cc->geom.minw) && baseismin = (cc->hint.basew == cc->hint.minw) &&
(cc->geom.baseh == cc->geom.minh); (cc->hint.baseh == cc->hint.minh);
/* temporarily remove base dimensions, ICCCM 4.1.2.3 */ /* temporarily remove base dimensions, ICCCM 4.1.2.3 */
if (!baseismin) { if (!baseismin) {
cc->geom.width -= cc->geom.basew; cc->geom.width -= cc->hint.basew;
cc->geom.height -= cc->geom.baseh; cc->geom.height -= cc->hint.baseh;
} }
/* adjust for aspect limits */ /* adjust for aspect limits */
if (cc->geom.mina > 0 && cc->geom.maxa > 0) { if (cc->hint.mina > 0 && cc->hint.maxa > 0) {
if (cc->geom.maxa < if (cc->hint.maxa <
(float)cc->geom.width / cc->geom.height) (float)cc->geom.width / cc->geom.height)
cc->geom.width = cc->geom.height * cc->geom.maxa; cc->geom.width = cc->geom.height * cc->hint.maxa;
else if (cc->geom.mina < else if (cc->hint.mina <
(float)cc->geom.height / cc->geom.width) (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 */ /* remove base dimensions for increment */
if (baseismin) { if (baseismin) {
cc->geom.width -= cc->geom.basew; cc->geom.width -= cc->hint.basew;
cc->geom.height -= cc->geom.baseh; cc->geom.height -= cc->hint.baseh;
} }
/* adjust for increment value */ /* adjust for increment value */
cc->geom.width -= cc->geom.width % cc->geom.incw; cc->geom.width -= cc->geom.width % cc->hint.incw;
cc->geom.height -= cc->geom.height % cc->geom.inch; cc->geom.height -= cc->geom.height % cc->hint.inch;
/* restore base dimensions */ /* restore base dimensions */
cc->geom.width += cc->geom.basew; cc->geom.width += cc->hint.basew;
cc->geom.height += cc->geom.baseh; cc->geom.height += cc->hint.baseh;
/* adjust for min width/height */ /* adjust for min width/height */
cc->geom.width = MAX(cc->geom.width, cc->geom.minw); cc->geom.width = MAX(cc->geom.width, cc->hint.minw);
cc->geom.height = MAX(cc->geom.height, cc->geom.minh); cc->geom.height = MAX(cc->geom.height, cc->hint.minh);
/* adjust for max width/height */ /* adjust for max width/height */
if (cc->geom.maxw) if (cc->hint.maxw)
cc->geom.width = MIN(cc->geom.width, cc->geom.maxw); cc->geom.width = MIN(cc->geom.width, cc->hint.maxw);
if (cc->geom.maxh) if (cc->hint.maxh)
cc->geom.height = MIN(cc->geom.height, cc->geom.maxh); cc->geom.height = MIN(cc->geom.height, cc->hint.maxh);
} }
static void static void

View File

@ -58,8 +58,8 @@ mousefunc_sweep_draw(struct client_ctx *cc)
int width, width_size, width_name; int width, width_size, width_name;
(void)snprintf(asize, sizeof(asize), "%dx%d", (void)snprintf(asize, sizeof(asize), "%dx%d",
(cc->geom.width - cc->geom.basew) / cc->geom.incw, (cc->geom.width - cc->hint.basew) / cc->hint.incw,
(cc->geom.height - cc->geom.baseh) / cc->geom.inch); (cc->geom.height - cc->hint.baseh) / cc->hint.inch);
width_size = font_width(sc, asize, strlen(asize)) + 4; width_size = font_width(sc, asize, strlen(asize)) + 4;
width_name = font_width(sc, cc->name, strlen(cc->name)) + 4; width_name = font_width(sc, cc->name, strlen(cc->name)) + 4;
width = MAX(width_size, width_name); width = MAX(width_size, width_name);