summaryrefslogtreecommitdiffstats
path: root/sway/commands
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/commands
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/commands')
-rw-r--r--sway/commands/move.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/sway/commands/move.c b/sway/commands/move.c
index 0b134494..1a8a321e 100644
--- a/sway/commands/move.c
+++ b/sway/commands/move.c
@@ -9,30 +9,40 @@
9 9
10struct cmd_results *cmd_move(int argc, char **argv) { 10struct cmd_results *cmd_move(int argc, char **argv) {
11 struct cmd_results *error = NULL; 11 struct cmd_results *error = NULL;
12 int move_amt = 10;
13
12 if (config->reading) return cmd_results_new(CMD_FAILURE, "move", "Can't be used in config file."); 14 if (config->reading) return cmd_results_new(CMD_FAILURE, "move", "Can't be used in config file.");
13 if ((error = checkarg(argc, "move", EXPECTED_AT_LEAST, 1))) { 15 if ((error = checkarg(argc, "move", EXPECTED_AT_LEAST, 1))) {
14 return error; 16 return error;
15 } 17 }
16 const char* expected_syntax = "Expected 'move <left|right|up|down|next|prev|first>' or " 18 const char* expected_syntax = "Expected 'move <left|right|up|down|next|prev|first> <[px] px>' or "
17 "'move <container|window> to workspace <name>' or " 19 "'move <container|window> to workspace <name>' or "
18 "'move <container|window|workspace> to output <name|direction>' or " 20 "'move <container|window|workspace> to output <name|direction>' or "
19 "'move position mouse'"; 21 "'move position mouse'";
20 swayc_t *view = get_focused_container(&root_container); 22 swayc_t *view = get_focused_container(&root_container);
21 23
24 if (argc == 2 || (argc == 3 && strcasecmp(argv[2], "px") == 0 )) {
25 char *inv;
26 move_amt = (int)strtol(argv[1], &inv, 10);
27 if (*inv != '\0' && strcasecmp(inv, "px") != 0) {
28 move_amt = 10;
29 }
30 }
31
22 if (strcasecmp(argv[0], "left") == 0) { 32 if (strcasecmp(argv[0], "left") == 0) {
23 move_container(view, MOVE_LEFT); 33 move_container(view, MOVE_LEFT, move_amt);
24 } else if (strcasecmp(argv[0], "right") == 0) { 34 } else if (strcasecmp(argv[0], "right") == 0) {
25 move_container(view, MOVE_RIGHT); 35 move_container(view, MOVE_RIGHT, move_amt);
26 } else if (strcasecmp(argv[0], "up") == 0) { 36 } else if (strcasecmp(argv[0], "up") == 0) {
27 move_container(view, MOVE_UP); 37 move_container(view, MOVE_UP, move_amt);
28 } else if (strcasecmp(argv[0], "down") == 0) { 38 } else if (strcasecmp(argv[0], "down") == 0) {
29 move_container(view, MOVE_DOWN); 39 move_container(view, MOVE_DOWN, move_amt);
30 } else if (strcasecmp(argv[0], "next") == 0) { 40 } else if (strcasecmp(argv[0], "next") == 0) {
31 move_container(view, MOVE_NEXT); 41 move_container(view, MOVE_NEXT, move_amt);
32 } else if (strcasecmp(argv[0], "prev") == 0) { 42 } else if (strcasecmp(argv[0], "prev") == 0) {
33 move_container(view, MOVE_PREV); 43 move_container(view, MOVE_PREV, move_amt);
34 } else if (strcasecmp(argv[0], "first") == 0) { 44 } else if (strcasecmp(argv[0], "first") == 0) {
35 move_container(view, MOVE_FIRST); 45 move_container(view, MOVE_FIRST, move_amt);
36 } else if (strcasecmp(argv[0], "container") == 0 || strcasecmp(argv[0], "window") == 0) { 46 } else if (strcasecmp(argv[0], "container") == 0 || strcasecmp(argv[0], "window") == 0) {
37 // "move container ... 47 // "move container ...
38 if ((error = checkarg(argc, "move container/window", EXPECTED_AT_LEAST, 4))) { 48 if ((error = checkarg(argc, "move container/window", EXPECTED_AT_LEAST, 4))) {