commit 65b481781d641452baacb701d38e822b99d84424
parent 67f07658f59673f9c2bf78fadc2547f56ab61630
Author: Lyciih <gnehciyil@gmail.com>
Date: Tue, 15 Jul 2025 00:04:12 +0800
Add xinerama-monitors-xorder patch
Sort Xinerama monitors by x_org to match physical screen layout.
Diffstat:
2 files changed, 49 insertions(+), 0 deletions(-)
diff --git a/dwm.suckless.org/patches/xinerama-monitors-xorder/dwm-xinerama-monitors-xorder-6.4.diff b/dwm.suckless.org/patches/xinerama-monitors-xorder/dwm-xinerama-monitors-xorder-6.4.diff
@@ -0,0 +1,28 @@
+--- a/dwm.c 2025-07-14 22:37:49.738597862 +0800
++++ b/dwm.c 2025-07-14 22:37:08.706035689 +0800
+@@ -1864,6 +1864,16 @@ updateclientlist()
+ (unsigned char *) &(c->win), 1);
+ }
+
++#ifdef XINERAMA
++// Custom comparator: sort monitors by x_org to match physical layout left-to-right
++static int
++compare_xinerama_x(const void *a, const void *b) {
++ const XineramaScreenInfo *sa = (const XineramaScreenInfo *)a;
++ const XineramaScreenInfo *sb = (const XineramaScreenInfo *)b;
++ return sa->x_org - sb->x_org;
++}
++#endif /* XINERAMA */
++
+ int
+ updategeom(void)
+ {
+@@ -1880,6 +1890,8 @@ updategeom(void)
+ for (n = 0, m = mons; m; m = m->next, n++);
+ /* only consider unique geometries as separate screens */
+ unique = ecalloc(nn, sizeof(XineramaScreenInfo));
++ // Sort monitors by x_org so dwm handles screens in left-to-right order
++ qsort(info, nn, sizeof(XineramaScreenInfo), compare_xinerama_x);
+ for (i = 0, j = 0; i < nn; i++)
+ if (isuniquegeom(unique, j, &info[i]))
+ memcpy(&unique[j++], &info[i], sizeof(XineramaScreenInfo));
diff --git a/dwm.suckless.org/patches/xinerama-monitors-xorder/index.md b/dwm.suckless.org/patches/xinerama-monitors-xorder/index.md
@@ -0,0 +1,21 @@
+xinerama monitors xorder
+========================
+
+Description
+-----------
+Sorts Xinerama monitors by their `x_org` value (horizontal position),
+ensuring directional monitor movement (e.g. `Mod+Shift+Left/Right`) reflects
+physical screen layout from left to right.
+
+This is helpful in multi-monitor setups where the logical screen order from
+Xinerama doesn't match the physical layout.
+
+Download
+--------
+- [dwm-xinerama-monitors-xorder-6.4.diff](dwm-xinerama-monitors-xorder-6.4.diff)
+
+Author
+------
+* Lyciih <gnehciyil@gmail.com>
+
+