summaryrefslogtreecommitdiffstats
path: root/sway/container.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/container.c')
-rw-r--r--sway/container.c41
1 files changed, 33 insertions, 8 deletions
diff --git a/sway/container.c b/sway/container.c
index 5d544934..d4f7c693 100644
--- a/sway/container.c
+++ b/sway/container.c
@@ -59,7 +59,7 @@ swayc_t *new_output(wlc_handle handle) {
59 const char *name = wlc_output_get_name(handle); 59 const char *name = wlc_output_get_name(handle);
60 sway_log(L_DEBUG, "Added output %lu:%s", handle, name); 60 sway_log(L_DEBUG, "Added output %lu:%s", handle, name);
61 61
62 struct output_config *oc ; 62 struct output_config *oc = NULL;
63 int i; 63 int i;
64 for (i = 0; i < config->output_configs->length; ++i) { 64 for (i = 0; i < config->output_configs->length; ++i) {
65 oc = config->output_configs->items[i]; 65 oc = config->output_configs->items[i];
@@ -70,6 +70,10 @@ swayc_t *new_output(wlc_handle handle) {
70 oc = NULL; 70 oc = NULL;
71 } 71 }
72 72
73 if (oc && !oc->enabled) {
74 return NULL;
75 }
76
73 swayc_t *output = new_swayc(C_OUTPUT); 77 swayc_t *output = new_swayc(C_OUTPUT);
74 if (oc && oc->width != -1 && oc->height != -1) { 78 if (oc && oc->width != -1 && oc->height != -1) {
75 output->width = oc->width; 79 output->width = oc->width;
@@ -83,6 +87,24 @@ swayc_t *new_output(wlc_handle handle) {
83 output->handle = handle; 87 output->handle = handle;
84 output->name = name ? strdup(name) : NULL; 88 output->name = name ? strdup(name) : NULL;
85 output->gaps = config->gaps_outer + config->gaps_inner / 2; 89 output->gaps = config->gaps_outer + config->gaps_inner / 2;
90
91 // Find position for it
92 if (oc && oc->x != -1 && oc->y != -1) {
93 sway_log(L_DEBUG, "Set %s position to %d, %d", name, oc->x, oc->y);
94 output->x = oc->x;
95 output->y = oc->y;
96 } else {
97 int x = 0;
98 for (i = 0; i < root_container.children->length; ++i) {
99 swayc_t *c = root_container.children->items[i];
100 if (c->type == C_OUTPUT) {
101 if (c->width + c->x > x) {
102 x = c->width + c->x;
103 }
104 }
105 }
106 output->x = x;
107 }
86 108
87 add_child(&root_container, output); 109 add_child(&root_container, output);
88 110
@@ -281,7 +303,8 @@ swayc_t *destroy_workspace(swayc_t *workspace) {
281 return NULL; 303 return NULL;
282 } 304 }
283 305
284 if (workspace->children->length == 0) { 306 // Do not destroy if there are children
307 if (workspace->children->length == 0 && workspace->floating->length == 0) {
285 sway_log(L_DEBUG, "%s: '%s'", __func__, workspace->name); 308 sway_log(L_DEBUG, "%s: '%s'", __func__, workspace->name);
286 swayc_t *parent = workspace->parent; 309 swayc_t *parent = workspace->parent;
287 free_swayc(workspace); 310 free_swayc(workspace);
@@ -448,14 +471,16 @@ bool swayc_is_fullscreen(swayc_t *view) {
448// Mapping 471// Mapping
449 472
450void container_map(swayc_t *container, void (*f)(swayc_t *view, void *data), void *data) { 473void container_map(swayc_t *container, void (*f)(swayc_t *view, void *data), void *data) {
451 if (container && container->children && container->children->length) { 474 if (container) {
452 int i; 475 int i;
453 for (i = 0; i < container->children->length; ++i) { 476 if (container->children) {
454 swayc_t *child = container->children->items[i]; 477 for (i = 0; i < container->children->length; ++i) {
455 f(child, data); 478 swayc_t *child = container->children->items[i];
456 container_map(child, f, data); 479 f(child, data);
480 container_map(child, f, data);
481 }
457 } 482 }
458 if (container->type == C_WORKSPACE) { 483 if (container->floating) {
459 for (i = 0; i < container->floating->length; ++i) { 484 for (i = 0; i < container->floating->length; ++i) {
460 swayc_t *child = container->floating->items[i]; 485 swayc_t *child = container->floating->items[i];
461 f(child, data); 486 f(child, data);