summaryrefslogtreecommitdiffstats
path: root/dwm.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--dwm.c44
1 files changed, 30 insertions, 14 deletions
diff --git a/dwm.c b/dwm.c
index 48f50da..5199e71 100644
--- a/dwm.c
+++ b/dwm.c
@@ -158,7 +158,7 @@ static void attachstack(Client *c);
158static void buttonpress(XEvent *e); 158static void buttonpress(XEvent *e);
159static void checkotherwm(void); 159static void checkotherwm(void);
160static void cleanup(void); 160static void cleanup(void);
161static void cleanupmons(void); 161static void cleanupmon(Monitor *mon);
162static void clearurgent(Client *c); 162static void clearurgent(Client *c);
163static void configure(Client *c); 163static void configure(Client *c);
164static void configurenotify(XEvent *e); 164static void configurenotify(XEvent *e);
@@ -480,22 +480,25 @@ cleanup(void) {
480 XFreeCursor(dpy, cursor[CurNormal]); 480 XFreeCursor(dpy, cursor[CurNormal]);
481 XFreeCursor(dpy, cursor[CurResize]); 481 XFreeCursor(dpy, cursor[CurResize]);
482 XFreeCursor(dpy, cursor[CurMove]); 482 XFreeCursor(dpy, cursor[CurMove]);
483 cleanupmons(); 483 while(mons)
484 cleanupmon(mons);
484 XSync(dpy, False); 485 XSync(dpy, False);
485 XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime); 486 XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot, CurrentTime);
486} 487}
487 488
488void 489void
489cleanupmons(void) { 490cleanupmon(Monitor *mon) {
490 Monitor *m; 491 Monitor *m;
491 492
492 while(mons) { 493 if(mon == mons)
493 m = mons->next; 494 mons = mons->next;
494 XUnmapWindow(dpy, mons->barwin); 495 else {
495 XDestroyWindow(dpy, mons->barwin); 496 for(m = mons; m && m->next != mon; m = m->next);
496 free(mons); 497 m->next = mon->next;
497 mons = m;
498 } 498 }
499 XUnmapWindow(dpy, mon->barwin);
500 XDestroyWindow(dpy, mon->barwin);
501 free(mon);
499} 502}
500 503
501void 504void
@@ -1727,6 +1730,7 @@ updategeom(void) {
1727#ifdef XINERAMA 1730#ifdef XINERAMA
1728 if(XineramaIsActive(dpy)) { 1731 if(XineramaIsActive(dpy)) {
1729 int i, j, n, nn; 1732 int i, j, n, nn;
1733 Client *c;
1730 Monitor *m; 1734 Monitor *m;
1731 XineramaScreenInfo *info = XineramaQueryScreens(dpy, &nn); 1735 XineramaScreenInfo *info = XineramaQueryScreens(dpy, &nn);
1732 XineramaScreenInfo *unique = NULL; 1736 XineramaScreenInfo *unique = NULL;
@@ -1755,7 +1759,7 @@ updategeom(void) {
1755 || unique[i].width != m->mw || unique[i].height != m->mh)) 1759 || unique[i].width != m->mw || unique[i].height != m->mh))
1756 { 1760 {
1757 dirty = True; 1761 dirty = True;
1758 m->num = unique[i].screen_number; 1762 m->num = i;
1759 m->mx = m->wx = unique[i].x_org; 1763 m->mx = m->wx = unique[i].x_org;
1760 m->my = m->wy = unique[i].y_org; 1764 m->my = m->wy = unique[i].y_org;
1761 m->mw = m->ww = unique[i].width; 1765 m->mw = m->ww = unique[i].width;
@@ -1763,10 +1767,22 @@ updategeom(void) {
1763 updatebarpos(m); 1767 updatebarpos(m);
1764 } 1768 }
1765 } 1769 }
1766 else { /* less monitors available */ 1770 else { /* less monitors available nn < n */
1767 cleanup(); 1771 for(i = nn; i < n; i++) {
1768 setup(); 1772 for(m = mons; m && m->next; m = m->next);
1769 scan(); 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 free(unique); 1787 free(unique);
1772 } 1788 }