changeset 1417 | 8d447b21ca19 |
parent 1416 | e802c6186f6c |
child 1418 | 37e3b2a40f6f |
1416:e802c6186f6c | 1417:8d447b21ca19 |
---|---|
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 |
5 * driven through handling X events. In contrast to other X clients, a window |
5 * driven through handling X events. In contrast to other X clients, a window |
6 * manager selects for SubstructureRedirectMask on the root window, to receive |
6 * manager selects for SubstructureRedirectMask on the root window, to receive |
209 static void tile(Monitor *); |
209 static void tile(Monitor *); |
210 static void togglebar(const Arg *arg); |
210 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); |
217 static void updatebarpos(Monitor *m); |
218 static void updatebarpos(Monitor *m); |
218 static void updatebars(void); |
219 static void updatebars(void); |
389 void |
390 void |
390 buttonpress(XEvent *e) { |
391 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; |
400 do |
415 do |
401 x += TEXTW(tags[i]); |
416 x += TEXTW(tags[i]); |
755 |
770 |
756 void |
771 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; |
767 if(c->isurgent) |
780 if(c->isurgent) |
768 clearurgent(c); |
781 clearurgent(c); |
795 for(i = 0, m = mons; m; m = m->next, i++) |
808 for(i = 0, m = mons; m; m = m->next, i++) |
796 if(i == arg->ui) { |
809 if(i == arg->ui) { |
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 } |
803 drawbars(); |
817 drawbars(); |
804 break; |
818 break; |
1217 c->x = wc.x = x; |
1231 c->x = wc.x = x; |
1218 c->y = wc.y = y; |
1232 c->y = wc.y = y; |
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 } |
1227 } |
1240 } |
1228 |
1241 |
1585 |
1598 |
1586 if(mask) { |
1599 if(mask) { |
1587 selmon->tagset[selmon->seltags] = mask; |
1600 selmon->tagset[selmon->seltags] = mask; |
1588 arrange(); |
1601 arrange(); |
1589 } |
1602 } |
1603 } |
|
1604 |
|
1605 void |
|
1606 unfocus(Client *c) { |
|
1607 if(!c) |
|
1608 return; |
|
1609 grabbuttons(c, False); |
|
1610 XSetWindowBorder(dpy, c->win, dc.norm[ColBorder]); |
|
1590 } |
1611 } |
1591 |
1612 |
1592 void |
1613 void |
1593 unmanage(Client *c) { |
1614 unmanage(Client *c) { |
1594 XWindowChanges wc; |
1615 XWindowChanges wc; |
1730 m->topbar = topbar; |
1751 m->topbar = topbar; |
1731 updatebarpos(m); |
1752 updatebarpos(m); |
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; |
1739 detachstack(c); |
1760 detachstack(c); |
1740 c->mon = newmons; |
1761 c->mon = newmons; |
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; |
1748 if(XQueryPointer(dpy, root, &dummy, &dummy, &x, &y, &di, &di, &dui)) |
1768 if(XQueryPointer(dpy, root, &dummy, &dummy, &x, &y, &di, &di, &dui)) |
1749 for(m = newmons; m; m = m->next) |
1769 for(m = newmons; m; m = m->next) |