diff options
author | D.B <thejan.2009@gmail.com> | 2016-08-07 17:07:30 +0200 |
---|---|---|
committer | D.B <thejan.2009@gmail.com> | 2016-08-07 17:07:30 +0200 |
commit | 61781bbef0f75e935a6d71f691de8f63a1508e16 (patch) | |
tree | 41193cff1b249a489b32ec1e3c5a9e8dc14a5df3 | |
parent | Merge pull request #841 from thejan2009/tabbed-title-avoiding-null (diff) | |
download | sway-61781bbef0f75e935a6d71f691de8f63a1508e16.tar.gz sway-61781bbef0f75e935a6d71f691de8f63a1508e16.tar.zst sway-61781bbef0f75e935a6d71f691de8f63a1508e16.zip |
Fix container move when workspace is focused
Fixes #819. If workspace is focused and command 'move container to
workspace/output' is issued, workspace child containers are wrapped in a
new container and moved according to command.
-rw-r--r-- | sway/commands.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/sway/commands.c b/sway/commands.c index 172f9f34..54139593 100644 --- a/sway/commands.c +++ b/sway/commands.c | |||
@@ -1032,7 +1032,9 @@ static struct cmd_results *cmd_move(int argc, char **argv) { | |||
1032 | return error; | 1032 | return error; |
1033 | } else if ( strcasecmp(argv[1], "to") == 0 && strcasecmp(argv[2], "workspace") == 0) { | 1033 | } else if ( strcasecmp(argv[1], "to") == 0 && strcasecmp(argv[2], "workspace") == 0) { |
1034 | // move container to workspace x | 1034 | // move container to workspace x |
1035 | if (view->type != C_CONTAINER && view->type != C_VIEW) { | 1035 | if (view->type == C_WORKSPACE) { |
1036 | view = new_container(view, view->layout); | ||
1037 | } if (view->type != C_CONTAINER && view->type != C_VIEW) { | ||
1036 | return cmd_results_new(CMD_FAILURE, "move", "Can only move containers and views."); | 1038 | return cmd_results_new(CMD_FAILURE, "move", "Can only move containers and views."); |
1037 | } | 1039 | } |
1038 | 1040 | ||
@@ -1055,18 +1057,20 @@ static struct cmd_results *cmd_move(int argc, char **argv) { | |||
1055 | swayc_t *output = NULL; | 1057 | swayc_t *output = NULL; |
1056 | struct wlc_point abs_pos; | 1058 | struct wlc_point abs_pos; |
1057 | get_absolute_center_position(view, &abs_pos); | 1059 | get_absolute_center_position(view, &abs_pos); |
1058 | if (view->type != C_CONTAINER && view->type != C_VIEW) { | 1060 | if (view->type == C_WORKSPACE) { |
1061 | view = new_container(view, view->layout); | ||
1062 | } else if (view->type != C_CONTAINER && view->type != C_VIEW) { | ||
1059 | return cmd_results_new(CMD_FAILURE, "move", "Can only move containers and views."); | 1063 | return cmd_results_new(CMD_FAILURE, "move", "Can only move containers and views."); |
1060 | } else if (!(output = output_by_name(argv[3], &abs_pos))) { | 1064 | } else if (!(output = output_by_name(argv[3], &abs_pos))) { |
1061 | return cmd_results_new(CMD_FAILURE, "move", | 1065 | return cmd_results_new(CMD_FAILURE, "move", |
1062 | "Can't find output with name/direction '%s' @ (%i,%i)", argv[3], abs_pos.x, abs_pos.y); | 1066 | "Can't find output with name/direction '%s' @ (%i,%i)", argv[3], abs_pos.x, abs_pos.y); |
1067 | } | ||
1068 | |||
1069 | swayc_t *container = get_focused_container(output); | ||
1070 | if (container->is_floating) { | ||
1071 | move_container_to(view, container->parent); | ||
1063 | } else { | 1072 | } else { |
1064 | swayc_t *container = get_focused_container(output); | 1073 | move_container_to(view, container); |
1065 | if (container->is_floating) { | ||
1066 | move_container_to(view, container->parent); | ||
1067 | } else { | ||
1068 | move_container_to(view, container); | ||
1069 | } | ||
1070 | } | 1074 | } |
1071 | } else { | 1075 | } else { |
1072 | return cmd_results_new(CMD_INVALID, "move", expected_syntax); | 1076 | return cmd_results_new(CMD_INVALID, "move", expected_syntax); |