summaryrefslogtreecommitdiffstats
path: root/dwm.c
diff options
context:
space:
mode:
Diffstat (limited to 'dwm.c')
-rw-r--r--dwm.c54
1 files changed, 33 insertions, 21 deletions
diff --git a/dwm.c b/dwm.c
index f992ea9..9f1b1f4 100644
--- a/dwm.c
+++ b/dwm.c
@@ -164,9 +164,9 @@ void grabbuttons(Client *c, Bool focused);
164void grabkeys(void); 164void grabkeys(void);
165unsigned int idxoftag(const char *tag); 165unsigned int idxoftag(const char *tag);
166void initfont(Monitor*, const char *fontstr); 166void initfont(Monitor*, const char *fontstr);
167Bool isoccupied(Monitor *m, unsigned int t); 167Bool isoccupied(unsigned int monitor, unsigned int t);
168Bool isprotodel(Client *c); 168Bool isprotodel(Client *c);
169Bool isurgent(int monitor, unsigned int t); 169Bool isurgent(unsigned int monitor, unsigned int t);
170Bool isvisible(Client *c, int monitor); 170Bool isvisible(Client *c, int monitor);
171void keypress(XEvent *e); 171void keypress(XEvent *e);
172void killclient(const char *arg); 172void killclient(const char *arg);
@@ -562,39 +562,46 @@ detachstack(Client *c) {
562void 562void
563drawbar(void) { 563drawbar(void) {
564 int i, j, x; 564 int i, j, x;
565 Client *c;
565 566
566 for(i = 0; i < mcount; i++) { 567 for(i = 0; i < mcount; i++) {
567 Monitor *m = &monitors[i]; 568 Monitor *m = &monitors[i];
568 m->dc.x = 0; 569 m->dc.x = 0;
570 for(c = stack; c && !isvisible(c, i); c = c->snext);
571 fprintf(stderr, "m%d %s\n", i, c ? c->name : "NIL");
569 for(j = 0; j < LENGTH(tags); j++) { 572 for(j = 0; j < LENGTH(tags); j++) {
570 m->dc.w = textw(m, tags[j]); 573 m->dc.w = textw(m, tags[j]);
571 if(m->seltags[j]) { 574 if(m->seltags[j]) {
572 drawtext(m, tags[j], m->dc.sel, isurgent(i, j)); 575 drawtext(m, tags[j], m->dc.sel, isurgent(i, j));
573 drawsquare(m, sel && sel->tags[j] && sel->monitor == selmonitor, 576 drawsquare(m, c && c->tags[j] && c->monitor == i,
574 isoccupied(m, j), isurgent(i, j), m->dc.sel); 577 isoccupied(i, j), isurgent(i, j), m->dc.sel);
575 } 578 }
576 else { 579 else {
577 drawtext(m, tags[j], m->dc.norm, isurgent(i, j)); 580 drawtext(m, tags[j], m->dc.norm, isurgent(i, j));
578 drawsquare(m, sel && sel->tags[j] && sel->monitor == selmonitor, 581 drawsquare(m, c && c->tags[j] && c->monitor == i,
579 isoccupied(m, j), isurgent(i, j), m->dc.norm); 582 isoccupied(i, j), isurgent(i, j), m->dc.norm);
580 } 583 }
581 m->dc.x += m->dc.w; 584 m->dc.x += m->dc.w;
582 } 585 }
583 m->dc.w = blw; 586 m->dc.w = blw;
584 drawtext(m, m->layout->symbol, m->dc.norm, False); 587 drawtext(m, m->layout->symbol, m->dc.norm, False);
585 x = m->dc.x + m->dc.w; 588 x = m->dc.x + m->dc.w;
586 m->dc.w = textw(m, stext); 589 if(i == selmonitor) {
587 m->dc.x = m->sw - m->dc.w; 590 m->dc.w = textw(m, stext);
588 if(m->dc.x < x) { 591 m->dc.x = m->sw - m->dc.w;
589 m->dc.x = x; 592 if(m->dc.x < x) {
590 m->dc.w = m->sw - x; 593 m->dc.x = x;
594 m->dc.w = m->sw - x;
595 }
596 drawtext(m, stext, m->dc.norm, False);
591 } 597 }
592 drawtext(m, stext, m->dc.norm, False); 598 else
599 m->dc.x = m->sw;
593 if((m->dc.w = m->dc.x - x) > bh) { 600 if((m->dc.w = m->dc.x - x) > bh) {
594 m->dc.x = x; 601 m->dc.x = x;
595 if(sel && sel->monitor == selmonitor) { 602 if(c) {
596 drawtext(m, sel->name, m->dc.sel, False); 603 drawtext(m, c->name, m->dc.sel, False);
597 drawsquare(m, False, sel->isfloating, False, m->dc.sel); 604 drawsquare(m, False, c->isfloating, False, m->dc.sel);
598 } 605 }
599 else 606 else
600 drawtext(m, NULL, m->dc.norm, False); 607 drawtext(m, NULL, m->dc.norm, False);
@@ -679,8 +686,10 @@ enternotify(XEvent *e) {
679 Client *c; 686 Client *c;
680 XCrossingEvent *ev = &e->xcrossing; 687 XCrossingEvent *ev = &e->xcrossing;
681 688
682 if(ev->mode != NotifyNormal || ev->detail == NotifyInferior); 689 if(ev->mode != NotifyNormal || ev->detail == NotifyInferior) {
683 //return; 690 if(!isxinerama || ev->window != monitors[selmonitor].root)
691 return;
692 }
684 if((c = getclient(ev->window))) 693 if((c = getclient(ev->window)))
685 focus(c); 694 focus(c);
686 else { 695 else {
@@ -747,6 +756,7 @@ focus(Client *c) {
747 } 756 }
748 else { 757 else {
749 XSetInputFocus(dpy, m->root, RevertToPointerRoot, CurrentTime); 758 XSetInputFocus(dpy, m->root, RevertToPointerRoot, CurrentTime);
759 drawbar();
750 } 760 }
751} 761}
752 762
@@ -972,11 +982,11 @@ initfont(Monitor *m, const char *fontstr) {
972} 982}
973 983
974Bool 984Bool
975isoccupied(Monitor *m, unsigned int t) { 985isoccupied(unsigned int monitor, unsigned int t) {
976 Client *c; 986 Client *c;
977 987
978 for(c = clients; c; c = c->next) 988 for(c = clients; c; c = c->next)
979 if(c->tags[t] && c->monitor == selmonitor) 989 if(c->tags[t] && c->monitor == monitor)
980 return True; 990 return True;
981 return False; 991 return False;
982} 992}
@@ -997,7 +1007,7 @@ isprotodel(Client *c) {
997} 1007}
998 1008
999Bool 1009Bool
1000isurgent(int monitor, unsigned int t) { 1010isurgent(unsigned int monitor, unsigned int t) {
1001 Client *c; 1011 Client *c;
1002 1012
1003 for(c = clients; c; c = c->next) 1013 for(c = clients; c; c = c->next)
@@ -1010,8 +1020,10 @@ Bool
1010isvisible(Client *c, int monitor) { 1020isvisible(Client *c, int monitor) {
1011 unsigned int i; 1021 unsigned int i;
1012 1022
1023 if(c->monitor != monitor)
1024 return False;
1013 for(i = 0; i < LENGTH(tags); i++) 1025 for(i = 0; i < LENGTH(tags); i++)
1014 if(c->tags[i] && monitors[c->monitor].seltags[i] && c->monitor == monitor) 1026 if(c->tags[i] && monitors[c->monitor].seltags[i])
1015 return True; 1027 return True;
1016 return False; 1028 return False;
1017} 1029}