]> git.lizzy.rs Git - bspwm.git/commitdiff
Add xinerama support back in.
authorJohn Vogel <jvogel4@stny.rr.com>
Mon, 16 Dec 2013 01:24:21 +0000 (20:24 -0500)
committerJohn Vogel <jvogel4@stny.rr.com>
Mon, 16 Dec 2013 01:24:21 +0000 (20:24 -0500)
Makefile
bspwm.c

index 3aa582e40273b9efe5648a158a4cde3d23cb0db2..e263b0d223e09c04886da1a152f9fcb8ec229146 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 VERSION = 0.8.7
 
 CC      ?= gcc
-LIBS     = -lm -lxcb -lxcb-icccm -lxcb-ewmh -lxcb-randr
+LIBS     = -lm -lxcb -lxcb-icccm -lxcb-ewmh -lxcb-randr -lxcb-xinerama
 CFLAGS  += -std=c99 -pedantic -Wall -Wextra -I$(PREFIX)/include
 CFLAGS  += -D_POSIX_C_SOURCE=200112L -DVERSION=\"$(VERSION)\"
 LDFLAGS += -L$(PREFIX)/lib
diff --git a/bspwm.c b/bspwm.c
index 4be7b3590c8f34523c97754aff6d6eb5db1583a2..a6fa8c533abbd0cf160225c0e3281efbac5d92ad 100644 (file)
--- a/bspwm.c
+++ b/bspwm.c
@@ -34,6 +34,7 @@
 #include <sys/un.h>
 #include <signal.h>
 #include <unistd.h>
+#include <xcb/xinerama.h>
 #include "types.h"
 #include "desktop.h"
 #include "monitor.h"
@@ -262,9 +263,32 @@ void setup(void)
     } else {
         randr = false;
         warn("Couldn't retrieve monitors via RandR.\n");
-        xcb_rectangle_t rect = (xcb_rectangle_t) {0, 0, screen_width, screen_height};
-        monitor_t *m = add_monitor(rect);
-        add_desktop(m, make_desktop(NULL));
+        bool xinerama_is_active = false;
+        if (xcb_get_extension_data(dpy, &xcb_xinerama_id)->present) {
+            xcb_xinerama_is_active_reply_t *xia = xcb_xinerama_is_active_reply(dpy, xcb_xinerama_is_active(dpy), NULL);
+            if (xia != NULL) {
+                xinerama_is_active = xia->state;
+                free(xia);
+            }
+        }
+
+        if (xinerama_is_active) {
+            xcb_xinerama_query_screens_reply_t *xsq = xcb_xinerama_query_screens_reply(dpy, xcb_xinerama_query_screens(dpy), NULL);
+            xcb_xinerama_screen_info_t *xsi = xcb_xinerama_query_screens_screen_info(xsq);
+            int n = xcb_xinerama_query_screens_screen_info_length(xsq);
+            for (int i = 0; i < n; i++) {
+                xcb_xinerama_screen_info_t info = xsi[i];
+                xcb_rectangle_t rect = (xcb_rectangle_t) {info.x_org, info.y_org, info.width, info.height};
+                monitor_t *m = add_monitor(rect);
+               add_desktop(m, make_desktop(NULL));
+            }
+            free(xsq);
+        } else {
+            warn("Xinerama is inactive.\n");
+            xcb_rectangle_t rect = (xcb_rectangle_t) {0, 0, screen_width, screen_height};
+            monitor_t *m = add_monitor(rect);
+            add_desktop(m, make_desktop(NULL));
+        }
     }
 
     ewmh_update_number_of_desktops();