From a33d8698852ae5771001f19a71fa5ffa6aee6e05 Mon Sep 17 00:00:00 2001
From: Michael Stapelberg <michael@stapelberg.de>
Date: Mon, 21 Feb 2011 01:12:22 +0100
Subject: [PATCH] Bugfix: Correctly open workspaces on additional outputs

---
 src/randr.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/src/randr.c b/src/randr.c
index 9abe9c7c..a49675cc 100644
--- a/src/randr.c
+++ b/src/randr.c
@@ -306,7 +306,7 @@ void output_init_con(Output *output) {
     int c = 0;
     bool exists = true;
     while (exists) {
-        Con *out, *current;
+        Con *out, *current, *child;
 
         c++;
 
@@ -316,11 +316,16 @@ void output_init_con(Output *output) {
         exists = false;
         TAILQ_FOREACH(out, &(croot->nodes_head), nodes) {
             TAILQ_FOREACH(current, &(out->nodes_head), nodes) {
-                if (strcasecmp(current->name, ws->name) != 0)
+                if (current->type != CT_CON)
                     continue;
 
-                exists = true;
-                break;
+                TAILQ_FOREACH(child, &(current->nodes_head), nodes) {
+                    if (strcasecmp(child->name, ws->name) != 0)
+                        continue;
+
+                    exists = true;
+                    break;
+                }
             }
         }