about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAnselm R Garbe <garbeam@gmail.com>2008-08-23 09:54:55 +0100
committerAnselm R Garbe <garbeam@gmail.com>2008-08-23 09:54:55 +0100
commitdb5db8806f4bbb26bb1259f7ea42d7a826517bbb (patch)
treec7d1e0e25c6f3536928fce515d8495d38b50f8cc
parent258c3380305683de8031871cf95c1cc04ed7ad9e (diff)
downloaddwm-db5db8806f4bbb26bb1259f7ea42d7a826517bbb.tar.gz
applied Peter Hartlich's patch regarding aspect calculation with slight modifications
-rw-r--r--dwm.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/dwm.c b/dwm.c
index ba24d9a..ae2952b 100644
--- a/dwm.c
+++ b/dwm.c
@@ -1046,23 +1046,34 @@ quit(const Arg *arg) {
 
 void
 resize(Client *c, int x, int y, int w, int h, Bool sizehints) {
+	float a;
 	XWindowChanges wc;
 
 	if(sizehints) {
+		/* see last two sentences in ICCCM 4.1.2.3 */
+		Bool baseismin = c->basew == c->minw && c->baseh == c->minh;
+
 		/* set minimum possible */
 		w = MAX(1, w);
 		h = MAX(1, h);
 
-		/* temporarily remove base dimensions */
-		w -= c->basew;
-		h -= c->baseh;
+		if(!baseismin) { /* temporarily remove base dimensions */
+			w -= c->basew;
+			h -= c->baseh;
+		}
 
 		/* adjust for aspect limits */
 		if(c->mina > 0 && c->maxa > 0) {
-			if(c->maxa < (float) w/h)
+			a = (float) w/h;
+			if(a > c->maxa)
 				w = h * c->maxa;
-			else if(c->mina > (float) h/w)
-				h = w * c->mina;
+			else if(a < c->mina)
+				h = w / c->mina;
+		}
+
+		if(baseismin) { /* increment calculation requires this */
+			w -= c->basew;
+			h -= c->baseh;
 		}
 
 		/* adjust for increment value */
> 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276