diff options
Diffstat (limited to 'sway/commands/move.c')
-rw-r--r-- | sway/commands/move.c | 60 |
1 files changed, 34 insertions, 26 deletions
diff --git a/sway/commands/move.c b/sway/commands/move.c index d49d6862..500151f7 100644 --- a/sway/commands/move.c +++ b/sway/commands/move.c | |||
@@ -99,40 +99,48 @@ static struct cmd_results *cmd_move_container(struct sway_container *current, | |||
99 | if (strcasecmp(argv[1], "workspace") == 0) { | 99 | if (strcasecmp(argv[1], "workspace") == 0) { |
100 | // move container to workspace x | 100 | // move container to workspace x |
101 | struct sway_container *ws; | 101 | struct sway_container *ws; |
102 | char *ws_name = NULL; | 102 | if (strcasecmp(argv[2], "next") == 0 || |
103 | if (strcasecmp(argv[2], "number") == 0) { | 103 | strcasecmp(argv[2], "prev") == 0 || |
104 | // move "container to workspace number x" | 104 | strcasecmp(argv[2], "next_on_output") == 0 || |
105 | if (argc < 4) { | 105 | strcasecmp(argv[2], "prev_on_output") == 0 || |
106 | return cmd_results_new(CMD_INVALID, "move", expected_syntax); | 106 | strcasecmp(argv[2], "back_and_forth") == 0 || |
107 | strcasecmp(argv[2], "current") == 0) { | ||
108 | ws = workspace_by_name(argv[2]); | ||
109 | } else if (strcasecmp(argv[2], "back_and_forth") == 0) { | ||
110 | if (!(ws = workspace_by_name(argv[0])) && prev_workspace_name) { | ||
111 | ws = workspace_create(NULL, prev_workspace_name); | ||
107 | } | 112 | } |
108 | ws_name = strdup(argv[3]); | ||
109 | ws = workspace_by_number(ws_name); | ||
110 | } else { | 113 | } else { |
111 | ws_name = join_args(argv + 2, argc - 2); | 114 | char *ws_name = NULL; |
112 | ws = workspace_by_name(ws_name); | 115 | if (strcasecmp(argv[2], "number") == 0) { |
113 | } | 116 | // move "container to workspace number x" |
114 | 117 | if (argc < 4) { | |
115 | if (!no_auto_back_and_forth && config->auto_back_and_forth && | 118 | return cmd_results_new(CMD_INVALID, "move", |
116 | prev_workspace_name) { | 119 | expected_syntax); |
117 | // auto back and forth move | 120 | } |
118 | if (old_ws->name && strcmp(old_ws->name, ws_name) == 0) { | 121 | ws_name = strdup(argv[3]); |
119 | // if target workspace is the current one | 122 | ws = workspace_by_number(ws_name); |
120 | free(ws_name); | 123 | } else { |
121 | ws_name = strdup(prev_workspace_name); | 124 | ws_name = join_args(argv + 2, argc - 2); |
122 | ws = workspace_by_name(ws_name); | 125 | ws = workspace_by_name(ws_name); |
123 | } | 126 | } |
124 | } | ||
125 | 127 | ||
126 | if (!ws) { | 128 | if (!no_auto_back_and_forth && config->auto_back_and_forth && |
127 | if (strcasecmp(argv[2], "back_and_forth") == 0) { | 129 | prev_workspace_name) { |
128 | if (prev_workspace_name) { | 130 | // auto back and forth move |
129 | ws = workspace_create(NULL, prev_workspace_name); | 131 | if (old_ws->name && strcmp(old_ws->name, ws_name) == 0) { |
132 | // if target workspace is the current one | ||
133 | free(ws_name); | ||
134 | ws_name = strdup(prev_workspace_name); | ||
135 | ws = workspace_by_name(ws_name); | ||
130 | } | 136 | } |
131 | } | 137 | } |
132 | ws = workspace_create(NULL, ws_name); | ||
133 | } | ||
134 | free(ws_name); | ||
135 | 138 | ||
139 | if (!ws) { | ||
140 | ws = workspace_create(NULL, ws_name); | ||
141 | } | ||
142 | free(ws_name); | ||
143 | } | ||
136 | destination = seat_get_focus_inactive(config->handler_context.seat, ws); | 144 | destination = seat_get_focus_inactive(config->handler_context.seat, ws); |
137 | } else if (strcasecmp(argv[1], "output") == 0) { | 145 | } else if (strcasecmp(argv[1], "output") == 0) { |
138 | struct sway_container *source = container_parent(current, C_OUTPUT); | 146 | struct sway_container *source = container_parent(current, C_OUTPUT); |