diff options
Diffstat (limited to 'sway/tree/container.c')
-rw-r--r-- | sway/tree/container.c | 39 |
1 files changed, 8 insertions, 31 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c index 1f537025..dade8f54 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -38,7 +38,7 @@ static void notify_new_container(struct sway_container *container) { | |||
38 | ipc_event_window(container, "new"); | 38 | ipc_event_window(container, "new"); |
39 | } | 39 | } |
40 | 40 | ||
41 | static struct sway_container *new_swayc(enum sway_container_type type) { | 41 | static struct sway_container *container_create(enum sway_container_type type) { |
42 | // next id starts at 1 because 0 is assigned to root_container in layout.c | 42 | // next id starts at 1 because 0 is assigned to root_container in layout.c |
43 | static size_t next_id = 1; | 43 | static size_t next_id = 1; |
44 | struct sway_container *c = calloc(1, sizeof(struct sway_container)); | 44 | struct sway_container *c = calloc(1, sizeof(struct sway_container)); |
@@ -122,7 +122,7 @@ struct sway_container *container_output_create( | |||
122 | return NULL; | 122 | return NULL; |
123 | } | 123 | } |
124 | 124 | ||
125 | struct sway_container *output = new_swayc(C_OUTPUT); | 125 | struct sway_container *output = container_create(C_OUTPUT); |
126 | output->sway_output = sway_output; | 126 | output->sway_output = sway_output; |
127 | output->name = strdup(name); | 127 | output->name = strdup(name); |
128 | if (output->name == NULL) { | 128 | if (output->name == NULL) { |
@@ -151,14 +151,14 @@ struct sway_container *container_output_create( | |||
151 | return output; | 151 | return output; |
152 | } | 152 | } |
153 | 153 | ||
154 | struct sway_container *container_workspace_create(struct sway_container | 154 | struct sway_container *container_workspace_create( |
155 | *output, const char *name) { | 155 | struct sway_container *output, const char *name) { |
156 | if (!sway_assert(output, | 156 | if (!sway_assert(output, |
157 | "container_workspace_create called with null output")) { | 157 | "container_workspace_create called with null output")) { |
158 | return NULL; | 158 | return NULL; |
159 | } | 159 | } |
160 | wlr_log(L_DEBUG, "Added workspace %s for output %s", name, output->name); | 160 | wlr_log(L_DEBUG, "Added workspace %s for output %s", name, output->name); |
161 | struct sway_container *workspace = new_swayc(C_WORKSPACE); | 161 | struct sway_container *workspace = container_create(C_WORKSPACE); |
162 | 162 | ||
163 | workspace->x = output->x; | 163 | workspace->x = output->x; |
164 | workspace->y = output->y; | 164 | workspace->y = output->y; |
@@ -182,7 +182,7 @@ struct sway_container *container_view_create(struct sway_container *sibling, | |||
182 | return NULL; | 182 | return NULL; |
183 | } | 183 | } |
184 | const char *title = view_get_title(sway_view); | 184 | const char *title = view_get_title(sway_view); |
185 | struct sway_container *swayc = new_swayc(C_VIEW); | 185 | struct sway_container *swayc = container_create(C_VIEW); |
186 | wlr_log(L_DEBUG, "Adding new view %p:%s to container %p %d %s", | 186 | wlr_log(L_DEBUG, "Adding new view %p:%s to container %p %d %s", |
187 | swayc, title, sibling, sibling ? sibling->type : 0, sibling->name); | 187 | swayc, title, sibling, sibling ? sibling->type : 0, sibling->name); |
188 | // Setup values | 188 | // Setup values |
@@ -314,30 +314,7 @@ struct sway_container *container_parent(struct sway_container *container, | |||
314 | return container; | 314 | return container; |
315 | } | 315 | } |
316 | 316 | ||
317 | void sway_container_for_each(struct sway_container *container, | 317 | struct sway_container *container_at(struct sway_container *parent, |
318 | void (*f)(struct sway_container *view, void *data), void *data) { | ||
319 | if (container) { | ||
320 | int i; | ||
321 | if (container->children) { | ||
322 | for (i = 0; i < container->children->length; ++i) { | ||
323 | struct sway_container *child = container->children->items[i]; | ||
324 | sway_container_for_each(child, f, data); | ||
325 | } | ||
326 | } | ||
327 | // TODO | ||
328 | /* | ||
329 | if (container->floating) { | ||
330 | for (i = 0; i < container->floating->length; ++i) { | ||
331 | struct sway_container *child = container->floating->items[i]; | ||
332 | container_map(child, f, data); | ||
333 | } | ||
334 | } | ||
335 | */ | ||
336 | f(container, data); | ||
337 | } | ||
338 | } | ||
339 | |||
340 | struct sway_container *sway_container_at(struct sway_container *parent, | ||
341 | double lx, double ly, | 318 | double lx, double ly, |
342 | struct wlr_surface **surface, double *sx, double *sy) { | 319 | struct wlr_surface **surface, double *sx, double *sy) { |
343 | list_t *queue = get_bfs_queue(); | 320 | list_t *queue = get_bfs_queue(); |
@@ -423,7 +400,7 @@ struct sway_container *sway_container_at(struct sway_container *parent, | |||
423 | return NULL; | 400 | return NULL; |
424 | } | 401 | } |
425 | 402 | ||
426 | void sway_container_for_each_bfs(struct sway_container *con, | 403 | void container_for_each(struct sway_container *con, |
427 | void (*f)(struct sway_container *con, void *data), void *data) { | 404 | void (*f)(struct sway_container *con, void *data), void *data) { |
428 | list_t *queue = get_bfs_queue(); | 405 | list_t *queue = get_bfs_queue(); |
429 | if (!queue) { | 406 | if (!queue) { |