about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-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 */
ref='#n120'>120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174