diff options
author | S. Christoffer Eliesen <christoffer@eliesen.no> | 2015-10-25 00:38:33 +0200 |
---|---|---|
committer | S. Christoffer Eliesen <christoffer@eliesen.no> | 2015-11-03 22:38:53 +0100 |
commit | 9c8394022edff666f670279f6a14e86fb8321733 (patch) | |
tree | 18c0dd77b12722e621c9dd9f39397f8d7e3a6405 /sway/commands.c | |
parent | Merge pull request #214 from taiyu-len/master (diff) | |
download | sway-9c8394022edff666f670279f6a14e86fb8321733.tar.gz sway-9c8394022edff666f670279f6a14e86fb8321733.tar.zst sway-9c8394022edff666f670279f6a14e86fb8321733.zip |
commands: Learn 'move <container|window> to output <direction|name>'.
Diffstat (limited to 'sway/commands.c')
-rw-r--r-- | sway/commands.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/sway/commands.c b/sway/commands.c index 00a4d1b0..7f4fef09 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -555,7 +555,8 @@ static struct cmd_results *cmd_move(int argc, char **argv) { | |||
555 | return error; | 555 | return error; |
556 | } | 556 | } |
557 | const char* expected_syntax = "Expected 'move <left|right|up|down>' or " | 557 | const char* expected_syntax = "Expected 'move <left|right|up|down>' or " |
558 | "'move <container|window> to workspace <name>'"; | 558 | "'move <container|window> to workspace <name>' or " |
559 | "'move <container|window> to output <name|direction>'"; | ||
559 | swayc_t *view = get_focused_container(&root_container); | 560 | swayc_t *view = get_focused_container(&root_container); |
560 | 561 | ||
561 | if (strcasecmp(argv[0], "left") == 0) { | 562 | if (strcasecmp(argv[0], "left") == 0) { |
@@ -587,6 +588,22 @@ static struct cmd_results *cmd_move(int argc, char **argv) { | |||
587 | ws = workspace_create(ws_name); | 588 | ws = workspace_create(ws_name); |
588 | } | 589 | } |
589 | move_container_to(view, get_focused_container(ws)); | 590 | move_container_to(view, get_focused_container(ws)); |
591 | } else if (strcasecmp(argv[1], "to") == 0 && strcasecmp(argv[2], "output") == 0) { | ||
592 | // move container to output x | ||
593 | swayc_t *output = NULL; | ||
594 | if (view->type != C_CONTAINER && view->type != C_VIEW) { | ||
595 | return cmd_results_new(CMD_FAILURE, "move", "Can only move containers and views."); | ||
596 | } else if (!(output = output_by_name(argv[3]))) { | ||
597 | return cmd_results_new(CMD_FAILURE, "move", | ||
598 | "Can't find output with name/direction '%s'", argv[3]); | ||
599 | } else { | ||
600 | swayc_t *container = get_focused_container(output); | ||
601 | if (container->is_floating) { | ||
602 | move_container_to(view, container->parent); | ||
603 | } else { | ||
604 | move_container_to(view, container); | ||
605 | } | ||
606 | } | ||
590 | } else { | 607 | } else { |
591 | return cmd_results_new(CMD_INVALID, "move", expected_syntax); | 608 | return cmd_results_new(CMD_INVALID, "move", expected_syntax); |
592 | } | 609 | } |