summaryrefslogtreecommitdiffstats
path: root/dwm.c
diff options
context:
space:
mode:
Diffstat (limited to 'dwm.c')
-rw-r--r--dwm.c58
1 files changed, 18 insertions, 40 deletions
diff --git a/dwm.c b/dwm.c
index 279f831..5cbb59b 100644
--- a/dwm.c
+++ b/dwm.c
@@ -159,9 +159,7 @@ static Bool gettextprop(Window w, Atom atom, char *text, unsigned int size);
159static void grabbuttons(Client *c, Bool focused); 159static void grabbuttons(Client *c, Bool focused);
160static void grabkeys(void); 160static void grabkeys(void);
161static void initfont(const char *fontstr); 161static void initfont(const char *fontstr);
162static Bool isoccupied(unsigned int t);
163static Bool isprotodel(Client *c); 162static Bool isprotodel(Client *c);
164static Bool isurgent(unsigned int t);
165static void keypress(XEvent *e); 163static void keypress(XEvent *e);
166static void killclient(const Arg *arg); 164static void killclient(const Arg *arg);
167static void manage(Window w, XWindowAttributes *wa); 165static void manage(Window w, XWindowAttributes *wa);
@@ -500,19 +498,23 @@ die(const char *errstr, ...) {
500 498
501void 499void
502drawbar(void) { 500drawbar(void) {
503 int i, x; 501 int x;
502 unsigned int i, occ = 0, urg = 0;
503 unsigned long *col;
504 Client *c;
505
506 for(c = clients; c; c = c->next) {
507 occ |= c->tags;
508 if(c->isurgent)
509 urg |= c->tags;
510 }
504 511
505 dc.x = 0; 512 dc.x = 0;
506 for(i = 0; i < LENGTH(tags); i++) { 513 for(i = 0; i < LENGTH(tags); i++) {
507 dc.w = TEXTW(tags[i]); 514 dc.w = TEXTW(tags[i]);
508 if(tagset[seltags] & 1 << i) { 515 col = tagset[seltags] & 1 << i ? dc.sel : dc.norm;
509 drawtext(tags[i], dc.sel, isurgent(i)); 516 drawtext(tags[i], col, urg & 1 << i);
510 drawsquare(sel && sel->tags & 1 << i, isoccupied(i), isurgent(i), dc.sel); 517 drawsquare(sel && sel->tags & 1 << i, occ & 1 << i, urg & 1 << i, col);
511 }
512 else {
513 drawtext(tags[i], dc.norm, isurgent(i));
514 drawsquare(sel && sel->tags & 1 << i, isoccupied(i), isurgent(i), dc.norm);
515 }
516 dc.x += dc.w; 518 dc.x += dc.w;
517 } 519 }
518 if(blw > 0) { 520 if(blw > 0) {
@@ -741,7 +743,7 @@ grabbuttons(Client *c, Bool focused) {
741 if(buttons[i].click == ClkClientWin) 743 if(buttons[i].click == ClkClientWin)
742 for(j = 0; j < LENGTH(modifiers); j++) 744 for(j = 0; j < LENGTH(modifiers); j++)
743 XGrabButton(dpy, buttons[i].button, buttons[i].mask | modifiers[j], c->win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); 745 XGrabButton(dpy, buttons[i].button, buttons[i].mask | modifiers[j], c->win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
744 } else 746 } else
745 XGrabButton(dpy, AnyButton, AnyModifier, c->win, False, 747 XGrabButton(dpy, AnyButton, AnyModifier, c->win, False,
746 BUTTONMASK, GrabModeAsync, GrabModeSync, None, None); 748 BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
747} 749}
@@ -749,6 +751,7 @@ grabbuttons(Client *c, Bool focused) {
749void 751void
750grabkeys(void) { 752grabkeys(void) {
751 unsigned int i, j; 753 unsigned int i, j;
754 unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask };
752 KeyCode code; 755 KeyCode code;
753 XModifierKeymap *modmap; 756 XModifierKeymap *modmap;
754 757
@@ -764,14 +767,9 @@ grabkeys(void) {
764 XUngrabKey(dpy, AnyKey, AnyModifier, root); 767 XUngrabKey(dpy, AnyKey, AnyModifier, root);
765 for(i = 0; i < LENGTH(keys); i++) { 768 for(i = 0; i < LENGTH(keys); i++) {
766 code = XKeysymToKeycode(dpy, keys[i].keysym); 769 code = XKeysymToKeycode(dpy, keys[i].keysym);
767 XGrabKey(dpy, code, keys[i].mod, root, True, 770 for(j = 0; j < LENGTH(modifiers); j++)
768 GrabModeAsync, GrabModeAsync); 771 XGrabKey(dpy, code, keys[i].mod | modifiers[j], root, True,
769 XGrabKey(dpy, code, keys[i].mod|LockMask, root, True, 772 GrabModeAsync, GrabModeAsync);
770 GrabModeAsync, GrabModeAsync);
771 XGrabKey(dpy, code, keys[i].mod|numlockmask, root, True,
772 GrabModeAsync, GrabModeAsync);
773 XGrabKey(dpy, code, keys[i].mod|numlockmask|LockMask, root, True,
774 GrabModeAsync, GrabModeAsync);
775 } 773 }
776} 774}
777 775
@@ -816,16 +814,6 @@ initfont(const char *fontstr) {
816} 814}
817 815
818Bool 816Bool
819isoccupied(unsigned int t) {
820 Client *c;
821
822 for(c = clients; c; c = c->next)
823 if(c->tags & 1 << t)
824 return True;
825 return False;
826}
827
828Bool
829isprotodel(Client *c) { 817isprotodel(Client *c) {
830 int i, n; 818 int i, n;
831 Atom *protocols; 819 Atom *protocols;
@@ -840,16 +828,6 @@ isprotodel(Client *c) {
840 return ret; 828 return ret;
841} 829}
842 830
843Bool
844isurgent(unsigned int t) {
845 Client *c;
846
847 for(c = clients; c; c = c->next)
848 if(c->isurgent && c->tags & 1 << t)
849 return True;
850 return False;
851}
852
853void 831void
854keypress(XEvent *e) { 832keypress(XEvent *e) {
855 unsigned int i; 833 unsigned int i;