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:
parent
8806b6e237
commit
d93ff48803
68
dwm.c
68
dwm.c
|
@ -1876,42 +1876,42 @@ 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 (m = mons; m && m->next; m = m->next);
|
for (i = n; i < nn; i++) {
|
||||||
if (m)
|
for (m = mons; m && m->next; m = m->next);
|
||||||
m->next = createmon();
|
if (m)
|
||||||
else
|
m->next = createmon();
|
||||||
mons = createmon();
|
else
|
||||||
|
mons = createmon();
|
||||||
|
}
|
||||||
|
for (i = 0, m = mons; i < nn && m; m = m->next, i++)
|
||||||
|
if (i >= n
|
||||||
|
|| unique[i].x_org != m->mx || unique[i].y_org != m->my
|
||||||
|
|| unique[i].width != m->mw || unique[i].height != m->mh)
|
||||||
|
{
|
||||||
|
dirty = 1;
|
||||||
|
m->num = i;
|
||||||
|
m->mx = m->wx = unique[i].x_org;
|
||||||
|
m->my = m->wy = unique[i].y_org;
|
||||||
|
m->mw = m->ww = unique[i].width;
|
||||||
|
m->mh = m->wh = unique[i].height;
|
||||||
|
updatebarpos(m);
|
||||||
}
|
}
|
||||||
for (i = 0, m = mons; i < nn && m; m = m->next, i++)
|
/* removed monitors if n > nn */
|
||||||
if (i >= n
|
for (i = nn; i < n; i++) {
|
||||||
|| unique[i].x_org != m->mx || unique[i].y_org != m->my
|
for (m = mons; m && m->next; m = m->next);
|
||||||
|| unique[i].width != m->mw || unique[i].height != m->mh)
|
while ((c = m->clients)) {
|
||||||
{
|
dirty = 1;
|
||||||
dirty = 1;
|
m->clients = c->next;
|
||||||
m->num = i;
|
detachstack(c);
|
||||||
m->mx = m->wx = unique[i].x_org;
|
c->mon = mons;
|
||||||
m->my = m->wy = unique[i].y_org;
|
attach(c);
|
||||||
m->mw = m->ww = unique[i].width;
|
attachstack(c);
|
||||||
m->mh = m->wh = unique[i].height;
|
|
||||||
updatebarpos(m);
|
|
||||||
}
|
|
||||||
} else { /* less monitors available nn < n */
|
|
||||||
for (i = nn; i < n; i++) {
|
|
||||||
for (m = mons; m && m->next; m = m->next);
|
|
||||||
while ((c = m->clients)) {
|
|
||||||
dirty = 1;
|
|
||||||
m->clients = c->next;
|
|
||||||
detachstack(c);
|
|
||||||
c->mon = mons;
|
|
||||||
attach(c);
|
|
||||||
attachstack(c);
|
|
||||||
}
|
|
||||||
if (m == selmon)
|
|
||||||
selmon = mons;
|
|
||||||
cleanupmon(m);
|
|
||||||
}
|
}
|
||||||
|
if (m == selmon)
|
||||||
|
selmon = mons;
|
||||||
|
cleanupmon(m);
|
||||||
}
|
}
|
||||||
free(unique);
|
free(unique);
|
||||||
} else
|
} else
|
||||||
|
|
Loading…
Reference in a new issue