From b35782bcade4eb21b8e7dab455dad64ab721438d Mon Sep 17 00:00:00 2001 From: Calvin Lee Date: Mon, 27 Feb 2017 20:30:58 -0700 Subject: i3 feature support: Moving flotaing containers This commit lets the 'move' command apply to floating containers as well as tiled ones. The command may be appended with a number of pixels and then optionally the string `px` (like '10 px') in order to move the container more or fewer than the standard ten pixels. --- sway/layout.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'sway/layout.c') diff --git a/sway/layout.c b/sway/layout.c index 5e144cd8..e196ebd3 100644 --- a/sway/layout.c +++ b/sway/layout.c @@ -349,10 +349,31 @@ static void swap_children(swayc_t *container, int a, int b) { } } -void move_container(swayc_t *container, enum movement_direction dir) { +void move_container(swayc_t *container, enum movement_direction dir, int move_amt) { enum swayc_layouts layout = L_NONE; swayc_t *parent = container->parent; - if (container->is_floating || (container->type != C_VIEW && container->type != C_CONTAINER)) { + if (container->is_floating) { + swayc_t *output = swayc_parent_by_type(container, C_OUTPUT); + switch(dir) { + case MOVE_LEFT: + container->x = MAX(0, container->x - move_amt); + break; + case MOVE_RIGHT: + container->x = MIN(output->width - container->width, container->x + move_amt); + break; + case MOVE_UP: + container->y = MAX(0, container->y - move_amt); + break; + case MOVE_DOWN: + container->y = MIN(output->height - container->height, container->y + move_amt); + break; + default: + break; + } + update_geometry(container); + return; + } + if (container->type != C_VIEW && container->type != C_CONTAINER) { return; } if (dir == MOVE_UP || dir == MOVE_DOWN) { -- cgit v1.2.3