summaryrefslogtreecommitdiffstats
path: root/sway/container.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/container.c')
-rw-r--r--sway/container.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/sway/container.c b/sway/container.c
index 4321b6ce..87e48e91 100644
--- a/sway/container.c
+++ b/sway/container.c
@@ -81,6 +81,7 @@ swayc_t *new_workspace(swayc_t * output, const char *name) {
81 workspace->height = output->height; 81 workspace->height = output->height;
82 workspace->name = strdup(name); 82 workspace->name = strdup(name);
83 workspace->visible = true; 83 workspace->visible = true;
84 workspace->floating = create_list();
84 85
85 add_child(output, workspace); 86 add_child(output, workspace);
86 return workspace; 87 return workspace;
@@ -134,6 +135,9 @@ swayc_t *new_view(swayc_t *sibling, wlc_handle handle) {
134 view->name = strdup(title); 135 view->name = strdup(title);
135 view->visible = true; 136 view->visible = true;
136 137
138 // TODO: properly set this
139 view->is_floating = false;
140
137 //Case of focused workspace, just create as child of it 141 //Case of focused workspace, just create as child of it
138 if (sibling->type == C_WORKSPACE) { 142 if (sibling->type == C_WORKSPACE) {
139 add_child(sibling, view); 143 add_child(sibling, view);
@@ -192,23 +196,32 @@ swayc_t *destroy_view(swayc_t *view) {
192 if (parent->type == C_CONTAINER) { 196 if (parent->type == C_CONTAINER) {
193 return destroy_container(parent); 197 return destroy_container(parent);
194 } 198 }
199
195 return parent; 200 return parent;
196} 201}
197 202
198
199swayc_t *find_container(swayc_t *container, bool (*test)(swayc_t *view, void *data), void *data) { 203swayc_t *find_container(swayc_t *container, bool (*test)(swayc_t *view, void *data), void *data) {
200 if (!container->children) { 204 if (!container->children) {
201 return NULL; 205 return NULL;
202 } 206 }
207 // Special case for checking floating stuff
203 int i; 208 int i;
209 if (container->type == C_WORKSPACE) {
210 for (i = 0; i < container->floating->length; ++i) {
211 swayc_t *child = container->floating->items[i];
212 if (test(child, data)) {
213 return child;
214 }
215 }
216 }
204 for (i = 0; i < container->children->length; ++i) { 217 for (i = 0; i < container->children->length; ++i) {
205 swayc_t *child = container->children->items[i]; 218 swayc_t *child = container->children->items[i];
206 if (test(child, data)) { 219 if (test(child, data)) {
207 return child; 220 return child;
208 } else { 221 } else {
209 swayc_t *_ = find_container(child, test, data); 222 swayc_t *res = find_container(child, test, data);
210 if (_) { 223 if (res) {
211 return _; 224 return res;
212 } 225 }
213 } 226 }
214 } 227 }