summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSanttu Lakkala <inz@inz.fi>2022-02-21 16:58:28 +0200
committerHiltjo Posthuma <hiltjo@codemadness.org>2022-04-16 16:59:03 +0200
commitd93ff48803f04f1363bf303af1d7e6ccc5cb8d3f (patch)
treea9bf08152f3175a326e767629497d79f34f33be8
parent8806b6e2379372900e3d9e0bf6604bc7f727350b (diff)
downloaddwm-d93ff48803f04f1363bf303af1d7e6ccc5cb8d3f.tar.gz
dwm-d93ff48803f04f1363bf303af1d7e6ccc5cb8d3f.zip
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.
-rw-r--r--dwm.c68
1 files changed, 34 insertions, 34 deletions
diff --git a/dwm.c b/dwm.c
index d8075ad..0fc328a 100644
--- a/dwm.c
+++ b/dwm.c
@@ -1876,42 +1876,42 @@ updategeom(void)
1876 memcpy(&unique[j++], &info[i], sizeof(XineramaScreenInfo)); 1876 memcpy(&unique[j++], &info[i], sizeof(XineramaScreenInfo));
1877 XFree(info); 1877 XFree(info);
1878 nn = j; 1878 nn = j;
1879 if (n <= nn) { /* new monitors available */ 1879
1880 for (i = 0; i < (nn - n); i++) { 1880 /* new monitors if nn > n */
1881 for (m = mons; m && m->next; m = m->next); 1881 for (i = n; i < nn; i++) {
1882 if (m) 1882 for (m = mons; m && m->next; m = m->next);
1883 m->next = createmon(); 1883 if (m)
1884 else 1884 m->next = createmon();
1885 mons = createmon(); 1885 else
1886 mons = createmon();
1887 }
1888 for (i = 0, m = mons; i < nn && m; m = m->next, i++)
1889 if (i >= n
1890 || unique[i].x_org != m->mx || unique[i].y_org != m->my
1891 || unique[i].width != m->mw || unique[i].height != m->mh)
1892 {
1893 dirty = 1;
1894 m->num = i;
1895 m->mx = m->wx = unique[i].x_org;
1896 m->my = m->wy = unique[i].y_org;
1897 m->mw = m->ww = unique[i].width;
1898 m->mh = m->wh = unique[i].height;
1899 updatebarpos(m);
1886 } 1900 }
1887 for (i = 0, m = mons; i < nn && m; m = m->next, i++) 1901 /* removed monitors if n > nn */
1888 if (i >= n 1902 for (i = nn; i < n; i++) {
1889 || unique[i].x_org != m->mx || unique[i].y_org != m->my 1903 for (m = mons; m && m->next; m = m->next);
1890 || unique[i].width != m->mw || unique[i].height != m->mh) 1904 while ((c = m->clients)) {
1891 { 1905 dirty = 1;
1892 dirty = 1; 1906 m->clients = c->next;
1893 m->num = i; 1907 detachstack(c);
1894 m->mx = m->wx = unique[i].x_org; 1908 c->mon = mons;
1895 m->my = m->wy = unique[i].y_org; 1909 attach(c);
1896 m->mw = m->ww = unique[i].width; 1910 attachstack(c);
1897 m->mh = m->wh = unique[i].height;
1898 updatebarpos(m);
1899 }
1900 } else { /* less monitors available nn < n */
1901 for (i = nn; i < n; i++) {
1902 for (m = mons; m && m->next; m = m->next);
1903 while ((c = m->clients)) {
1904 dirty = 1;
1905 m->clients = c->next;
1906 detachstack(c);
1907 c->mon = mons;
1908 attach(c);
1909 attachstack(c);
1910 }
1911 if (m == selmon)
1912 selmon = mons;
1913 cleanupmon(m);
1914 } 1911 }
1912 if (m == selmon)
1913 selmon = mons;
1914 cleanupmon(m);
1915 } 1915 }
1916 free(unique); 1916 free(unique);
1917 } else 1917 } else