diff options
| author | Anselm R Garbe <garbeam@gmail.com> | 2008-02-22 10:03:42 +0000 |
|---|---|---|
| committer | Anselm R Garbe <garbeam@gmail.com> | 2008-02-22 10:03:42 +0000 |
| commit | dd218235369d12ad9d71269db11db05c464a09e0 (patch) | |
| tree | f05ab4817971f4c68f5431fad584948bf90aa919 | |
| parent | minor (diff) | |
| download | dwm-dd218235369d12ad9d71269db11db05c464a09e0.tar.gz dwm-dd218235369d12ad9d71269db11db05c464a09e0.zip | |
made arrange() Monitor-dependent as well, fixed the movemouse/resizemouse issues
| -rw-r--r-- | dwm.c | 52 |
1 files changed, 28 insertions, 24 deletions
| @@ -130,7 +130,7 @@ struct Monitor { | |||
| 130 | 130 | ||
| 131 | /* function declarations */ | 131 | /* function declarations */ |
| 132 | void applyrules(Client *c); | 132 | void applyrules(Client *c); |
| 133 | void arrange(void); | 133 | void arrange(Monitor *m); |
| 134 | void attach(Client *c); | 134 | void attach(Client *c); |
| 135 | void attachstack(Client *c); | 135 | void attachstack(Client *c); |
| 136 | void ban(Client *c); | 136 | void ban(Client *c); |
| @@ -299,7 +299,8 @@ applyrules(Client *c) { | |||
| 299 | } | 299 | } |
| 300 | 300 | ||
| 301 | void | 301 | void |
| 302 | arrange(void) { | 302 | arrange(Monitor *m) { |
| 303 | unsigned int i; | ||
| 303 | Client *c; | 304 | Client *c; |
| 304 | 305 | ||
| 305 | for(c = clients; c; c = c->next) | 306 | for(c = clients; c; c = c->next) |
| @@ -308,9 +309,13 @@ arrange(void) { | |||
| 308 | else | 309 | else |
| 309 | ban(c); | 310 | ban(c); |
| 310 | 311 | ||
| 311 | selmonitor->layout->arrange(selmonitor); | 312 | if(m) |
| 313 | m->layout->arrange(m); | ||
| 314 | else | ||
| 315 | for(i = 0; i < mcount; i++) | ||
| 316 | m->layout->arrange(&monitors[i]); | ||
| 312 | focus(NULL); | 317 | focus(NULL); |
| 313 | restack(selmonitor); | 318 | restack(m); |
| 314 | } | 319 | } |
| 315 | 320 | ||
| 316 | void | 321 | void |
| @@ -485,7 +490,7 @@ configurenotify(XEvent *e) { | |||
| 485 | dc.drawable = XCreatePixmap(dpy, root, DisplayWidth(root, screen), bh, DefaultDepth(dpy, screen)); | 490 | dc.drawable = XCreatePixmap(dpy, root, DisplayWidth(root, screen), bh, DefaultDepth(dpy, screen)); |
| 486 | XResizeWindow(dpy, m->barwin, m->sw, bh); | 491 | XResizeWindow(dpy, m->barwin, m->sw, bh); |
| 487 | updatebarpos(m); | 492 | updatebarpos(m); |
| 488 | arrange(); | 493 | arrange(m); |
| 489 | } | 494 | } |
| 490 | } | 495 | } |
| 491 | 496 | ||
| @@ -1078,7 +1083,7 @@ manage(Window w, XWindowAttributes *wa) { | |||
| 1078 | 1083 | ||
| 1079 | applyrules(c); | 1084 | applyrules(c); |
| 1080 | 1085 | ||
| 1081 | m = selmonitor; | 1086 | m = c->monitor; |
| 1082 | 1087 | ||
| 1083 | c->x = wa->x + m->sx; | 1088 | c->x = wa->x + m->sx; |
| 1084 | c->y = wa->y + m->sy; | 1089 | c->y = wa->y + m->sy; |
| @@ -1122,7 +1127,7 @@ manage(Window w, XWindowAttributes *wa) { | |||
| 1122 | ban(c); | 1127 | ban(c); |
| 1123 | XMapWindow(dpy, c->win); | 1128 | XMapWindow(dpy, c->win); |
| 1124 | setclientstate(c, NormalState); | 1129 | setclientstate(c, NormalState); |
| 1125 | arrange(); | 1130 | arrange(m); |
| 1126 | } | 1131 | } |
| 1127 | 1132 | ||
| 1128 | void | 1133 | void |
| @@ -1201,7 +1206,7 @@ movemouse(Client *c) { | |||
| 1201 | ny = m->way; | 1206 | ny = m->way; |
| 1202 | else if(abs((m->way + m->wah) - (ny + c->h + 2 * c->border)) < SNAP) | 1207 | else if(abs((m->way + m->wah) - (ny + c->h + 2 * c->border)) < SNAP) |
| 1203 | ny = m->way + m->wah - c->h - 2 * c->border; | 1208 | ny = m->way + m->wah - c->h - 2 * c->border; |
| 1204 | if((m->layout->arrange != floating) && (abs(nx - c->x) > SNAP || abs(ny - c->y) > SNAP)) | 1209 | if(!c->isfloating && (m->layout->arrange != floating) && (abs(nx - c->x) > SNAP || abs(ny - c->y) > SNAP)) |
| 1205 | togglefloating(NULL); | 1210 | togglefloating(NULL); |
| 1206 | if((m->layout->arrange == floating) || c->isfloating) | 1211 | if((m->layout->arrange == floating) || c->isfloating) |
| 1207 | resize(c, nx, ny, c->w, c->h, False); | 1212 | resize(c, nx, ny, c->w, c->h, False); |
| @@ -1230,7 +1235,7 @@ propertynotify(XEvent *e) { | |||
| 1230 | case XA_WM_TRANSIENT_FOR: | 1235 | case XA_WM_TRANSIENT_FOR: |
| 1231 | XGetTransientForHint(dpy, c->win, &trans); | 1236 | XGetTransientForHint(dpy, c->win, &trans); |
| 1232 | if(!c->isfloating && (c->isfloating = (getclient(trans) != NULL))) | 1237 | if(!c->isfloating && (c->isfloating = (getclient(trans) != NULL))) |
| 1233 | arrange(); | 1238 | arrange(c->monitor); |
| 1234 | break; | 1239 | break; |
| 1235 | case XA_WM_NORMAL_HINTS: | 1240 | case XA_WM_NORMAL_HINTS: |
| 1236 | updatesizehints(c); | 1241 | updatesizehints(c); |
| @@ -1262,7 +1267,7 @@ reapply(const char *arg) { | |||
| 1262 | memcpy(c->tags, zerotags, sizeof zerotags); | 1267 | memcpy(c->tags, zerotags, sizeof zerotags); |
| 1263 | applyrules(c); | 1268 | applyrules(c); |
| 1264 | } | 1269 | } |
| 1265 | arrange(); | 1270 | arrange(NULL); |
| 1266 | } | 1271 | } |
| 1267 | 1272 | ||
| 1268 | void | 1273 | void |
| @@ -1366,7 +1371,7 @@ resizemouse(Client *c) { | |||
| 1366 | nw = 1; | 1371 | nw = 1; |
| 1367 | if((nh = ev.xmotion.y - ocy - 2 * c->border + 1) <= 0) | 1372 | if((nh = ev.xmotion.y - ocy - 2 * c->border + 1) <= 0) |
| 1368 | nh = 1; | 1373 | nh = 1; |
| 1369 | if((m->layout->arrange != floating) && (abs(nw - c->w) > SNAP || abs(nh - c->h) > SNAP)) | 1374 | if(!c->isfloating && (m->layout->arrange != floating) && (abs(nw - c->w) > SNAP || abs(nh - c->h) > SNAP)) |
| 1370 | togglefloating(NULL); | 1375 | togglefloating(NULL); |
| 1371 | if((m->layout->arrange == floating) || c->isfloating) | 1376 | if((m->layout->arrange == floating) || c->isfloating) |
| 1372 | resize(c, c->x, c->y, nw, nh, True); | 1377 | resize(c, c->x, c->y, nw, nh, True); |
| @@ -1518,7 +1523,7 @@ setlayout(const char *arg) { | |||
| 1518 | m->layout = &layouts[i]; | 1523 | m->layout = &layouts[i]; |
| 1519 | } | 1524 | } |
| 1520 | if(sel) | 1525 | if(sel) |
| 1521 | arrange(); | 1526 | arrange(m); |
| 1522 | else | 1527 | else |
| 1523 | drawbar(m); | 1528 | drawbar(m); |
| 1524 | } | 1529 | } |
| @@ -1544,7 +1549,7 @@ setmwfact(const char *arg) { | |||
| 1544 | else if(m->mwfact > 0.9) | 1549 | else if(m->mwfact > 0.9) |
| 1545 | m->mwfact = 0.9; | 1550 | m->mwfact = 0.9; |
| 1546 | } | 1551 | } |
| 1547 | arrange(); | 1552 | arrange(m); |
| 1548 | } | 1553 | } |
| 1549 | 1554 | ||
| 1550 | void | 1555 | void |
| @@ -1697,7 +1702,7 @@ tag(const char *arg) { | |||
| 1697 | for(i = 0; i < LENGTH(tags); i++) | 1702 | for(i = 0; i < LENGTH(tags); i++) |
| 1698 | sel->tags[i] = (NULL == arg); | 1703 | sel->tags[i] = (NULL == arg); |
| 1699 | sel->tags[idxoftag(arg)] = True; | 1704 | sel->tags[idxoftag(arg)] = True; |
| 1700 | arrange(); | 1705 | arrange(sel->monitor); |
| 1701 | } | 1706 | } |
| 1702 | 1707 | ||
| 1703 | unsigned int | 1708 | unsigned int |
| @@ -1769,7 +1774,7 @@ togglebar(const char *arg) { | |||
| 1769 | else | 1774 | else |
| 1770 | bpos = BarOff; | 1775 | bpos = BarOff; |
| 1771 | updatebarpos(monitorat()); | 1776 | updatebarpos(monitorat()); |
| 1772 | arrange(); | 1777 | arrange(monitorat()); |
| 1773 | } | 1778 | } |
| 1774 | 1779 | ||
| 1775 | void | 1780 | void |
| @@ -1779,7 +1784,7 @@ togglefloating(const char *arg) { | |||
| 1779 | sel->isfloating = !sel->isfloating; | 1784 | sel->isfloating = !sel->isfloating; |
| 1780 | if(sel->isfloating) | 1785 | if(sel->isfloating) |
| 1781 | resize(sel, sel->x, sel->y, sel->w, sel->h, True); | 1786 | resize(sel, sel->x, sel->y, sel->w, sel->h, True); |
| 1782 | arrange(); | 1787 | arrange(sel->monitor); |
| 1783 | } | 1788 | } |
| 1784 | 1789 | ||
| 1785 | void | 1790 | void |
| @@ -1793,13 +1798,12 @@ toggletag(const char *arg) { | |||
| 1793 | for(j = 0; j < LENGTH(tags) && !sel->tags[j]; j++); | 1798 | for(j = 0; j < LENGTH(tags) && !sel->tags[j]; j++); |
| 1794 | if(j == LENGTH(tags)) | 1799 | if(j == LENGTH(tags)) |
| 1795 | sel->tags[i] = True; /* at least one tag must be enabled */ | 1800 | sel->tags[i] = True; /* at least one tag must be enabled */ |
| 1796 | arrange(); | 1801 | arrange(sel->monitor); |
| 1797 | } | 1802 | } |
| 1798 | 1803 | ||
| 1799 | void | 1804 | void |
| 1800 | toggleview(const char *arg) { | 1805 | toggleview(const char *arg) { |
| 1801 | unsigned int i, j; | 1806 | unsigned int i, j; |
| 1802 | |||
| 1803 | Monitor *m = monitorat(); | 1807 | Monitor *m = monitorat(); |
| 1804 | 1808 | ||
| 1805 | i = idxoftag(arg); | 1809 | i = idxoftag(arg); |
| @@ -1807,7 +1811,7 @@ toggleview(const char *arg) { | |||
| 1807 | for(j = 0; j < LENGTH(tags) && !m->seltags[j]; j++); | 1811 | for(j = 0; j < LENGTH(tags) && !m->seltags[j]; j++); |
| 1808 | if(j == LENGTH(tags)) | 1812 | if(j == LENGTH(tags)) |
| 1809 | m->seltags[i] = True; /* at least one tag must be viewed */ | 1813 | m->seltags[i] = True; /* at least one tag must be viewed */ |
| 1810 | arrange(); | 1814 | arrange(m); |
| 1811 | } | 1815 | } |
| 1812 | 1816 | ||
| 1813 | void | 1817 | void |
| @@ -1838,7 +1842,7 @@ unmanage(Client *c) { | |||
| 1838 | XSync(dpy, False); | 1842 | XSync(dpy, False); |
| 1839 | XSetErrorHandler(xerror); | 1843 | XSetErrorHandler(xerror); |
| 1840 | XUngrabServer(dpy); | 1844 | XUngrabServer(dpy); |
| 1841 | arrange(); | 1845 | arrange(NULL); |
| 1842 | } | 1846 | } |
| 1843 | 1847 | ||
| 1844 | void | 1848 | void |
| @@ -1988,7 +1992,7 @@ view(const char *arg) { | |||
| 1988 | if(memcmp(m->seltags, tmp, sizeof initags) != 0) { | 1992 | if(memcmp(m->seltags, tmp, sizeof initags) != 0) { |
| 1989 | memcpy(m->prevtags, m->seltags, sizeof initags); | 1993 | memcpy(m->prevtags, m->seltags, sizeof initags); |
| 1990 | memcpy(m->seltags, tmp, sizeof initags); | 1994 | memcpy(m->seltags, tmp, sizeof initags); |
| 1991 | arrange(); | 1995 | arrange(m); |
| 1992 | } | 1996 | } |
| 1993 | } | 1997 | } |
| 1994 | 1998 | ||
| @@ -2001,7 +2005,7 @@ viewprevtag(const char *arg) { | |||
| 2001 | memcpy(tmp, m->seltags, sizeof initags); | 2005 | memcpy(tmp, m->seltags, sizeof initags); |
| 2002 | memcpy(m->seltags, m->prevtags, sizeof initags); | 2006 | memcpy(m->seltags, m->prevtags, sizeof initags); |
| 2003 | memcpy(m->prevtags, tmp, sizeof initags); | 2007 | memcpy(m->prevtags, tmp, sizeof initags); |
| 2004 | arrange(); | 2008 | arrange(m); |
| 2005 | } | 2009 | } |
| 2006 | 2010 | ||
| 2007 | void | 2011 | void |
| @@ -2016,7 +2020,7 @@ zoom(const char *arg) { | |||
| 2016 | detach(c); | 2020 | detach(c); |
| 2017 | attach(c); | 2021 | attach(c); |
| 2018 | focus(c); | 2022 | focus(c); |
| 2019 | arrange(); | 2023 | arrange(c->monitor); |
| 2020 | } | 2024 | } |
| 2021 | 2025 | ||
| 2022 | void | 2026 | void |
| @@ -2035,7 +2039,7 @@ movetomonitor(const char *arg) { | |||
| 2035 | 2039 | ||
| 2036 | memcpy(sel->tags, sel->monitor->seltags, sizeof initags); | 2040 | memcpy(sel->tags, sel->monitor->seltags, sizeof initags); |
| 2037 | resize(sel, sel->monitor->wax, sel->monitor->way, sel->w, sel->h, True); | 2041 | resize(sel, sel->monitor->wax, sel->monitor->way, sel->w, sel->h, True); |
| 2038 | arrange(); | 2042 | arrange(sel->monitor); |
| 2039 | } | 2043 | } |
| 2040 | 2044 | ||
| 2041 | void | 2045 | void |
