aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorS. Christoffer Eliesen <christoffer@eliesen.no>2015-10-25 00:38:33 +0200
committerS. Christoffer Eliesen <christoffer@eliesen.no>2015-11-03 22:38:53 +0100
commit9c8394022edff666f670279f6a14e86fb8321733 (patch)
tree18c0dd77b12722e621c9dd9f39397f8d7e3a6405
parent0833fa0c7538c8e5cfdce5d1500360383b9a39f7 (diff)
commands: Learn 'move <container|window> to output <direction|name>'.
-rw-r--r--sway.5.txt4
-rw-r--r--sway/commands.c19
2 files changed, 22 insertions, 1 deletions
diff --git a/sway.5.txt b/sway.5.txt
index 27735db6..87bd0c05 100644
--- a/sway.5.txt
+++ b/sway.5.txt
@@ -102,6 +102,10 @@ Commands
Moves the focused container to the workspace identified by _name_.
_name_ may be a special workspace name. See **workspace**.
+**move** <container|window> to output <name|direction>::
+ Moves the focused container to the output identified by _name_ or _direction_.
+ _direction_ may be one of _up_, _down_, _left_, _right_.
+
**mouse_warping** <output|none>::
When _output_: place mouse at center of newly focused window when changing
output. When _none_: don't move mouse.
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) {
return error;
}
const char* expected_syntax = "Expected 'move <left|right|up|down>' or "
- "'move <container|window> to workspace <name>'";
+ "'move <container|window> to workspace <name>' or "
+ "'move <container|window> to output <name|direction>'";
swayc_t *view = get_focused_container(&root_container);
if (strcasecmp(argv[0], "left") == 0) {
@@ -587,6 +588,22 @@ static struct cmd_results *cmd_move(int argc, char **argv) {
ws = workspace_create(ws_name);
}
move_container_to(view, get_focused_container(ws));
+ } else if (strcasecmp(argv[1], "to") == 0 && strcasecmp(argv[2], "output") == 0) {
+ // move container to output x
+ swayc_t *output = NULL;
+ if (view->type != C_CONTAINER && view->type != C_VIEW) {
+ return cmd_results_new(CMD_FAILURE, "move", "Can only move containers and views.");
+ } else if (!(output = output_by_name(argv[3]))) {
+ return cmd_results_new(CMD_FAILURE, "move",
+ "Can't find output with name/direction '%s'", argv[3]);
+ } else {
+ swayc_t *container = get_focused_container(output);
+ if (container->is_floating) {
+ move_container_to(view, container->parent);
+ } else {
+ move_container_to(view, container);
+ }
+ }
} else {
return cmd_results_new(CMD_INVALID, "move", expected_syntax);
}