]> git.sur5r.net Git - i3/i3/commitdiff
Bugfix: fix disabling RandR outputs
authorMichael Stapelberg <michael@stapelberg.de>
Mon, 21 Feb 2011 00:43:39 +0000 (01:43 +0100)
committerMichael Stapelberg <michael@stapelberg.de>
Mon, 21 Feb 2011 00:43:39 +0000 (01:43 +0100)
Makefile
include/all.h
include/output.h [new file with mode: 0644]
src/output.c [new file with mode: 0644]
src/randr.c

index 25da180e0f2fc7bd72a42ef5f96294863b373664..5a0dd76fc55e948abef16363918a8d7ad46e346b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,7 @@ include $(TOPDIR)/common.mk
 
 # Depend on the object files of all source-files in src/*.c and on all header files
 AUTOGENERATED:=src/cfgparse.tab.c src/cfgparse.yy.c src/cmdparse.tab.c src/cmdparse.yy.c
-FILES:=src/ipc.c src/main.c src/log.c src/util.c src/tree.c src/xcb.c src/manage.c src/workspace.c src/x.c src/floating.c src/click.c src/config.c src/handlers.c src/randr.c src/xinerama.c src/con.c src/load_layout.c src/render.c src/window.c src/match.c src/xcursor.c src/resize.c src/sighandler.c src/move.c
+FILES:=src/ipc.c src/main.c src/log.c src/util.c src/tree.c src/xcb.c src/manage.c src/workspace.c src/x.c src/floating.c src/click.c src/config.c src/handlers.c src/randr.c src/xinerama.c src/con.c src/load_layout.c src/render.c src/window.c src/match.c src/xcursor.c src/resize.c src/sighandler.c src/move.c src/output.c
 FILES:=$(FILES:.c=.o)
 HEADERS:=$(filter-out include/loglevels.h,$(wildcard include/*.h))
 
index dd2b9365f7a09e80308fcce6715ae462441397fd..23c7fe36d157572c51b71799a6ad35c97cad6f27 100644 (file)
@@ -55,5 +55,6 @@
 #include "resize.h"
 #include "sighandler.h"
 #include "move.h"
+#include "output.h"
 
 #endif
diff --git a/include/output.h b/include/output.h
new file mode 100644 (file)
index 0000000..67652fa
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * vim:ts=4:sw=4:expandtab
+ */
+
+#ifndef _OUTPUT_H
+#define _OUTPUT_H
+
+/**
+ * Returns the output container below the given output container.
+ *
+ */
+Con *output_get_content(Con *output);
+
+#endif
diff --git a/src/output.c b/src/output.c
new file mode 100644 (file)
index 0000000..6848792
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * vim:ts=4:sw=4:expandtab
+ */
+
+#include "all.h"
+
+/*
+ * Returns the output container below the given output container.
+ *
+ */
+Con *output_get_content(Con *output) {
+    Con *child;
+
+    TAILQ_FOREACH(child, &(output->nodes_head), nodes)
+        if (child->type == CT_CON)
+            return child;
+
+    ELOG("output_get_content() called on non-output %p\n", output);
+    assert(false);
+}
index a49675cc0ba520cd8f2f1572bb2d0033334698b1..20e4f54e89b86447ff65979b676c2c677ca79ea7 100644 (file)
@@ -584,7 +584,9 @@ void randr_query_outputs() {
             DLOG("Output %s disabled, re-assigning workspaces/docks\n", output->name);
 
             if ((first = get_first_output()) == NULL)
-                    die("No usable outputs available\n");
+                die("No usable outputs available\n");
+
+            Con *first_content = output_get_content(first->con);
 
             if (output->con != NULL) {
                 /* We need to move the workspaces from the disappearing output to the first output */
@@ -598,12 +600,13 @@ void randr_query_outputs() {
 
                 /* 2: iterate through workspaces and re-assign them */
                 Con *current;
-                while (!TAILQ_EMPTY(&(output->con->nodes_head))) {
-                    current = TAILQ_FIRST(&(output->con->nodes_head));
+                Con *old_content = output_get_content(output->con);
+                while (!TAILQ_EMPTY(&(old_content->nodes_head))) {
+                    current = TAILQ_FIRST(&(old_content->nodes_head));
                     DLOG("Detaching current = %p / %s\n", current, current->name);
                     con_detach(current);
                     DLOG("Re-attaching current = %p / %s\n", current, current->name);
-                    con_attach(current, first->con, false);
+                    con_attach(current, first_content, false);
                     DLOG("Done, next\n");
                 }
                 DLOG("re-attached all workspaces\n");