applied Johannes Hofmann's patch, please test 63d71902
anselm@anselm1 · 2008-08-04 17:39 1 file(s) · +18 −40
dwm.c +18 −40
159 159
static void grabbuttons(Client *c, Bool focused);
160 160
static void grabkeys(void);
161 161
static void initfont(const char *fontstr);
162 -
static Bool isoccupied(unsigned int t);
163 162
static Bool isprotodel(Client *c);
164 -
static Bool isurgent(unsigned int t);
165 163
static void keypress(XEvent *e);
166 164
static void killclient(const Arg *arg);
167 165
static void manage(Window w, XWindowAttributes *wa);
500 498
501 499
void
502 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 512
	dc.x = 0;
506 513
	for(i = 0; i < LENGTH(tags); i++) {
507 514
		dc.w = TEXTW(tags[i]);
508 -
		if(tagset[seltags] & 1 << i) {
509 -
			drawtext(tags[i], dc.sel, isurgent(i));
510 -
			drawsquare(sel && sel->tags & 1 << i, isoccupied(i), isurgent(i), dc.sel);
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 -
		}
515 +
		col = tagset[seltags] & 1 << i ? dc.sel : dc.norm;
516 +
		drawtext(tags[i], col, urg & 1 << i);
517 +
		drawsquare(sel && sel->tags & 1 << i, occ & 1 << i, urg & 1 << i, col);
516 518
		dc.x += dc.w;
517 519
	}
518 520
	if(blw > 0) {
741 743
			if(buttons[i].click == ClkClientWin)
742 744
				for(j = 0; j < LENGTH(modifiers); j++)
743 745
					XGrabButton(dpy, buttons[i].button, buttons[i].mask | modifiers[j], c->win, False, BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
744 -
        } else
746 +
	} else
745 747
		XGrabButton(dpy, AnyButton, AnyModifier, c->win, False,
746 748
		            BUTTONMASK, GrabModeAsync, GrabModeSync, None, None);
747 749
}
749 751
void
750 752
grabkeys(void) {
751 753
	unsigned int i, j;
754 +
	unsigned int modifiers[] = { 0, LockMask, numlockmask, numlockmask|LockMask };
752 755
	KeyCode code;
753 756
	XModifierKeymap *modmap;
754 757
764 767
	XUngrabKey(dpy, AnyKey, AnyModifier, root);
765 768
	for(i = 0; i < LENGTH(keys); i++) {
766 769
		code = XKeysymToKeycode(dpy, keys[i].keysym);
767 -
		XGrabKey(dpy, code, keys[i].mod, root, True,
768 -
				GrabModeAsync, GrabModeAsync);
769 -
		XGrabKey(dpy, code, keys[i].mod|LockMask, root, True,
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);
770 +
		for(j = 0; j < LENGTH(modifiers); j++)
771 +
			XGrabKey(dpy, code, keys[i].mod | modifiers[j], root, True,
772 +
			         GrabModeAsync, GrabModeAsync);
775 773
	}
776 774
}
777 775
816 814
}
817 815
818 816
Bool
819 -
isoccupied(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 -
828 -
Bool
829 817
isprotodel(Client *c) {
830 818
	int i, n;
831 819
	Atom *protocols;
838 826
		XFree(protocols);
839 827
	}
840 828
	return ret;
841 -
}
842 -
843 -
Bool
844 -
isurgent(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 829
}
852 830
853 831
void