diff options
Diffstat (limited to 'sway/container.c')
-rw-r--r-- | sway/container.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/sway/container.c b/sway/container.c index abbd5504..416b8db8 100644 --- a/sway/container.c +++ b/sway/container.c | |||
@@ -57,6 +57,19 @@ static void free_swayc(swayc_t *cont) { | |||
57 | swayc_t *new_output(wlc_handle handle) { | 57 | swayc_t *new_output(wlc_handle handle) { |
58 | const struct wlc_size *size = wlc_output_get_resolution(handle); | 58 | const struct wlc_size *size = wlc_output_get_resolution(handle); |
59 | const char *name = wlc_output_get_name(handle); | 59 | const char *name = wlc_output_get_name(handle); |
60 | // Find current outputs to see if this already exists | ||
61 | { | ||
62 | int i, len = root_container.children->length; | ||
63 | for (i = 0; i < len; ++i) { | ||
64 | swayc_t *op = root_container.children->items[i]; | ||
65 | const char *op_name = op->name; | ||
66 | if (op_name && name && strcmp(op_name, name) == 0) { | ||
67 | sway_log(L_DEBUG, "restoring output %lu:%s", handle, op_name); | ||
68 | return op; | ||
69 | } | ||
70 | } | ||
71 | } | ||
72 | |||
60 | sway_log(L_DEBUG, "Added output %lu:%s", handle, name); | 73 | sway_log(L_DEBUG, "Added output %lu:%s", handle, name); |
61 | 74 | ||
62 | struct output_config *oc = NULL; | 75 | struct output_config *oc = NULL; |
@@ -329,7 +342,7 @@ swayc_t *destroy_workspace(swayc_t *workspace) { | |||
329 | 342 | ||
330 | // Do not destroy if there are children | 343 | // Do not destroy if there are children |
331 | if (workspace->children->length == 0 && workspace->floating->length == 0) { | 344 | if (workspace->children->length == 0 && workspace->floating->length == 0) { |
332 | sway_log(L_DEBUG, "'%s'", workspace->name); | 345 | sway_log(L_DEBUG, "destroying '%s'", workspace->name); |
333 | swayc_t *parent = workspace->parent; | 346 | swayc_t *parent = workspace->parent; |
334 | free_swayc(workspace); | 347 | free_swayc(workspace); |
335 | return parent; | 348 | return parent; |
@@ -396,6 +409,17 @@ swayc_t *swayc_by_test(swayc_t *container, bool (*test)(swayc_t *view, void *dat | |||
396 | return NULL; | 409 | return NULL; |
397 | } | 410 | } |
398 | 411 | ||
412 | static bool test_name(swayc_t *view, void *data) { | ||
413 | if (!view && !view->name) { | ||
414 | return false; | ||
415 | } | ||
416 | return strcmp(view->name, data) == 0; | ||
417 | } | ||
418 | |||
419 | swayc_t *swayc_by_name(const char *name) { | ||
420 | return swayc_by_test(&root_container, test_name, (void *)name); | ||
421 | } | ||
422 | |||
399 | swayc_t *swayc_parent_by_type(swayc_t *container, enum swayc_types type) { | 423 | swayc_t *swayc_parent_by_type(swayc_t *container, enum swayc_types type) { |
400 | if (!ASSERT_NONNULL(container)) { | 424 | if (!ASSERT_NONNULL(container)) { |
401 | return NULL; | 425 | return NULL; |