From: Michael Stapelberg Date: Mon, 21 Feb 2011 00:43:39 +0000 (+0100) Subject: Bugfix: fix disabling RandR outputs X-Git-Tag: tree-pr2~39 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=a92b9dca73e220ee6475aabada64fd807aced7c0;p=i3%2Fi3 Bugfix: fix disabling RandR outputs --- diff --git a/Makefile b/Makefile index 25da180e..5a0dd76f 100644 --- 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)) diff --git a/include/all.h b/include/all.h index dd2b9365..23c7fe36 100644 --- a/include/all.h +++ b/include/all.h @@ -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 index 00000000..67652fa1 --- /dev/null +++ b/include/output.h @@ -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 index 00000000..68487924 --- /dev/null +++ b/src/output.c @@ -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); +} diff --git a/src/randr.c b/src/randr.c index a49675cc..20e4f54e 100644 --- a/src/randr.c +++ b/src/randr.c @@ -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");