# 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))
--- /dev/null
+/*
+ * 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);
+}
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 */
/* 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");