applied Gottox' resizehints patch, thanks Gottox!
af508c2e
1 file(s) · +52 −45
| 129 | 129 | ||
| 130 | 130 | /* function declarations */ |
|
| 131 | 131 | static void applyrules(Client *c); |
|
| 132 | + | static void applysizehints(Client *c, int *w, int *h); |
|
| 132 | 133 | static void arrange(void); |
|
| 133 | 134 | static void attach(Client *c); |
|
| 134 | 135 | static void attachstack(Client *c); |
|
| 268 | 269 | } |
|
| 269 | 270 | if(!c->tags) |
|
| 270 | 271 | c->tags = tagset[seltags]; |
|
| 272 | + | } |
|
| 273 | + | ||
| 274 | + | void |
|
| 275 | + | applysizehints(Client *c, int *w, int *h) { |
|
| 276 | + | Bool baseismin; |
|
| 277 | + | ||
| 278 | + | /* see last two sentences in ICCCM 4.1.2.3 */ |
|
| 279 | + | baseismin = c->basew == c->minw && c->baseh == c->minh; |
|
| 280 | + | ||
| 281 | + | /* set minimum possible */ |
|
| 282 | + | *w = MAX(1, *w); |
|
| 283 | + | *h = MAX(1, *h); |
|
| 284 | + | ||
| 285 | + | if(!baseismin) { /* temporarily remove base dimensions */ |
|
| 286 | + | *w -= c->basew; |
|
| 287 | + | *h -= c->baseh; |
|
| 288 | + | } |
|
| 289 | + | ||
| 290 | + | /* adjust for aspect limits */ |
|
| 291 | + | if(c->mina > 0 && c->maxa > 0) { |
|
| 292 | + | if(c->maxa < (float)*w / *h) |
|
| 293 | + | *w = *h * c->maxa; |
|
| 294 | + | else if(c->mina < (float)*h / *w) |
|
| 295 | + | *h = *w * c->mina; |
|
| 296 | + | } |
|
| 297 | + | ||
| 298 | + | if(baseismin) { /* increment calculation requires this */ |
|
| 299 | + | *w -= c->basew; |
|
| 300 | + | *h -= c->baseh; |
|
| 301 | + | } |
|
| 302 | + | ||
| 303 | + | /* adjust for increment value */ |
|
| 304 | + | if(c->incw) |
|
| 305 | + | *w -= *w % c->incw; |
|
| 306 | + | if(c->inch) |
|
| 307 | + | *h -= *h % c->inch; |
|
| 308 | + | ||
| 309 | + | /* restore base dimensions */ |
|
| 310 | + | *w += c->basew; |
|
| 311 | + | *h += c->baseh; |
|
| 312 | + | ||
| 313 | + | *w = MAX(*w, c->minw); |
|
| 314 | + | *h = MAX(*h, c->minh); |
|
| 315 | + | ||
| 316 | + | if(c->maxw) |
|
| 317 | + | *w = MIN(*w, c->maxw); |
|
| 318 | + | ||
| 319 | + | if(c->maxh) |
|
| 320 | + | *h = MIN(*h, c->maxh); |
|
| 271 | 321 | } |
|
| 272 | 322 | ||
| 273 | 323 | void |
|
| 1038 | 1088 | resize(Client *c, int x, int y, int w, int h, Bool sizehints) { |
|
| 1039 | 1089 | XWindowChanges wc; |
|
| 1040 | 1090 | ||
| 1041 | - | if(sizehints) { |
|
| 1042 | - | /* see last two sentences in ICCCM 4.1.2.3 */ |
|
| 1043 | - | Bool baseismin = c->basew == c->minw && c->baseh == c->minh; |
|
| 1044 | - | ||
| 1045 | - | /* set minimum possible */ |
|
| 1046 | - | w = MAX(1, w); |
|
| 1047 | - | h = MAX(1, h); |
|
| 1048 | - | ||
| 1049 | - | if(!baseismin) { /* temporarily remove base dimensions */ |
|
| 1050 | - | w -= c->basew; |
|
| 1051 | - | h -= c->baseh; |
|
| 1052 | - | } |
|
| 1053 | - | ||
| 1054 | - | /* adjust for aspect limits */ |
|
| 1055 | - | if(c->mina > 0 && c->maxa > 0) { |
|
| 1056 | - | if(c->maxa < (float)w / h) |
|
| 1057 | - | w = h * c->maxa; |
|
| 1058 | - | else if(c->mina < (float)h / w) |
|
| 1059 | - | h = w * c->mina; |
|
| 1060 | - | } |
|
| 1061 | - | ||
| 1062 | - | if(baseismin) { /* increment calculation requires this */ |
|
| 1063 | - | w -= c->basew; |
|
| 1064 | - | h -= c->baseh; |
|
| 1065 | - | } |
|
| 1066 | - | ||
| 1067 | - | /* adjust for increment value */ |
|
| 1068 | - | if(c->incw) |
|
| 1069 | - | w -= w % c->incw; |
|
| 1070 | - | if(c->inch) |
|
| 1071 | - | h -= h % c->inch; |
|
| 1072 | - | ||
| 1073 | - | /* restore base dimensions */ |
|
| 1074 | - | w += c->basew; |
|
| 1075 | - | h += c->baseh; |
|
| 1076 | - | ||
| 1077 | - | w = MAX(w, c->minw); |
|
| 1078 | - | h = MAX(h, c->minh); |
|
| 1079 | - | ||
| 1080 | - | if(c->maxw) |
|
| 1081 | - | w = MIN(w, c->maxw); |
|
| 1082 | - | ||
| 1083 | - | if(c->maxh) |
|
| 1084 | - | h = MIN(h, c->maxh); |
|
| 1085 | - | } |
|
| 1091 | + | if(sizehints) |
|
| 1092 | + | applysizehints(c, &w, &h); |
|
| 1086 | 1093 | if(w <= 0 || h <= 0) |
|
| 1087 | 1094 | return; |
|
| 1088 | 1095 | if(x > sx + sw) |
|