several fixes through ISVISIBLE change (takes Monitor into account) 3da24539
Anselm R Garbe · 2009-06-20 15:51 1 file(s) · +20 −18
dwm.c +20 −18
44 44
#define BUTTONMASK              (ButtonPressMask|ButtonReleaseMask)
45 45
#define CLEANMASK(mask)         (mask & ~(numlockmask|LockMask))
46 46
#define INRECT(X,Y,RX,RY,RW,RH) ((X) >= (RX) && (X) < (RX) + (RW) && (Y) >= (RY) && (Y) < (RY) + (RH))
47 -
#define ISVISIBLE(x)            (x->tags & tagset[mon[x->mon].seltags])
48 -
#define LENGTH(x)               (sizeof x / sizeof x[0])
47 +
#define ISVISIBLE(M, C)         ((M) == (&mon[C->mon]) && (C->tags & tagset[M->seltags]))
48 +
#define LENGTH(X)               (sizeof X / sizeof X[0])
49 49
#define MAX(a, b)               ((a) > (b) ? (a) : (b))
50 50
#define MIN(a, b)               ((a) < (b) ? (a) : (b))
51 51
#define MOUSEMASK               (BUTTONMASK|PointerMotionMask)
493 493
		updategeom();
494 494
		if(dc.drawable != 0)
495 495
			XFreePixmap(dpy, dc.drawable);
496 -
		dc.drawable = XCreatePixmap(dpy, root, DisplayWidth(dpy, screen), bh, DefaultDepth(dpy, screen));
496 +
		dc.drawable = XCreatePixmap(dpy, root, sw, bh, DefaultDepth(dpy, screen));
497 497
		for(i = 0; i < nmons; i++)
498 498
			XMoveResizeWindow(dpy, mon[i].barwin, mon[i].wx, mon[i].by, mon[i].ww, bh);
499 499
		arrange();
524 524
				c->y = sy + (sh / 2 - c->h / 2); /* center in y direction */
525 525
			if((ev->value_mask & (CWX|CWY)) && !(ev->value_mask & (CWWidth|CWHeight)))
526 526
				configure(c);
527 -
			if(ISVISIBLE(c))
527 +
			if(ISVISIBLE((&mon[c->mon]), c))
528 528
				XMoveResizeWindow(dpy, c->win, c->x, c->y, c->w, c->h);
529 529
		}
530 530
		else
636 636
		}
637 637
	}
638 638
	else {
639 +
		dc.x = x;
639 640
		dc.w = m->ww - x;
640 641
		drawtext(NULL, dc.norm, False);
641 642
	}
718 719
	unsigned int i;
719 720
	XExposeEvent *ev = &e->xexpose;
720 721
721 -
	for(i = 0; i < nmons; i++)
722 -
		if(ev->count == 0 && (ev->window == mon[i].barwin)) {
723 -
			drawbar(&mon[i]);
724 -
			break;
725 -
		}
722 +
	if(ev->count == 0)
723 +
		for(i = 0; i < nmons; i++)
724 +
			if(ev->window == mon[i].barwin) {
725 +
				drawbar(&mon[i]);
726 +
				break;
727 +
			}
726 728
}
727 729
728 730
void
729 731
focus(Client *c) {
730 -
	if(!c || !ISVISIBLE(c))
731 -
		for(c = stack; c && !ISVISIBLE(c); c = c->snext);
732 +
	if(!c || !ISVISIBLE((&mon[c->mon]), c))
733 +
		for(c = stack; c && !ISVISIBLE(selmon, c); c = c->snext);
732 734
	if(sel && sel != c) {
733 735
		grabbuttons(sel, False);
734 736
		XSetWindowBorder(dpy, sel->win, dc.norm[ColBorder]);
776 778
	if(!sel)
777 779
		return;
778 780
	if(arg->i > 0) {
779 -
		for(c = sel->next; c && !ISVISIBLE(c); c = c->next);
781 +
		for(c = sel->next; c && !ISVISIBLE(selmon, c); c = c->next);
780 782
		if(!c)
781 -
			for(c = clients; c && !ISVISIBLE(c); c = c->next);
783 +
			for(c = clients; c && !ISVISIBLE(selmon, c); c = c->next);
782 784
	}
783 785
	else {
784 786
		for(i = clients; i != sel; i = i->next)
785 -
			if(ISVISIBLE(i))
787 +
			if(ISVISIBLE(selmon, i))
786 788
				c = i;
787 789
		if(!c)
788 790
			for(; i; i = i->next)
789 -
				if(ISVISIBLE(i))
791 +
				if(ISVISIBLE(selmon, i))
790 792
					c = i;
791 793
	}
792 794
	if(c) {
1126 1128
Client *
1127 1129
nexttiled(Monitor *m, Client *c) {
1128 1130
	// TODO: m handling
1129 -
	for(; c && (c->isfloating || m != &mon[c->mon] || !ISVISIBLE(c)); c = c->next);
1131 +
	for(; c && (c->isfloating || !ISVISIBLE(m, c)); c = c->next);
1130 1132
	return c;
1131 1133
}
1132 1134
1246 1248
		wc.stack_mode = Below;
1247 1249
		wc.sibling = m->barwin;
1248 1250
		for(c = stack; c; c = c->snext)
1249 -
			if(!c->isfloating && m == &mon[c->mon] && ISVISIBLE(c)) {
1251 +
			if(!c->isfloating && ISVISIBLE(m, c)) {
1250 1252
				XConfigureWindow(dpy, c->win, CWSibling|CWStackMode, &wc);
1251 1253
				wc.sibling = c->win;
1252 1254
			}
1408 1410
showhide(Client *c) {
1409 1411
	if(!c)
1410 1412
		return;
1411 -
	if(ISVISIBLE(c)) { /* show clients top down */
1413 +
	if(ISVISIBLE((&mon[c->mon]), c)) { /* show clients top down */
1412 1414
		XMoveWindow(dpy, c->win, c->x, c->y);
1413 1415
		if(!lt[selmon->sellt]->arrange || c->isfloating)
1414 1416
			resize(c, c->x, c->y, c->w, c->h);