implemented nn < n case, k-zed please recheck 30fed9a2
Anselm R Garbe · 2009-09-22 20:33 1 file(s) · +30 −14
dwm.c +30 −14
158 158
static void buttonpress(XEvent *e);
159 159
static void checkotherwm(void);
160 160
static void cleanup(void);
161 -
static void cleanupmons(void);
161 +
static void cleanupmon(Monitor *mon);
162 162
static void clearurgent(Client *c);
163 163
static void configure(Client *c);
164 164
static void configurenotify(XEvent *e);
480 480
	XFreeCursor(dpy, cursor[CurNormal]);
481 481
	XFreeCursor(dpy, cursor[CurResize]);
482 482
	XFreeCursor(dpy, cursor[CurMove]);
483 -
	cleanupmons();
483 +
	while(mons)
484 +
		cleanupmon(mons);
484 485
	XSync(dpy, False);
485 486
	XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
486 487
}
487 488
488 489
void
489 -
cleanupmons(void) {
490 +
cleanupmon(Monitor *mon) {
490 491
	Monitor *m;
491 492
492 -
	while(mons) {
493 -
		m = mons->next;
494 -
		XUnmapWindow(dpy, mons->barwin);
495 -
		XDestroyWindow(dpy, mons->barwin);
496 -
		free(mons);
497 -
		mons = m;
493 +
	if(mon == mons)
494 +
		mons = mons->next;
495 +
	else {
496 +
		for(m = mons; m && m->next != mon; m = m->next);
497 +
		m->next = mon->next;
498 498
	}
499 +
	XUnmapWindow(dpy, mon->barwin);
500 +
	XDestroyWindow(dpy, mon->barwin);
501 +
	free(mon);
499 502
}
500 503
501 504
void
1727 1730
#ifdef XINERAMA
1728 1731
	if(XineramaIsActive(dpy)) {
1729 1732
		int i, j, n, nn;
1733 +
		Client *c;
1730 1734
		Monitor *m;
1731 1735
		XineramaScreenInfo *info = XineramaQueryScreens(dpy, &nn);
1732 1736
		XineramaScreenInfo *unique = NULL;
1755 1759
				    || unique[i].width != m->mw || unique[i].height != m->mh))
1756 1760
				{
1757 1761
					dirty = True;
1758 -
					m->num = unique[i].screen_number;
1762 +
					m->num = i;
1759 1763
					m->mx = m->wx = unique[i].x_org;
1760 1764
					m->my = m->wy = unique[i].y_org;
1761 1765
					m->mw = m->ww = unique[i].width;
1763 1767
					updatebarpos(m);
1764 1768
				}
1765 1769
		}
1766 -
		else { /* less monitors available */
1767 -
			cleanup();
1768 -
			setup();
1769 -
			scan();
1770 +
		else { /* less monitors available nn < n */
1771 +
			for(i = nn; i < n; i++) {
1772 +
				for(m = mons; m && m->next; m = m->next);
1773 +
				while(m->clients) {
1774 +
					dirty = True;
1775 +
					c = m->clients;
1776 +
					m->clients = c->next;
1777 +
					detachstack(c);
1778 +
					c->mon = mons;
1779 +
					attach(c);
1780 +
					attachstack(c);
1781 +
				}
1782 +
				if(m == selmon)
1783 +
					selmon = mons;
1784 +
				cleanupmon(m);
1785 +
			}
1770 1786
		}
1771 1787
		free(unique);
1772 1788
	}