summaryrefslogtreecommitdiffstats
path: root/dwm.c
diff options
context:
space:
mode:
authorAnselm R Garbe <anselm@garbe.us>2009-09-27 10:31:14 +0100
committerAnselm R Garbe <anselm@garbe.us>2009-09-27 10:31:14 +0100
commit9e8dd3479da9f484c9aa37adcd327989149e89ef (patch)
tree35c168a1781bfb0e8068a392f4ba15e06c649160 /dwm.c
parentAdded tag 5.7 for changeset 257403d4cd96 (diff)
downloaddwm-9e8dd3479da9f484c9aa37adcd327989149e89ef.tar.gz
dwm-9e8dd3479da9f484c9aa37adcd327989149e89ef.zip
fixed the layout symbol bug reported by Nibble (but using a different approach as he suggested)
- optimised drawbar() and arrange() handling for multiple monitors, arrange only arranges the relevant monitors when applicable, same with drawbar - need to release 5.7.1
Diffstat (limited to 'dwm.c')
-rw-r--r--dwm.c66
1 files changed, 38 insertions, 28 deletions
diff --git a/dwm.c b/dwm.c
index 5199e71..b3a389d 100644
--- a/dwm.c
+++ b/dwm.c
@@ -152,7 +152,8 @@ typedef struct {
152/* function declarations */ 152/* function declarations */
153static void applyrules(Client *c); 153static void applyrules(Client *c);
154static Bool applysizehints(Client *c, int *x, int *y, int *w, int *h, Bool interact); 154static Bool applysizehints(Client *c, int *x, int *y, int *w, int *h, Bool interact);
155static void arrange(void); 155static void arrange(Monitor *m);
156static void arrangemon(Monitor *m);
156static void attach(Client *c); 157static void attach(Client *c);
157static void attachstack(Client *c); 158static void attachstack(Client *c);
158static void buttonpress(XEvent *e); 159static void buttonpress(XEvent *e);
@@ -379,18 +380,24 @@ applysizehints(Client *c, int *x, int *y, int *w, int *h, Bool interact) {
379} 380}
380 381
381void 382void
382arrange(void) { 383arrange(Monitor *m) {
383 Monitor *m; 384 if(m)
384 385 showhide(m->stack);
385 for(m = mons; m; m = m->next) 386 else for(m = mons; m; m = m->next)
386 showhide(m->stack); 387 showhide(m->stack);
387 focus(NULL); 388 focus(NULL);
388 for(m = mons; m; m = m->next) { 389 if(m)
389 strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, sizeof m->ltsymbol); 390 arrangemon(m);
390 if(m->lt[m->sellt]->arrange) 391 else for(m = mons; m; m = m->next)
391 m->lt[m->sellt]->arrange(m); 392 arrangemon(m);
392 restack(m); 393}
393 } 394
395void
396arrangemon(Monitor *m) {
397 strncpy(m->ltsymbol, m->lt[m->sellt]->symbol, sizeof m->ltsymbol);
398 if(m->lt[m->sellt]->arrange)
399 m->lt[m->sellt]->arrange(m);
400 restack(m);
394} 401}
395 402
396void 403void
@@ -546,7 +553,7 @@ configurenotify(XEvent *e) {
546 updatebars(); 553 updatebars();
547 for(m = mons; m; m = m->next) 554 for(m = mons; m; m = m->next)
548 XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh); 555 XMoveResizeWindow(dpy, m->barwin, m->wx, m->by, m->ww, bh);
549 arrange(); 556 arrange(NULL);
550 } 557 }
551 } 558 }
552} 559}
@@ -1139,7 +1146,7 @@ manage(Window w, XWindowAttributes *wa) {
1139 XMoveResizeWindow(dpy, c->win, c->x + 2 * sw, c->y, c->w, c->h); /* some windows require this */ 1146 XMoveResizeWindow(dpy, c->win, c->x + 2 * sw, c->y, c->w, c->h); /* some windows require this */
1140 XMapWindow(dpy, c->win); 1147 XMapWindow(dpy, c->win);
1141 setclientstate(c, NormalState); 1148 setclientstate(c, NormalState);
1142 arrange(); 1149 arrange(c->mon);
1143} 1150}
1144 1151
1145void 1152void
@@ -1265,7 +1272,7 @@ propertynotify(XEvent *e) {
1265 case XA_WM_TRANSIENT_FOR: 1272 case XA_WM_TRANSIENT_FOR:
1266 XGetTransientForHint(dpy, c->win, &trans); 1273 XGetTransientForHint(dpy, c->win, &trans);
1267 if(!c->isfloating && (c->isfloating = (wintoclient(trans) != NULL))) 1274 if(!c->isfloating && (c->isfloating = (wintoclient(trans) != NULL)))
1268 arrange(); 1275 arrange(c->mon);
1269 break; 1276 break;
1270 case XA_WM_NORMAL_HINTS: 1277 case XA_WM_NORMAL_HINTS:
1271 updatesizehints(c); 1278 updatesizehints(c);
@@ -1360,7 +1367,7 @@ restack(Monitor *m) {
1360 XEvent ev; 1367 XEvent ev;
1361 XWindowChanges wc; 1368 XWindowChanges wc;
1362 1369
1363 drawbars(); 1370 drawbar(m);
1364 if(!m->sel) 1371 if(!m->sel)
1365 return; 1372 return;
1366 if(m->sel->isfloating || !m->lt[m->sellt]->arrange) 1373 if(m->sel->isfloating || !m->lt[m->sellt]->arrange)
@@ -1427,7 +1434,7 @@ sendmon(Client *c, Monitor *m) {
1427 attach(c); 1434 attach(c);
1428 attachstack(c); 1435 attachstack(c);
1429 focus(NULL); 1436 focus(NULL);
1430 arrange(); 1437 arrange(NULL);
1431} 1438}
1432 1439
1433void 1440void
@@ -1442,12 +1449,14 @@ void
1442setlayout(const Arg *arg) { 1449setlayout(const Arg *arg) {
1443 if(!arg || !arg->v || arg->v != selmon->lt[selmon->sellt]) 1450 if(!arg || !arg->v || arg->v != selmon->lt[selmon->sellt])
1444 selmon->sellt ^= 1; 1451 selmon->sellt ^= 1;
1445 if(arg && arg->v) 1452 if(arg && arg->v) {
1446 selmon->lt[selmon->sellt] = (Layout *)arg->v; 1453 selmon->lt[selmon->sellt] = (Layout *)arg->v;
1454 strncpy(selmon->ltsymbol, selmon->lt[selmon->sellt]->symbol, sizeof selmon->ltsymbol);
1455 }
1447 if(selmon->sel) 1456 if(selmon->sel)
1448 arrange(); 1457 arrange(selmon);
1449 else 1458 else
1450 drawbars(); 1459 drawbar(selmon);
1451} 1460}
1452 1461
1453/* arg > 1.0 will set mfact absolutly */ 1462/* arg > 1.0 will set mfact absolutly */
@@ -1461,7 +1470,7 @@ setmfact(const Arg *arg) {
1461 if(f < 0.1 || f > 0.9) 1470 if(f < 0.1 || f > 0.9)
1462 return; 1471 return;
1463 selmon->mfact = f; 1472 selmon->mfact = f;
1464 arrange(); 1473 arrange(selmon);
1465} 1474}
1466 1475
1467void 1476void
@@ -1558,7 +1567,7 @@ void
1558tag(const Arg *arg) { 1567tag(const Arg *arg) {
1559 if(selmon->sel && arg->ui & TAGMASK) { 1568 if(selmon->sel && arg->ui & TAGMASK) {
1560 selmon->sel->tags = arg->ui & TAGMASK; 1569 selmon->sel->tags = arg->ui & TAGMASK;
1561 arrange(); 1570 arrange(selmon);
1562 } 1571 }
1563} 1572}
1564 1573
@@ -1615,7 +1624,7 @@ togglebar(const Arg *arg) {
1615 selmon->showbar = !selmon->showbar; 1624 selmon->showbar = !selmon->showbar;
1616 updatebarpos(selmon); 1625 updatebarpos(selmon);
1617 XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh); 1626 XMoveResizeWindow(dpy, selmon->barwin, selmon->wx, selmon->by, selmon->ww, bh);
1618 arrange(); 1627 arrange(selmon);
1619} 1628}
1620 1629
1621void 1630void
@@ -1626,7 +1635,7 @@ togglefloating(const Arg *arg) {
1626 if(selmon->sel->isfloating) 1635 if(selmon->sel->isfloating)
1627 resize(selmon->sel, selmon->sel->x, selmon->sel->y, 1636 resize(selmon->sel, selmon->sel->x, selmon->sel->y,
1628 selmon->sel->w, selmon->sel->h, False); 1637 selmon->sel->w, selmon->sel->h, False);
1629 arrange(); 1638 arrange(selmon);
1630} 1639}
1631 1640
1632void 1641void
@@ -1638,7 +1647,7 @@ toggletag(const Arg *arg) {
1638 newtags = selmon->sel->tags ^ (arg->ui & TAGMASK); 1647 newtags = selmon->sel->tags ^ (arg->ui & TAGMASK);
1639 if(newtags) { 1648 if(newtags) {
1640 selmon->sel->tags = newtags; 1649 selmon->sel->tags = newtags;
1641 arrange(); 1650 arrange(selmon);
1642 } 1651 }
1643} 1652}
1644 1653
@@ -1648,7 +1657,7 @@ toggleview(const Arg *arg) {
1648 1657
1649 if(newtagset) { 1658 if(newtagset) {
1650 selmon->tagset[selmon->seltags] = newtagset; 1659 selmon->tagset[selmon->seltags] = newtagset;
1651 arrange(); 1660 arrange(selmon);
1652 } 1661 }
1653} 1662}
1654 1663
@@ -1663,6 +1672,7 @@ unfocus(Client *c) {
1663 1672
1664void 1673void
1665unmanage(Client *c, Bool destroyed) { 1674unmanage(Client *c, Bool destroyed) {
1675 Monitor *m = c->mon;
1666 XWindowChanges wc; 1676 XWindowChanges wc;
1667 1677
1668 /* The server grab construct avoids race conditions. */ 1678 /* The server grab construct avoids race conditions. */
@@ -1681,7 +1691,7 @@ unmanage(Client *c, Bool destroyed) {
1681 } 1691 }
1682 free(c); 1692 free(c);
1683 focus(NULL); 1693 focus(NULL);
1684 arrange(); 1694 arrange(m);
1685} 1695}
1686 1696
1687void 1697void
@@ -1908,7 +1918,7 @@ view(const Arg *arg) {
1908 selmon->seltags ^= 1; /* toggle sel tagset */ 1918 selmon->seltags ^= 1; /* toggle sel tagset */
1909 if(arg->ui & TAGMASK) 1919 if(arg->ui & TAGMASK)
1910 selmon->tagset[selmon->seltags] = arg->ui & TAGMASK; 1920 selmon->tagset[selmon->seltags] = arg->ui & TAGMASK;
1911 arrange(); 1921 arrange(selmon);
1912} 1922}
1913 1923
1914Client * 1924Client *
@@ -1986,7 +1996,7 @@ zoom(const Arg *arg) {
1986 detach(c); 1996 detach(c);
1987 attach(c); 1997 attach(c);
1988 focus(c); 1998 focus(c);
1989 arrange(); 1999 arrange(c->mon);
1990} 2000}
1991 2001
1992int 2002int