Update monitor positions also on removal

When monitors are removed, the coordinates of existing monitors may
change, if the removed monitors had smaller coordinates than the
remaining ones.

Remove special case handling so that the same update-if-necessary loop
is run also in the case when monitors are removed.
This commit is contained in:
Santtu Lakkala 2022-02-21 16:58:28 +02:00 committed by Hiltjo Posthuma
parent 8806b6e237
commit d93ff48803

8
dwm.c
View file

@ -1876,8 +1876,9 @@ updategeom(void)
memcpy(&unique[j++], &info[i], sizeof(XineramaScreenInfo));
XFree(info);
nn = j;
if (n <= nn) { /* new monitors available */
for (i = 0; i < (nn - n); i++) {
/* new monitors if nn > n */
for (i = n; i < nn; i++) {
for (m = mons; m && m->next; m = m->next);
if (m)
m->next = createmon();
@ -1897,7 +1898,7 @@ updategeom(void)
m->mh = m->wh = unique[i].height;
updatebarpos(m);
}
} else { /* less monitors available nn < n */
/* removed monitors if n > nn */
for (i = nn; i < n; i++) {
for (m = mons; m && m->next; m = m->next);
while ((c = m->clients)) {
@ -1912,7 +1913,6 @@ updategeom(void)
selmon = mons;
cleanupmon(m);
}
}
free(unique);
} else
#endif /* XINERAMA */