diff options
Diffstat (limited to 'sway/layout.c')
-rw-r--r-- | sway/layout.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/sway/layout.c b/sway/layout.c index 78b3dd27..b70e1041 100644 --- a/sway/layout.c +++ b/sway/layout.c | |||
@@ -370,3 +370,35 @@ swayc_t *get_swayc_in_direction(swayc_t *container, enum movement_direction dir) | |||
370 | } | 370 | } |
371 | } | 371 | } |
372 | } | 372 | } |
373 | |||
374 | void recursive_resize(swayc_t *container, double amount, enum movement_direction dir) { | ||
375 | int i; | ||
376 | bool layout_match = true; | ||
377 | if (dir == MOVE_LEFT) { | ||
378 | container->x += (int) amount; | ||
379 | container->width += (int) amount; | ||
380 | layout_match = container->layout == L_HORIZ; | ||
381 | } else if(dir == MOVE_RIGHT) { | ||
382 | container->width += (int) amount; | ||
383 | layout_match = container->layout == L_HORIZ; | ||
384 | } else if(dir == MOVE_UP) { | ||
385 | container->y += (int) amount; | ||
386 | container->height += (int) amount; | ||
387 | layout_match = container->layout == L_VERT; | ||
388 | } else if(dir == MOVE_DOWN) { | ||
389 | container->height += (int) amount; | ||
390 | layout_match = container->layout == L_VERT; | ||
391 | } | ||
392 | if (container->type == C_VIEW) { | ||
393 | return; | ||
394 | } | ||
395 | if (layout_match) { | ||
396 | for (i = 0; i < container->children->length; i++) { | ||
397 | recursive_resize(container->children->items[i], amount/container->children->length, dir); | ||
398 | } | ||
399 | } else { | ||
400 | for (i = 0; i < container->children->length; i++) { | ||
401 | recursive_resize(container->children->items[i], amount, dir); | ||
402 | } | ||
403 | } | ||
404 | } | ||