+ /* We need to force disabling outputs which have been loaded from the
+ * layout file but are no longer active. This can happen if the output has
+ * been disabled in the short time between writing the restart layout file
+ * and restarting i3. See #2326. */
+ if (layout_path != NULL && randr_base > -1) {
+ Con *con;
+ TAILQ_FOREACH(con, &(croot->nodes_head), nodes) {
+ Output *output;
+ TAILQ_FOREACH(output, &outputs, outputs) {
+ if (output->active || strcmp(con->name, output_primary_name(output)) != 0)
+ continue;
+
+ /* This will correctly correlate the output with its content
+ * container. We need to make the connection to properly
+ * disable the output. */
+ if (output->con == NULL) {
+ output_init_con(output);
+ output->changed = false;
+ }
+
+ output->to_be_disabled = true;
+ randr_disable_output(output);
+ }
+ }
+ }
+ FREE(layout_path);
+