summaryrefslogtreecommitdiffhomepage
path: root/patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch')
-rw-r--r--patch/include.c6
-rw-r--r--patch/include.h6
-rw-r--r--patch/sortscreens.c15
-rw-r--r--patch/sortscreens.h3
4 files changed, 30 insertions, 0 deletions
diff --git a/patch/include.c b/patch/include.c
index 8f4a0d0..1bc7fcb 100644
--- a/patch/include.c
+++ b/patch/include.c
@@ -94,6 +94,12 @@
#include "setborderpx.c"
#endif
+#ifdef XINERAMA
+#if SORTSCREENS_PATCH
+#include "sortscreens.c"
+#endif
+#endif
+
#if STICKY_PATCH
#include "sticky.c"
#endif
diff --git a/patch/include.h b/patch/include.h
index 237b725..35c6423 100644
--- a/patch/include.h
+++ b/patch/include.h
@@ -94,6 +94,12 @@
#include "setborderpx.h"
#endif
+#ifdef XINERAMA
+#if SORTSCREENS_PATCH
+#include "sortscreens.h"
+#endif
+#endif
+
#if STICKY_PATCH
#include "sticky.h"
#endif
diff --git a/patch/sortscreens.c b/patch/sortscreens.c
new file mode 100644
index 0000000..6250848
--- /dev/null
+++ b/patch/sortscreens.c
@@ -0,0 +1,15 @@
+void
+sortscreens(XineramaScreenInfo *screens, int n)
+{
+ int i, j;
+ XineramaScreenInfo *screen = ecalloc(1, sizeof(XineramaScreenInfo));
+
+ for (i = 0; i < n; i++)
+ for (j = i + 1; j < n; j++)
+ if (RIGHTOF(screens[i], screens[j])) {
+ memcpy(&screen[0], &screens[i], sizeof(XineramaScreenInfo));
+ memcpy(&screens[i], &screens[j], sizeof(XineramaScreenInfo));
+ memcpy(&screens[j], &screen[0], sizeof(XineramaScreenInfo));
+ }
+ XFree(screen);
+} \ No newline at end of file
diff --git a/patch/sortscreens.h b/patch/sortscreens.h
new file mode 100644
index 0000000..d829cdf
--- /dev/null
+++ b/patch/sortscreens.h
@@ -0,0 +1,3 @@
+#define RIGHTOF(a,b) (a.y_org > b.y_org) || ((a.y_org == b.y_org) && (a.x_org > b.x_org))
+
+static void sortscreens(XineramaScreenInfo *screens, int n); \ No newline at end of file