interactive resizals allow display dimensions again
52bd69c2
1 file(s) · +33 −20
| 148 | 148 | ||
| 149 | 149 | /* function declarations */ |
|
| 150 | 150 | static void applyrules(Client *c); |
|
| 151 | - | static Bool applysizehints(Client *c, int *x, int *y, int *w, int *h); |
|
| 151 | + | static Bool applysizehints(Client *c, int *x, int *y, int *w, int *h, Bool interact); |
|
| 152 | 152 | static void arrange(void); |
|
| 153 | 153 | static void attach(Client *c); |
|
| 154 | 154 | static void attachstack(Client *c); |
|
| 194 | 194 | static Monitor *pointertomon(int x, int y); |
|
| 195 | 195 | static void propertynotify(XEvent *e); |
|
| 196 | 196 | static void quit(const Arg *arg); |
|
| 197 | - | static void resize(Client *c, int x, int y, int w, int h); |
|
| 197 | + | static void resize(Client *c, int x, int y, int w, int h, Bool interact); |
|
| 198 | 198 | static void resizemouse(const Arg *arg); |
|
| 199 | 199 | static void restack(Monitor *m); |
|
| 200 | 200 | static void run(void); |
|
| 298 | 298 | } |
|
| 299 | 299 | ||
| 300 | 300 | Bool |
|
| 301 | - | applysizehints(Client *c, int *x, int *y, int *w, int *h) { |
|
| 301 | + | applysizehints(Client *c, int *x, int *y, int *w, int *h, Bool interact) { |
|
| 302 | 302 | Bool baseismin; |
|
| 303 | 303 | Monitor *m = c->mon; |
|
| 304 | 304 | ||
| 306 | 306 | *w = MAX(1, *w); |
|
| 307 | 307 | *h = MAX(1, *h); |
|
| 308 | 308 | ||
| 309 | - | if(*x > m->mx + m->mw) |
|
| 310 | - | *x = m->mx + m->mw - WIDTH(c); |
|
| 311 | - | if(*y > m->my + m->mh) |
|
| 312 | - | *y = m->my + m->mh - HEIGHT(c); |
|
| 313 | - | if(*x + *w + 2 * c->bw < m->mx) |
|
| 314 | - | *x = m->mx; |
|
| 315 | - | if(*y + *h + 2 * c->bw < m->my) |
|
| 316 | - | *y = m->my; |
|
| 309 | + | if(interact) { |
|
| 310 | + | if(*x > sw) |
|
| 311 | + | *x = sw - WIDTH(c); |
|
| 312 | + | if(*y > sh) |
|
| 313 | + | *y = sh - HEIGHT(c); |
|
| 314 | + | if(*x + *w + 2 * c->bw < 0) |
|
| 315 | + | *x = 0; |
|
| 316 | + | if(*y + *h + 2 * c->bw < 0) |
|
| 317 | + | *y = 0; |
|
| 318 | + | } |
|
| 319 | + | else { |
|
| 320 | + | if(*x > m->mx + m->mw) |
|
| 321 | + | *x = m->mx + m->mw - WIDTH(c); |
|
| 322 | + | if(*y > m->my + m->mh) |
|
| 323 | + | *y = m->my + m->mh - HEIGHT(c); |
|
| 324 | + | if(*x + *w + 2 * c->bw < m->mx) |
|
| 325 | + | *x = m->mx; |
|
| 326 | + | if(*y + *h + 2 * c->bw < m->my) |
|
| 327 | + | *y = m->my; |
|
| 328 | + | } |
|
| 317 | 329 | if(*h < bh) |
|
| 318 | 330 | *h = bh; |
|
| 319 | 331 | if(*w < bh) |
|
| 1120 | 1132 | Client *c; |
|
| 1121 | 1133 | ||
| 1122 | 1134 | for(c = nexttiled(m->clients); c; c = nexttiled(c->next)) |
|
| 1123 | - | resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw); |
|
| 1135 | + | resize(c, m->wx, m->wy, m->ww - 2 * c->bw, m->wh - 2 * c->bw, False); |
|
| 1124 | 1136 | } |
|
| 1125 | 1137 | ||
| 1126 | 1138 | void |
|
| 1166 | 1178 | togglefloating(NULL); |
|
| 1167 | 1179 | } |
|
| 1168 | 1180 | if(!lt[selmon->sellt]->arrange || c->isfloating) |
|
| 1169 | - | resize(c, nx, ny, c->w, c->h); |
|
| 1181 | + | resize(c, nx, ny, c->w, c->h, True); |
|
| 1170 | 1182 | break; |
|
| 1171 | 1183 | } |
|
| 1172 | 1184 | } |
|
| 1235 | 1247 | } |
|
| 1236 | 1248 | ||
| 1237 | 1249 | void |
|
| 1238 | - | resize(Client *c, int x, int y, int w, int h) { |
|
| 1250 | + | resize(Client *c, int x, int y, int w, int h, Bool interact) { |
|
| 1239 | 1251 | XWindowChanges wc; |
|
| 1240 | 1252 | ||
| 1241 | - | if(applysizehints(c, &x, &y, &w, &h)) { |
|
| 1253 | + | if(applysizehints(c, &x, &y, &w, &h, interact)) { |
|
| 1242 | 1254 | c->x = wc.x = x; |
|
| 1243 | 1255 | c->y = wc.y = y; |
|
| 1244 | 1256 | c->w = wc.width = w; |
|
| 1286 | 1298 | togglefloating(NULL); |
|
| 1287 | 1299 | } |
|
| 1288 | 1300 | if(!lt[selmon->sellt]->arrange || c->isfloating) |
|
| 1289 | - | resize(c, c->x, c->y, nw, nh); |
|
| 1301 | + | resize(c, c->x, c->y, nw, nh, True); |
|
| 1290 | 1302 | break; |
|
| 1291 | 1303 | } |
|
| 1292 | 1304 | } |
|
| 1484 | 1496 | if(ISVISIBLE(c)) { /* show clients top down */ |
|
| 1485 | 1497 | XMoveWindow(dpy, c->win, c->x, c->y); |
|
| 1486 | 1498 | if(!lt[c->mon->sellt]->arrange || c->isfloating) |
|
| 1487 | - | resize(c, c->x, c->y, c->w, c->h); |
|
| 1499 | + | resize(c, c->x, c->y, c->w, c->h, False); |
|
| 1488 | 1500 | showhide(c->snext); |
|
| 1489 | 1501 | } |
|
| 1490 | 1502 | else { /* hide clients bottom up */ |
|
| 1554 | 1566 | /* master */ |
|
| 1555 | 1567 | c = nexttiled(m->clients); |
|
| 1556 | 1568 | mw = m->mfact * m->ww; |
|
| 1557 | - | resize(c, m->wx, m->wy, (n == 1 ? m->ww : mw) - 2 * c->bw, m->wh - 2 * c->bw); |
|
| 1569 | + | resize(c, m->wx, m->wy, (n == 1 ? m->ww : mw) - 2 * c->bw, m->wh - 2 * c->bw, False); |
|
| 1558 | 1570 | ||
| 1559 | 1571 | if(--n == 0) |
|
| 1560 | 1572 | return; |
|
| 1569 | 1581 | ||
| 1570 | 1582 | for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) { |
|
| 1571 | 1583 | resize(c, x, y, w - 2 * c->bw, /* remainder */ ((i + 1 == n) |
|
| 1572 | - | ? m->wy + m->wh - y - 2 * c->bw : h - 2 * c->bw)); |
|
| 1584 | + | ? m->wy + m->wh - y - 2 * c->bw : h - 2 * c->bw), False); |
|
| 1573 | 1585 | if(h != m->wh) |
|
| 1574 | 1586 | y = c->y + HEIGHT(c); |
|
| 1575 | 1587 | } |
|
| 1589 | 1601 | return; |
|
| 1590 | 1602 | selmon->sel->isfloating = !selmon->sel->isfloating || selmon->sel->isfixed; |
|
| 1591 | 1603 | if(selmon->sel->isfloating) |
|
| 1592 | - | resize(selmon->sel, selmon->sel->x, selmon->sel->y, selmon->sel->w, selmon->sel->h); |
|
| 1604 | + | resize(selmon->sel, selmon->sel->x, selmon->sel->y, |
|
| 1605 | + | selmon->sel->w, selmon->sel->h, False); |
|
| 1593 | 1606 | arrange(); |
|
| 1594 | 1607 | } |
|
| 1595 | 1608 | ||