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
1 changed files with 34 additions and 34 deletions

8
dwm.c
View File

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