157 static long getstate(Window w); |
157 static long getstate(Window w); |
158 static Bool gettextprop(Window w, Atom atom, char *text, unsigned int size); |
158 static Bool gettextprop(Window w, Atom atom, char *text, unsigned int size); |
159 static void grabbuttons(Client *c, Bool focused); |
159 static void grabbuttons(Client *c, Bool focused); |
160 static void grabkeys(void); |
160 static void grabkeys(void); |
161 static void initfont(const char *fontstr); |
161 static void initfont(const char *fontstr); |
162 static Bool isoccupied(unsigned int t); |
|
163 static Bool isprotodel(Client *c); |
162 static Bool isprotodel(Client *c); |
164 static Bool isurgent(unsigned int t); |
|
165 static void keypress(XEvent *e); |
163 static void keypress(XEvent *e); |
166 static void killclient(const Arg *arg); |
164 static void killclient(const Arg *arg); |
167 static void manage(Window w, XWindowAttributes *wa); |
165 static void manage(Window w, XWindowAttributes *wa); |
168 static void mappingnotify(XEvent *e); |
166 static void mappingnotify(XEvent *e); |
169 static void maprequest(XEvent *e); |
167 static void maprequest(XEvent *e); |
498 exit(EXIT_FAILURE); |
496 exit(EXIT_FAILURE); |
499 } |
497 } |
500 |
498 |
501 void |
499 void |
502 drawbar(void) { |
500 drawbar(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) { |
519 dc.w = blw; |
521 dc.w = blw; |
520 drawtext(lt[sellt]->symbol, dc.norm, False); |
522 drawtext(lt[sellt]->symbol, dc.norm, False); |
739 if(focused) { |
741 if(focused) { |
740 for(i = 0; i < LENGTH(buttons); i++) |
742 for(i = 0; i < LENGTH(buttons); i++) |
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 } |
748 |
750 |
749 void |
751 void |
750 grabkeys(void) { |
752 grabkeys(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 |
755 /* init modifier map */ |
758 /* init modifier map */ |
756 modmap = XGetModifierMapping(dpy); |
759 modmap = XGetModifierMapping(dpy); |
762 XFreeModifiermap(modmap); |
765 XFreeModifiermap(modmap); |
763 |
766 |
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 |
778 void |
776 void |
779 initfont(const char *fontstr) { |
777 initfont(const char *fontstr) { |