diff options
Diffstat (limited to '')
| -rw-r--r-- | dwm.c | 38 |
1 files changed, 29 insertions, 9 deletions
| @@ -1,4 +1,4 @@ | |||
| 1 | //#define XINULATOR /* debug, simulates dual head */ | 1 | #define XINULATOR /* debug, simulates dual head */ |
| 2 | /* See LICENSE file for copyright and license details. | 2 | /* See LICENSE file for copyright and license details. |
| 3 | * | 3 | * |
| 4 | * dynamic window manager is designed like any other X client as well. It is | 4 | * dynamic window manager is designed like any other X client as well. It is |
| @@ -211,6 +211,7 @@ static void togglebar(const Arg *arg); | |||
| 211 | static void togglefloating(const Arg *arg); | 211 | static void togglefloating(const Arg *arg); |
| 212 | static void toggletag(const Arg *arg); | 212 | static void toggletag(const Arg *arg); |
| 213 | static void toggleview(const Arg *arg); | 213 | static void toggleview(const Arg *arg); |
| 214 | static void unfocus(Client *c); | ||
| 214 | static void unmanage(Client *c); | 215 | static void unmanage(Client *c); |
| 215 | static void unmapnotify(XEvent *e); | 216 | static void unmapnotify(XEvent *e); |
| 216 | static void updategeom(void); | 217 | static void updategeom(void); |
| @@ -391,9 +392,23 @@ buttonpress(XEvent *e) { | |||
| 391 | unsigned int i, x, click; | 392 | unsigned int i, x, click; |
| 392 | Arg arg = {0}; | 393 | Arg arg = {0}; |
| 393 | Client *c; | 394 | Client *c; |
| 395 | Monitor *m; | ||
| 394 | XButtonPressedEvent *ev = &e->xbutton; | 396 | XButtonPressedEvent *ev = &e->xbutton; |
| 395 | 397 | ||
| 396 | click = ClkRootWin; | 398 | click = ClkRootWin; |
| 399 | /* focus monitor if necessary */ | ||
| 400 | for(m = mons; m; m = m->next) | ||
| 401 | if(ev->window == m->barwin) { | ||
| 402 | if(m != selmon) { | ||
| 403 | if(selmon->stack) | ||
| 404 | focus(selmon->stack); | ||
| 405 | else { | ||
| 406 | selmon = m; | ||
| 407 | focus(NULL); | ||
| 408 | } | ||
| 409 | } | ||
| 410 | break; | ||
| 411 | } | ||
| 397 | if(ev->window == selmon->barwin && ev->x >= selmon->btx) { | 412 | if(ev->window == selmon->barwin && ev->x >= selmon->btx) { |
| 398 | i = 0; | 413 | i = 0; |
| 399 | x = selmon->btx; | 414 | x = selmon->btx; |
| @@ -757,10 +772,8 @@ void | |||
| 757 | focus(Client *c) { | 772 | focus(Client *c) { |
| 758 | if(!c || !ISVISIBLE(c)) | 773 | if(!c || !ISVISIBLE(c)) |
| 759 | for(c = selmon->stack; c && !ISVISIBLE(c); c = c->snext); | 774 | for(c = selmon->stack; c && !ISVISIBLE(c); c = c->snext); |
| 760 | if(selmon->sel && selmon->sel != c) { | 775 | if(selmon->sel) |
| 761 | grabbuttons(selmon->sel, False); | 776 | unfocus(selmon->sel); |
| 762 | XSetWindowBorder(dpy, selmon->sel->win, dc.norm[ColBorder]); | ||
| 763 | } | ||
| 764 | if(c) { | 777 | if(c) { |
| 765 | if(c->mon != selmon) | 778 | if(c->mon != selmon) |
| 766 | selmon = c->mon; | 779 | selmon = c->mon; |
| @@ -797,6 +810,7 @@ focusmon(const Arg *arg) { | |||
| 797 | if(m->stack) | 810 | if(m->stack) |
| 798 | focus(m->stack); | 811 | focus(m->stack); |
| 799 | else { | 812 | else { |
| 813 | unfocus(selmon->stack); | ||
| 800 | selmon = m; | 814 | selmon = m; |
| 801 | focus(NULL); | 815 | focus(NULL); |
| 802 | } | 816 | } |
| @@ -1219,8 +1233,7 @@ resize(Client *c, int x, int y, int w, int h) { | |||
| 1219 | c->w = wc.width = w; | 1233 | c->w = wc.width = w; |
| 1220 | c->h = wc.height = h; | 1234 | c->h = wc.height = h; |
| 1221 | wc.border_width = c->bw; | 1235 | wc.border_width = c->bw; |
| 1222 | XConfigureWindow(dpy, c->win, | 1236 | XConfigureWindow(dpy, c->win, CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc); |
| 1223 | CWX|CWY|CWWidth|CWHeight|CWBorderWidth, &wc); | ||
| 1224 | configure(c); | 1237 | configure(c); |
| 1225 | XSync(dpy, False); | 1238 | XSync(dpy, False); |
| 1226 | } | 1239 | } |
| @@ -1590,6 +1603,14 @@ toggleview(const Arg *arg) { | |||
| 1590 | } | 1603 | } |
| 1591 | 1604 | ||
| 1592 | void | 1605 | void |
| 1606 | unfocus(Client *c) { | ||
| 1607 | if(!c) | ||
| 1608 | return; | ||
| 1609 | grabbuttons(c, False); | ||
| 1610 | XSetWindowBorder(dpy, c->win, dc.norm[ColBorder]); | ||
| 1611 | } | ||
| 1612 | |||
| 1613 | void | ||
| 1593 | unmanage(Client *c) { | 1614 | unmanage(Client *c) { |
| 1594 | XWindowChanges wc; | 1615 | XWindowChanges wc; |
| 1595 | 1616 | ||
| @@ -1732,7 +1753,7 @@ updategeom(void) { | |||
| 1732 | } | 1753 | } |
| 1733 | 1754 | ||
| 1734 | /* reassign left over clients of disappeared monitors */ | 1755 | /* reassign left over clients of disappeared monitors */ |
| 1735 | for(tm = mons; tm; tm = tm->next) { | 1756 | for(tm = mons; tm; tm = tm->next) |
| 1736 | while(tm->clients) { | 1757 | while(tm->clients) { |
| 1737 | c = tm->clients; | 1758 | c = tm->clients; |
| 1738 | tm->clients = c->next; | 1759 | tm->clients = c->next; |
| @@ -1741,7 +1762,6 @@ updategeom(void) { | |||
| 1741 | attach(c); | 1762 | attach(c); |
| 1742 | attachstack(c); | 1763 | attachstack(c); |
| 1743 | } | 1764 | } |
| 1744 | } | ||
| 1745 | 1765 | ||
| 1746 | /* select focused monitor */ | 1766 | /* select focused monitor */ |
| 1747 | selmon = newmons; | 1767 | selmon = newmons; |
