some drawbar() polishing, and certain related fixes 6ab163c6
Anselm R Garbe · 2008-02-15 16:00 1 file(s) · +33 −21
dwm.c +33 −21
164 164
void grabkeys(void);
165 165
unsigned int idxoftag(const char *tag);
166 166
void initfont(Monitor*, const char *fontstr);
167 -
Bool isoccupied(Monitor *m, unsigned int t);
167 +
Bool isoccupied(unsigned int monitor, unsigned int t);
168 168
Bool isprotodel(Client *c);
169 -
Bool isurgent(int monitor, unsigned int t);
169 +
Bool isurgent(unsigned int monitor, unsigned int t);
170 170
Bool isvisible(Client *c, int monitor);
171 171
void keypress(XEvent *e);
172 172
void killclient(const char *arg);
562 562
void
563 563
drawbar(void) {
564 564
	int i, j, x;
565 +
	Client *c;
565 566
566 567
	for(i = 0; i < mcount; i++) {
567 568
		Monitor *m = &monitors[i];
568 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 572
		for(j = 0; j < LENGTH(tags); j++) {
570 573
			m->dc.w = textw(m, tags[j]);
571 574
			if(m->seltags[j]) {
572 575
				drawtext(m, tags[j], m->dc.sel, isurgent(i, j));
573 -
				drawsquare(m, sel && sel->tags[j] && sel->monitor == selmonitor,
574 -
						isoccupied(m, j), isurgent(i, j), m->dc.sel);
576 +
				drawsquare(m, c && c->tags[j] && c->monitor == i,
577 +
						isoccupied(i, j), isurgent(i, j), m->dc.sel);
575 578
			}
576 579
			else {
577 580
				drawtext(m, tags[j], m->dc.norm, isurgent(i, j));
578 -
				drawsquare(m, sel && sel->tags[j] && sel->monitor == selmonitor,
579 -
						isoccupied(m, j), isurgent(i, j), m->dc.norm);
581 +
				drawsquare(m, c && c->tags[j] && c->monitor == i,
582 +
						isoccupied(i, j), isurgent(i, j), m->dc.norm);
580 583
			}
581 584
			m->dc.x += m->dc.w;
582 585
		}
583 586
		m->dc.w = blw;
584 587
		drawtext(m, m->layout->symbol, m->dc.norm, False);
585 588
		x = m->dc.x + m->dc.w;
586 -
		m->dc.w = textw(m, stext);
587 -
		m->dc.x = m->sw - m->dc.w;
588 -
		if(m->dc.x < x) {
589 -
			m->dc.x = x;
590 -
			m->dc.w = m->sw - x;
589 +
		if(i == selmonitor) {
590 +
			m->dc.w = textw(m, stext);
591 +
			m->dc.x = m->sw - m->dc.w;
592 +
			if(m->dc.x < 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 600
		if((m->dc.w = m->dc.x - x) > bh) {
594 601
			m->dc.x = x;
595 -
			if(sel && sel->monitor == selmonitor) {
596 -
				drawtext(m, sel->name, m->dc.sel, False);
597 -
				drawsquare(m, False, sel->isfloating, False, m->dc.sel);
602 +
			if(c) {
603 +
				drawtext(m, c->name, m->dc.sel, False);
604 +
				drawsquare(m, False, c->isfloating, False, m->dc.sel);
598 605
			}
599 606
			else
600 607
				drawtext(m, NULL, m->dc.norm, False);
679 686
	Client *c;
680 687
	XCrossingEvent *ev = &e->xcrossing;
681 688
682 -
	if(ev->mode != NotifyNormal || ev->detail == NotifyInferior);
683 -
		//return;
689 +
	if(ev->mode != NotifyNormal || ev->detail == NotifyInferior) {
690 +
		if(!isxinerama || ev->window != monitors[selmonitor].root)
691 +
			return;
692 +
	}
684 693
	if((c = getclient(ev->window)))
685 694
		focus(c);
686 695
	else {
747 756
	}
748 757
	else {
749 758
		XSetInputFocus(dpy, m->root, RevertToPointerRoot, CurrentTime);
759 +
		drawbar();
750 760
	}
751 761
}
752 762
972 982
}
973 983
974 984
Bool
975 -
isoccupied(Monitor *m, unsigned int t) {
985 +
isoccupied(unsigned int monitor, unsigned int t) {
976 986
	Client *c;
977 987
978 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 990
			return True;
981 991
	return False;
982 992
}
997 1007
}
998 1008
999 1009
Bool
1000 -
isurgent(int monitor, unsigned int t) {
1010 +
isurgent(unsigned int monitor, unsigned int t) {
1001 1011
	Client *c;
1002 1012
1003 1013
	for(c = clients; c; c = c->next)
1010 1020
isvisible(Client *c, int monitor) {
1011 1021
	unsigned int i;
1012 1022
1023 +
	if(c->monitor != monitor)
1024 +
		return False;
1013 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 1027
			return True;
1016 1028
	return False;
1017 1029
}