applied Peter Hartlich's patch regarding aspect calculation with slight modifications db5db880
Anselm R Garbe · 2008-08-23 09:54 1 file(s) · +17 −6
dwm.c +17 −6
1046 1046
1047 1047
void
1048 1048
resize(Client *c, int x, int y, int w, int h, Bool sizehints) {
1049 +
	float a;
1049 1050
	XWindowChanges wc;
1050 1051
1051 1052
	if(sizehints) {
1053 +
		/* see last two sentences in ICCCM 4.1.2.3 */
1054 +
		Bool baseismin = c->basew == c->minw && c->baseh == c->minh;
1055 +
1052 1056
		/* set minimum possible */
1053 1057
		w = MAX(1, w);
1054 1058
		h = MAX(1, h);
1055 1059
1056 -
		/* temporarily remove base dimensions */
1057 -
		w -= c->basew;
1058 -
		h -= c->baseh;
1060 +
		if(!baseismin) { /* temporarily remove base dimensions */
1061 +
			w -= c->basew;
1062 +
			h -= c->baseh;
1063 +
		}
1059 1064
1060 1065
		/* adjust for aspect limits */
1061 1066
		if(c->mina > 0 && c->maxa > 0) {
1062 -
			if(c->maxa < (float) w/h)
1067 +
			a = (float) w/h;
1068 +
			if(a > c->maxa)
1063 1069
				w = h * c->maxa;
1064 -
			else if(c->mina > (float) h/w)
1065 -
				h = w * c->mina;
1070 +
			else if(a < c->mina)
1071 +
				h = w / c->mina;
1072 +
		}
1073 +
1074 +
		if(baseismin) { /* increment calculation requires this */
1075 +
			w -= c->basew;
1076 +
			h -= c->baseh;
1066 1077
		}
1067 1078
1068 1079
		/* adjust for increment value */