summaryrefslogtreecommitdiffstats
path: root/sway/layout.c
diff options
context:
space:
mode:
authorLibravatar Calvin Lee <cyrus296@gmail.com>2017-02-27 20:30:58 -0700
committerLibravatar Calvin Lee <cyrus296@gmail.com>2017-03-01 11:00:16 -0700
commitb35782bcade4eb21b8e7dab455dad64ab721438d (patch)
tree18dd68d4a4f06da3dc069cfde54a3ebd2fe64f77 /sway/layout.c
parentFix #1087 (diff)
downloadsway-b35782bcade4eb21b8e7dab455dad64ab721438d.tar.gz
sway-b35782bcade4eb21b8e7dab455dad64ab721438d.tar.zst
sway-b35782bcade4eb21b8e7dab455dad64ab721438d.zip
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.
Diffstat (limited to 'sway/layout.c')
-rw-r--r--sway/layout.c25
1 files changed, 23 insertions, 2 deletions
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) {
349 } 349 }
350} 350}
351 351
352void move_container(swayc_t *container, enum movement_direction dir) { 352void move_container(swayc_t *container, enum movement_direction dir, int move_amt) {
353 enum swayc_layouts layout = L_NONE; 353 enum swayc_layouts layout = L_NONE;
354 swayc_t *parent = container->parent; 354 swayc_t *parent = container->parent;
355 if (container->is_floating || (container->type != C_VIEW && container->type != C_CONTAINER)) { 355 if (container->is_floating) {
356 swayc_t *output = swayc_parent_by_type(container, C_OUTPUT);
357 switch(dir) {
358 case MOVE_LEFT:
359 container->x = MAX(0, container->x - move_amt);
360 break;
361 case MOVE_RIGHT:
362 container->x = MIN(output->width - container->width, container->x + move_amt);
363 break;
364 case MOVE_UP:
365 container->y = MAX(0, container->y - move_amt);
366 break;
367 case MOVE_DOWN:
368 container->y = MIN(output->height - container->height, container->y + move_amt);
369 break;
370 default:
371 break;
372 }
373 update_geometry(container);
374 return;
375 }
376 if (container->type != C_VIEW && container->type != C_CONTAINER) {
356 return; 377 return;
357 } 378 }
358 if (dir == MOVE_UP || dir == MOVE_DOWN) { 379 if (dir == MOVE_UP || dir == MOVE_DOWN) {