equal
deleted
inserted
replaced
50 #define CLEANMASK(mask) (mask & ~(numlockmask|LockMask)) |
50 #define CLEANMASK(mask) (mask & ~(numlockmask|LockMask)) |
51 #define LENGTH(x) (sizeof x / sizeof x[0]) |
51 #define LENGTH(x) (sizeof x / sizeof x[0]) |
52 #define MAXTAGLEN 16 |
52 #define MAXTAGLEN 16 |
53 #define MOUSEMASK (BUTTONMASK|PointerMotionMask) |
53 #define MOUSEMASK (BUTTONMASK|PointerMotionMask) |
54 #define TAGMASK ((int)((1LL << LENGTH(tags)) - 1)) |
54 #define TAGMASK ((int)((1LL << LENGTH(tags)) - 1)) |
|
55 #define VISIBLE(x) ((x)->tags & tagset[seltags]) |
55 |
56 |
56 /* enums */ |
57 /* enums */ |
57 enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ |
58 enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */ |
58 enum { ColBorder, ColFG, ColBG, ColLast }; /* color */ |
59 enum { ColBorder, ColFG, ColBG, ColLast }; /* color */ |
59 enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */ |
60 enum { NetSupported, NetWMName, NetLast }; /* EWMH atoms */ |
147 void grabkeys(void); |
148 void grabkeys(void); |
148 void initfont(const char *fontstr); |
149 void initfont(const char *fontstr); |
149 Bool isoccupied(uint t); |
150 Bool isoccupied(uint t); |
150 Bool isprotodel(Client *c); |
151 Bool isprotodel(Client *c); |
151 Bool isurgent(uint t); |
152 Bool isurgent(uint t); |
152 Bool isvisible(Client *c); |
|
153 void keypress(XEvent *e); |
153 void keypress(XEvent *e); |
154 void killclient(const void *arg); |
154 void killclient(const void *arg); |
155 void manage(Window w, XWindowAttributes *wa); |
155 void manage(Window w, XWindowAttributes *wa); |
156 void mappingnotify(XEvent *e); |
156 void mappingnotify(XEvent *e); |
157 void maprequest(XEvent *e); |
157 void maprequest(XEvent *e); |
265 void |
265 void |
266 arrange(void) { |
266 arrange(void) { |
267 Client *c; |
267 Client *c; |
268 |
268 |
269 for(c = clients; c; c = c->next) |
269 for(c = clients; c; c = c->next) |
270 if(isvisible(c)) { |
270 if(VISIBLE(c)) { |
271 unban(c); |
271 unban(c); |
272 if(!lt->arrange || c->isfloating) |
272 if(!lt->arrange || c->isfloating) |
273 resize(c, c->x, c->y, c->w, c->h, True); |
273 resize(c, c->x, c->y, c->w, c->h, True); |
274 } |
274 } |
275 else |
275 else |
442 if((c->y - sy + c->h) > sh && c->isfloating) |
442 if((c->y - sy + c->h) > sh && c->isfloating) |
443 c->y = sy + (sh / 2 - c->h / 2); /* center in y direction */ |
443 c->y = sy + (sh / 2 - c->h / 2); /* center in y direction */ |
444 if((ev->value_mask & (CWX|CWY)) |
444 if((ev->value_mask & (CWX|CWY)) |
445 && !(ev->value_mask & (CWWidth|CWHeight))) |
445 && !(ev->value_mask & (CWWidth|CWHeight))) |
446 configure(c); |
446 configure(c); |
447 if(isvisible(c)) |
447 if(VISIBLE(c)) |
448 XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h); |
448 XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h); |
449 } |
449 } |
450 else |
450 else |
451 configure(c); |
451 configure(c); |
452 } |
452 } |
495 drawbar(void) { |
495 drawbar(void) { |
496 int i, x; |
496 int i, x; |
497 Client *c; |
497 Client *c; |
498 |
498 |
499 dc.x = 0; |
499 dc.x = 0; |
500 for(c = stack; c && !isvisible(c); c = c->snext); |
500 for(c = stack; c && !VISIBLE(c); c = c->snext); |
501 for(i = 0; i < LENGTH(tags); i++) { |
501 for(i = 0; i < LENGTH(tags); i++) { |
502 dc.w = textw(tags[i]); |
502 dc.w = textw(tags[i]); |
503 if(tagset[seltags] & 1 << i) { |
503 if(tagset[seltags] & 1 << i) { |
504 drawtext(tags[i], dc.sel, isurgent(i)); |
504 drawtext(tags[i], dc.sel, isurgent(i)); |
505 drawsquare(c && c->tags & 1 << i, isoccupied(i), isurgent(i), dc.sel); |
505 drawsquare(c && c->tags & 1 << i, isoccupied(i), isurgent(i), dc.sel); |
626 drawbar(); |
626 drawbar(); |
627 } |
627 } |
628 |
628 |
629 void |
629 void |
630 focus(Client *c) { |
630 focus(Client *c) { |
631 if(!c || (c && !isvisible(c))) |
631 if(!c || (c && !VISIBLE(c))) |
632 for(c = stack; c && !isvisible(c); c = c->snext); |
632 for(c = stack; c && !VISIBLE(c); c = c->snext); |
633 if(sel && sel != c) { |
633 if(sel && sel != c) { |
634 grabbuttons(sel, False); |
634 grabbuttons(sel, False); |
635 XSetWindowBorder(dpy, sel->win, dc.norm[ColBorder]); |
635 XSetWindowBorder(dpy, sel->win, dc.norm[ColBorder]); |
636 } |
636 } |
637 if(c) { |
637 if(c) { |
661 focusnext(const void *arg) { |
661 focusnext(const void *arg) { |
662 Client *c; |
662 Client *c; |
663 |
663 |
664 if(!sel) |
664 if(!sel) |
665 return; |
665 return; |
666 for(c = sel->next; c && !isvisible(c); c = c->next); |
666 for(c = sel->next; c && !VISIBLE(c); c = c->next); |
667 if(!c) |
667 if(!c) |
668 for(c = clients; c && !isvisible(c); c = c->next); |
668 for(c = clients; c && !VISIBLE(c); c = c->next); |
669 if(c) { |
669 if(c) { |
670 focus(c); |
670 focus(c); |
671 restack(); |
671 restack(); |
672 } |
672 } |
673 } |
673 } |
676 focusprev(const void *arg) { |
676 focusprev(const void *arg) { |
677 Client *c; |
677 Client *c; |
678 |
678 |
679 if(!sel) |
679 if(!sel) |
680 return; |
680 return; |
681 for(c = sel->prev; c && !isvisible(c); c = c->prev); |
681 for(c = sel->prev; c && !VISIBLE(c); c = c->prev); |
682 if(!c) { |
682 if(!c) { |
683 for(c = clients; c && c->next; c = c->next); |
683 for(c = clients; c && c->next; c = c->next); |
684 for(; c && !isvisible(c); c = c->prev); |
684 for(; c && !VISIBLE(c); c = c->prev); |
685 } |
685 } |
686 if(c) { |
686 if(c) { |
687 focus(c); |
687 focus(c); |
688 restack(); |
688 restack(); |
689 } |
689 } |
869 |
869 |
870 for(c = clients; c; c = c->next) |
870 for(c = clients; c; c = c->next) |
871 if(c->isurgent && c->tags & 1 << t) |
871 if(c->isurgent && c->tags & 1 << t) |
872 return True; |
872 return True; |
873 return False; |
873 return False; |
874 } |
|
875 |
|
876 Bool |
|
877 isvisible(Client *c) { |
|
878 return c->tags & tagset[seltags]; |
|
879 } |
874 } |
880 |
875 |
881 void |
876 void |
882 keypress(XEvent *e) { |
877 keypress(XEvent *e) { |
883 uint i; |
878 uint i; |
1041 } |
1036 } |
1042 } |
1037 } |
1043 |
1038 |
1044 Client * |
1039 Client * |
1045 nexttiled(Client *c) { |
1040 nexttiled(Client *c) { |
1046 for(; c && (c->isfloating || !isvisible(c)); c = c->next); |
1041 for(; c && (c->isfloating || !VISIBLE(c)); c = c->next); |
1047 return c; |
1042 return c; |
1048 } |
1043 } |
1049 |
1044 |
1050 void |
1045 void |
1051 propertynotify(XEvent *e) { |
1046 propertynotify(XEvent *e) { |
1205 XRaiseWindow(dpy, sel->win); |
1200 XRaiseWindow(dpy, sel->win); |
1206 if(lt->arrange) { |
1201 if(lt->arrange) { |
1207 wc.stack_mode = Below; |
1202 wc.stack_mode = Below; |
1208 wc.sibling = barwin; |
1203 wc.sibling = barwin; |
1209 for(c = stack; c; c = c->snext) |
1204 for(c = stack; c; c = c->snext) |
1210 if(!c->isfloating && isvisible(c)) { |
1205 if(!c->isfloating && VISIBLE(c)) { |
1211 XConfigureWindow(dpy, c->win, CWSibling|CWStackMode, &wc); |
1206 XConfigureWindow(dpy, c->win, CWSibling|CWStackMode, &wc); |
1212 wc.sibling = c->win; |
1207 wc.sibling = c->win; |
1213 } |
1208 } |
1214 } |
1209 } |
1215 XSync(dpy, False); |
1210 XSync(dpy, False); |