summaryrefslogtreecommitdiffstats
path: root/dwm.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--dwm.c53
1 files changed, 33 insertions, 20 deletions
diff --git a/dwm.c b/dwm.c
index 3857511..2e13241 100644
--- a/dwm.c
+++ b/dwm.c
@@ -148,7 +148,7 @@ typedef struct {
148 148
149/* function declarations */ 149/* function declarations */
150static void applyrules(Client *c); 150static void applyrules(Client *c);
151static Bool applysizehints(Client *c, int *x, int *y, int *w, int *h); 151static Bool applysizehints(Client *c, int *x, int *y, int *w, int *h, Bool interact);
152static void arrange(void); 152static void arrange(void);
153static void attach(Client *c); 153static void attach(Client *c);
154static void attachstack(Client *c); 154static void attachstack(Client *c);
@@ -194,7 +194,7 @@ static Client *nexttiled(Client *c);
194static Monitor *pointertomon(int x, int y); 194static Monitor *pointertomon(int x, int y);
195static void propertynotify(XEvent *e); 195static void propertynotify(XEvent *e);
196static void quit(const Arg *arg); 196static void quit(const Arg *arg);
197static void resize(Client *c, int x, int y, int w, int h); 197static void resize(Client *c, int x, int y, int w, int h, Bool interact);
198static void resizemouse(const Arg *arg); 198static void resizemouse(const Arg *arg);
199static void restack(Monitor *m); 199static void restack(Monitor *m);
200static void run(void); 200static void run(void);
@@ -298,7 +298,7 @@ applyrules(Client *c) {
298} 298}
299 299
300Bool 300Bool
301applysizehints(Client *c, int *x, int *y, int *w, int *h) { 301applysizehints(Client *c, int *x, int *y, int *w, int *h, Bool interact) {
302 Bool baseismin; 302 Bool baseismin;
303 Monitor *m = c->mon; 303 Monitor *m = c->mon;
304 304
@@ -306,14 +306,26 @@ applysizehints(Client *c, int *x, int *y, int *w, int *h) {
306 *w = MAX(1, *w); 306 *w = MAX(1, *w);
307 *h = MAX(1, *h); 307 *h = MAX(1, *h);
308 308
309 if(*x > m->mx + m->mw) 309 if(interact) {
310 *x = m->mx + m->mw - WIDTH(c); 310 if(*x > sw)
311 if(*y > m->my + m->mh) 311 *x = sw - WIDTH(c);
312 *y = m->my + m->mh - HEIGHT(c); 312 if(*y > sh)
313 if(*x + *w + 2 * c->bw < m->mx) 313 *y = sh - HEIGHT(c);
314 *x = m->mx; 314 if(*x + *w + 2 * c->bw < 0)
315 if(*y + *h + 2 * c->bw < m->my) 315 *x = 0;
316 *y = m->my; 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 if(*h < bh) 329 if(*h < bh)
318 *h = bh; 330 *h = bh;
319 if(*w < bh) 331 if(*w < bh)
@@ -1120,7 +1132,7 @@ monocle(Monitor *m) {
1120 Client *c; 1132 Client *c;
1121 1133
1122 for(c = nexttiled(m->clients); c; c = nexttiled(c->next)) 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
1126void 1138void
@@ -1166,7 +1178,7 @@ movemouse(const Arg *arg) {
1166 togglefloating(NULL); 1178 togglefloating(NULL);
1167 } 1179 }
1168 if(!lt[selmon->sellt]->arrange || c->isfloating) 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 break; 1182 break;
1171 } 1183 }
1172 } 1184 }
@@ -1235,10 +1247,10 @@ quit(const Arg *arg) {
1235} 1247}
1236 1248
1237void 1249void
1238resize(Client *c, int x, int y, int w, int h) { 1250resize(Client *c, int x, int y, int w, int h, Bool interact) {
1239 XWindowChanges wc; 1251 XWindowChanges wc;
1240 1252
1241 if(applysizehints(c, &x, &y, &w, &h)) { 1253 if(applysizehints(c, &x, &y, &w, &h, interact)) {
1242 c->x = wc.x = x; 1254 c->x = wc.x = x;
1243 c->y = wc.y = y; 1255 c->y = wc.y = y;
1244 c->w = wc.width = w; 1256 c->w = wc.width = w;
@@ -1286,7 +1298,7 @@ resizemouse(const Arg *arg) {
1286 togglefloating(NULL); 1298 togglefloating(NULL);
1287 } 1299 }
1288 if(!lt[selmon->sellt]->arrange || c->isfloating) 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 break; 1302 break;
1291 } 1303 }
1292 } 1304 }
@@ -1484,7 +1496,7 @@ showhide(Client *c) {
1484 if(ISVISIBLE(c)) { /* show clients top down */ 1496 if(ISVISIBLE(c)) { /* show clients top down */
1485 XMoveWindow(dpy, c->win, c->x, c->y); 1497 XMoveWindow(dpy, c->win, c->x, c->y);
1486 if(!lt[c->mon->sellt]->arrange || c->isfloating) 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 showhide(c->snext); 1500 showhide(c->snext);
1489 } 1501 }
1490 else { /* hide clients bottom up */ 1502 else { /* hide clients bottom up */
@@ -1554,7 +1566,7 @@ tile(Monitor *m) {
1554 /* master */ 1566 /* master */
1555 c = nexttiled(m->clients); 1567 c = nexttiled(m->clients);
1556 mw = m->mfact * m->ww; 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 if(--n == 0) 1571 if(--n == 0)
1560 return; 1572 return;
@@ -1569,7 +1581,7 @@ tile(Monitor *m) {
1569 1581
1570 for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) { 1582 for(i = 0, c = nexttiled(c->next); c; c = nexttiled(c->next), i++) {
1571 resize(c, x, y, w - 2 * c->bw, /* remainder */ ((i + 1 == n) 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 if(h != m->wh) 1585 if(h != m->wh)
1574 y = c->y + HEIGHT(c); 1586 y = c->y + HEIGHT(c);
1575 } 1587 }
@@ -1589,7 +1601,8 @@ togglefloating(const Arg *arg) {
1589 return; 1601 return;
1590 selmon->sel->isfloating = !selmon->sel->isfloating || selmon->sel->isfixed; 1602 selmon->sel->isfloating = !selmon->sel->isfloating || selmon->sel->isfixed;
1591 if(selmon->sel->isfloating) 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 arrange(); 1606 arrange();
1594} 1607}
1595 1608