summaryrefslogtreecommitdiffstats
path: root/dwm.c
diff options
context:
space:
mode:
authorAnselm R Garbe <anselm@garbe.us>2009-06-24 19:45:47 +0100
committerAnselm R Garbe <anselm@garbe.us>2009-06-24 19:45:47 +0100
commit18b1312449531c7b77403aafb71611e9e48500ec (patch)
tree811235937992f13f89f338c6f065528548145836 /dwm.c
parentsome focus fixes (diff)
downloaddwm-18b1312449531c7b77403aafb71611e9e48500ec.tar.gz
dwm-18b1312449531c7b77403aafb71611e9e48500ec.zip
several other focus fixes, introduced unfocus()
Diffstat (limited to 'dwm.c')
-rw-r--r--dwm.c38
1 files changed, 29 insertions, 9 deletions
diff --git a/dwm.c b/dwm.c
index e288ab6..d3169be 100644
--- a/dwm.c
+++ b/dwm.c
@@ -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);
211static void togglefloating(const Arg *arg); 211static void togglefloating(const Arg *arg);
212static void toggletag(const Arg *arg); 212static void toggletag(const Arg *arg);
213static void toggleview(const Arg *arg); 213static void toggleview(const Arg *arg);
214static void unfocus(Client *c);
214static void unmanage(Client *c); 215static void unmanage(Client *c);
215static void unmapnotify(XEvent *e); 216static void unmapnotify(XEvent *e);
216static void updategeom(void); 217static 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
757focus(Client *c) { 772focus(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
1592void 1605void
1606unfocus(Client *c) {
1607 if(!c)
1608 return;
1609 grabbuttons(c, False);
1610 XSetWindowBorder(dpy, c->win, dc.norm[ColBorder]);
1611}
1612
1613void
1593unmanage(Client *c) { 1614unmanage(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;