summaryrefslogtreecommitdiffstats
path: root/sway/container.c
diff options
context:
space:
mode:
authorLibravatar Zandr Martin <zandrmartin@gmail.com>2016-07-04 13:34:44 -0500
committerLibravatar Zandr Martin <zandrmartin@gmail.com>2016-07-04 13:34:44 -0500
commit15a324b0d3c0d15405286794d2c8b88b764835cf (patch)
treeb2c2cf4c7e7d509b515fd6b93aa34f959fb666e1 /sway/container.c
parentSpawn windows as floating if they have a parent (diff)
downloadsway-15a324b0d3c0d15405286794d2c8b88b764835cf.tar.gz
sway-15a324b0d3c0d15405286794d2c8b88b764835cf.tar.zst
sway-15a324b0d3c0d15405286794d2c8b88b764835cf.zip
implement `get_tree` command
Diffstat (limited to 'sway/container.c')
-rw-r--r--sway/container.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/sway/container.c b/sway/container.c
index 21538ab4..a7e46571 100644
--- a/sway/container.c
+++ b/sway/container.c
@@ -75,6 +75,30 @@ static void free_swayc(swayc_t *cont) {
75 free(cont); 75 free(cont);
76} 76}
77 77
78static void update_root_geometry() {
79 int width = 0;
80 int height = 0;
81 swayc_t *child;
82 int child_width;
83 int child_height;
84
85 for (int i = 0; i < root_container.children->length; ++i) {
86 child = root_container.children->items[i];
87 child_width = child->width + child->x;
88 child_height = child->height + child->y;
89 if (child_width > width) {
90 width = child_width;
91 }
92
93 if (child_height > height) {
94 height = child_height;
95 }
96 }
97
98 root_container.width = width;
99 root_container.height = height;
100}
101
78// New containers 102// New containers
79 103
80swayc_t *new_output(wlc_handle handle) { 104swayc_t *new_output(wlc_handle handle) {
@@ -167,6 +191,7 @@ swayc_t *new_output(wlc_handle handle) {
167 } 191 }
168 192
169 free(ws_name); 193 free(ws_name);
194 update_root_geometry();
170 return output; 195 return output;
171} 196}
172 197
@@ -361,7 +386,7 @@ void floating_view_sane_size(swayc_t *view) {
361 view->desired_width = config->floating_maximum_width; 386 view->desired_width = config->floating_maximum_width;
362 } 387 }
363 388
364 sway_log(L_DEBUG, "Sane values for view to %d x %d @ %.f, %.f", 389 sway_log(L_DEBUG, "Sane values for view to %d x %d @ %.f, %.f",
365 view->desired_width, view->desired_height, view->x, view->y); 390 view->desired_width, view->desired_height, view->x, view->y);
366 391
367 return; 392 return;
@@ -393,6 +418,7 @@ swayc_t *destroy_output(swayc_t *output) {
393 } 418 }
394 sway_log(L_DEBUG, "OUTPUT: Destroying output '%" PRIuPTR "'", output->handle); 419 sway_log(L_DEBUG, "OUTPUT: Destroying output '%" PRIuPTR "'", output->handle);
395 free_swayc(output); 420 free_swayc(output);
421 update_root_geometry();
396 return &root_container; 422 return &root_container;
397} 423}
398 424