aboutsummaryrefslogtreecommitdiffstats
path: root/sway/commands/move.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands/move.c')
-rw-r--r--sway/commands/move.c197
1 files changed, 106 insertions, 91 deletions
diff --git a/sway/commands/move.c b/sway/commands/move.c
index f8f89f18..69ed06c0 100644
--- a/sway/commands/move.c
+++ b/sway/commands/move.c
@@ -113,8 +113,8 @@ static void container_move_to_container_from_direction(
113 struct sway_container *container, struct sway_container *destination, 113 struct sway_container *container, struct sway_container *destination,
114 enum wlr_direction move_dir) { 114 enum wlr_direction move_dir) {
115 if (destination->view) { 115 if (destination->view) {
116 if (destination->parent == container->parent && 116 if (destination->pending.parent == container->pending.parent &&
117 destination->workspace == container->workspace) { 117 destination->pending.workspace == container->pending.workspace) {
118 sway_log(SWAY_DEBUG, "Swapping siblings"); 118 sway_log(SWAY_DEBUG, "Swapping siblings");
119 list_t *siblings = container_get_siblings(container); 119 list_t *siblings = container_get_siblings(container);
120 int container_index = list_find(siblings, container); 120 int container_index = list_find(siblings, container);
@@ -126,28 +126,28 @@ static void container_move_to_container_from_direction(
126 int offset = 126 int offset =
127 move_dir == WLR_DIRECTION_LEFT || move_dir == WLR_DIRECTION_UP; 127 move_dir == WLR_DIRECTION_LEFT || move_dir == WLR_DIRECTION_UP;
128 int index = container_sibling_index(destination) + offset; 128 int index = container_sibling_index(destination) + offset;
129 if (destination->parent) { 129 if (destination->pending.parent) {
130 container_insert_child(destination->parent, container, index); 130 container_insert_child(destination->pending.parent, container, index);
131 } else { 131 } else {
132 workspace_insert_tiling(destination->workspace, 132 workspace_insert_tiling(destination->pending.workspace,
133 container, index); 133 container, index);
134 } 134 }
135 container->width = container->height = 0; 135 container->pending.width = container->pending.height = 0;
136 container->width_fraction = container->height_fraction = 0; 136 container->width_fraction = container->height_fraction = 0;
137 workspace_squash(destination->workspace); 137 workspace_squash(destination->pending.workspace);
138 } 138 }
139 return; 139 return;
140 } 140 }
141 141
142 if (is_parallel(destination->layout, move_dir)) { 142 if (is_parallel(destination->pending.layout, move_dir)) {
143 sway_log(SWAY_DEBUG, "Reparenting container (parallel)"); 143 sway_log(SWAY_DEBUG, "Reparenting container (parallel)");
144 int index = 144 int index =
145 move_dir == WLR_DIRECTION_RIGHT || move_dir == WLR_DIRECTION_DOWN ? 145 move_dir == WLR_DIRECTION_RIGHT || move_dir == WLR_DIRECTION_DOWN ?
146 0 : destination->children->length; 146 0 : destination->pending.children->length;
147 container_insert_child(destination, container, index); 147 container_insert_child(destination, container, index);
148 container->width = container->height = 0; 148 container->pending.width = container->pending.height = 0;
149 container->width_fraction = container->height_fraction = 0; 149 container->width_fraction = container->height_fraction = 0;
150 workspace_squash(destination->workspace); 150 workspace_squash(destination->pending.workspace);
151 return; 151 return;
152 } 152 }
153 153
@@ -168,7 +168,7 @@ static void container_move_to_container_from_direction(
168static void container_move_to_workspace_from_direction( 168static void container_move_to_workspace_from_direction(
169 struct sway_container *container, struct sway_workspace *workspace, 169 struct sway_container *container, struct sway_workspace *workspace,
170 enum wlr_direction move_dir) { 170 enum wlr_direction move_dir) {
171 container->width = container->height = 0; 171 container->pending.width = container->pending.height = 0;
172 container->width_fraction = container->height_fraction = 0; 172 container->width_fraction = container->height_fraction = 0;
173 173
174 if (is_parallel(workspace->layout, move_dir)) { 174 if (is_parallel(workspace->layout, move_dir)) {
@@ -188,8 +188,8 @@ static void container_move_to_workspace_from_direction(
188 workspace_add_tiling(workspace, container); 188 workspace_add_tiling(workspace, container);
189 return; 189 return;
190 } 190 }
191 while (focus_inactive->parent) { 191 while (focus_inactive->pending.parent) {
192 focus_inactive = focus_inactive->parent; 192 focus_inactive = focus_inactive->pending.parent;
193 } 193 }
194 container_move_to_container_from_direction(container, focus_inactive, 194 container_move_to_container_from_direction(container, focus_inactive,
195 move_dir); 195 move_dir);
@@ -197,25 +197,33 @@ static void container_move_to_workspace_from_direction(
197 197
198static void container_move_to_workspace(struct sway_container *container, 198static void container_move_to_workspace(struct sway_container *container,
199 struct sway_workspace *workspace) { 199 struct sway_workspace *workspace) {
200 if (container->workspace == workspace) { 200 if (container->pending.workspace == workspace) {
201 return; 201 return;
202 } 202 }
203 struct sway_workspace *old_workspace = container->workspace; 203 struct sway_workspace *old_workspace = container->pending.workspace;
204 if (container_is_floating(container)) { 204 if (container_is_floating(container)) {
205 struct sway_output *old_output = container->workspace->output; 205 struct sway_output *old_output = container->pending.workspace->output;
206 container_detach(container); 206 container_detach(container);
207 workspace_add_floating(workspace, container); 207 workspace_add_floating(workspace, container);
208 container_handle_fullscreen_reparent(container); 208 container_handle_fullscreen_reparent(container);
209 // If changing output, center it within the workspace 209 // If changing output, adjust the coordinates of the window.
210 if (old_output != workspace->output && !container->fullscreen_mode) { 210 if (old_output != workspace->output && !container->pending.fullscreen_mode) {
211 container_floating_move_to_center(container); 211 struct wlr_box workspace_box, old_workspace_box;
212 workspace_get_box(workspace, &workspace_box);
213 workspace_get_box(old_workspace, &old_workspace_box);
214 floating_fix_coordinates(container, &old_workspace_box, &workspace_box);
215 if (container->scratchpad && workspace->output) {
216 struct wlr_box output_box;
217 output_get_box(workspace->output, &output_box);
218 container->transform = workspace_box;
219 }
212 } 220 }
213 } else { 221 } else {
214 container_detach(container); 222 container_detach(container);
215 if (workspace_is_empty(workspace) && container->children) { 223 if (workspace_is_empty(workspace) && container->pending.children) {
216 workspace_unwrap_children(workspace, container); 224 workspace_unwrap_children(workspace, container);
217 } else { 225 } else {
218 container->width = container->height = 0; 226 container->pending.width = container->pending.height = 0;
219 container->width_fraction = container->height_fraction = 0; 227 container->width_fraction = container->height_fraction = 0;
220 workspace_add_tiling(workspace, container); 228 workspace_add_tiling(workspace, container);
221 } 229 }
@@ -237,13 +245,13 @@ static void container_move_to_container(struct sway_container *container,
237 return; 245 return;
238 } 246 }
239 if (container_is_floating(container)) { 247 if (container_is_floating(container)) {
240 container_move_to_workspace(container, destination->workspace); 248 container_move_to_workspace(container, destination->pending.workspace);
241 return; 249 return;
242 } 250 }
243 struct sway_workspace *old_workspace = container->workspace; 251 struct sway_workspace *old_workspace = container->pending.workspace;
244 252
245 container_detach(container); 253 container_detach(container);
246 container->width = container->height = 0; 254 container->pending.width = container->pending.height = 0;
247 container->width_fraction = container->height_fraction = 0; 255 container->width_fraction = container->height_fraction = 0;
248 256
249 if (destination->view) { 257 if (destination->view) {
@@ -256,12 +264,12 @@ static void container_move_to_container(struct sway_container *container,
256 ipc_event_window(container, "move"); 264 ipc_event_window(container, "move");
257 } 265 }
258 266
259 if (destination->workspace) { 267 if (destination->pending.workspace) {
260 workspace_focus_fullscreen(destination->workspace); 268 workspace_focus_fullscreen(destination->pending.workspace);
261 workspace_detect_urgent(destination->workspace); 269 workspace_detect_urgent(destination->pending.workspace);
262 } 270 }
263 271
264 if (old_workspace && old_workspace != destination->workspace) { 272 if (old_workspace && old_workspace != destination->pending.workspace) {
265 workspace_detect_urgent(old_workspace); 273 workspace_detect_urgent(old_workspace);
266 } 274 }
267} 275}
@@ -275,7 +283,7 @@ static bool container_move_to_next_output(struct sway_container *container,
275 if (!sway_assert(ws, "Expected output to have a workspace")) { 283 if (!sway_assert(ws, "Expected output to have a workspace")) {
276 return false; 284 return false;
277 } 285 }
278 switch (container->fullscreen_mode) { 286 switch (container->pending.fullscreen_mode) {
279 case FULLSCREEN_NONE: 287 case FULLSCREEN_NONE:
280 container_move_to_workspace_from_direction(container, ws, move_dir); 288 container_move_to_workspace_from_direction(container, ws, move_dir);
281 return true; 289 return true;
@@ -293,12 +301,12 @@ static bool container_move_to_next_output(struct sway_container *container,
293static bool container_move_in_direction(struct sway_container *container, 301static bool container_move_in_direction(struct sway_container *container,
294 enum wlr_direction move_dir) { 302 enum wlr_direction move_dir) {
295 // If moving a fullscreen view, only consider outputs 303 // If moving a fullscreen view, only consider outputs
296 switch (container->fullscreen_mode) { 304 switch (container->pending.fullscreen_mode) {
297 case FULLSCREEN_NONE: 305 case FULLSCREEN_NONE:
298 break; 306 break;
299 case FULLSCREEN_WORKSPACE: 307 case FULLSCREEN_WORKSPACE:
300 return container_move_to_next_output(container, 308 return container_move_to_next_output(container,
301 container->workspace->output, move_dir); 309 container->pending.workspace->output, move_dir);
302 case FULLSCREEN_GLOBAL: 310 case FULLSCREEN_GLOBAL:
303 return false; 311 return false;
304 } 312 }
@@ -317,26 +325,26 @@ static bool container_move_in_direction(struct sway_container *container,
317 while (!ancestor) { 325 while (!ancestor) {
318 // Don't allow containers to move out of their 326 // Don't allow containers to move out of their
319 // fullscreen or floating parent 327 // fullscreen or floating parent
320 if (current->fullscreen_mode || container_is_floating(current)) { 328 if (current->pending.fullscreen_mode || container_is_floating(current)) {
321 return false; 329 return false;
322 } 330 }
323 331
324 enum sway_container_layout parent_layout = container_parent_layout(current); 332 enum sway_container_layout parent_layout = container_parent_layout(current);
325 if (!is_parallel(parent_layout, move_dir)) { 333 if (!is_parallel(parent_layout, move_dir)) {
326 if (!current->parent) { 334 if (!current->pending.parent) {
327 // No parallel parent, so we reorient the workspace 335 // No parallel parent, so we reorient the workspace
328 current = workspace_wrap_children(current->workspace); 336 current = workspace_wrap_children(current->pending.workspace);
329 current->workspace->layout = 337 current->pending.workspace->layout =
330 move_dir == WLR_DIRECTION_LEFT || 338 move_dir == WLR_DIRECTION_LEFT ||
331 move_dir == WLR_DIRECTION_RIGHT ? 339 move_dir == WLR_DIRECTION_RIGHT ?
332 L_HORIZ : L_VERT; 340 L_HORIZ : L_VERT;
333 container->height = container->width = 0; 341 container->pending.height = container->pending.width = 0;
334 container->height_fraction = container->width_fraction = 0; 342 container->height_fraction = container->width_fraction = 0;
335 workspace_update_representation(current->workspace); 343 workspace_update_representation(current->pending.workspace);
336 wrapped = true; 344 wrapped = true;
337 } else { 345 } else {
338 // Keep looking for a parallel parent 346 // Keep looking for a parallel parent
339 current = current->parent; 347 current = current->pending.parent;
340 } 348 }
341 continue; 349 continue;
342 } 350 }
@@ -356,14 +364,14 @@ static bool container_move_in_direction(struct sway_container *container,
356 container_move_to_container_from_direction(container, 364 container_move_to_container_from_direction(container,
357 target, move_dir); 365 target, move_dir);
358 return true; 366 return true;
359 } else if (!container->parent) { 367 } else if (!container->pending.parent) {
360 // Container is at workspace level so we move it to the 368 // Container is at workspace level so we move it to the
361 // next workspace if possible 369 // next workspace if possible
362 return container_move_to_next_output(container, 370 return container_move_to_next_output(container,
363 current->workspace->output, move_dir); 371 current->pending.workspace->output, move_dir);
364 } else { 372 } else {
365 // Container has escaped its immediate parallel parent 373 // Container has escaped its immediate parallel parent
366 current = current->parent; 374 current = current->pending.parent;
367 continue; 375 continue;
368 } 376 }
369 } 377 }
@@ -377,31 +385,31 @@ static bool container_move_in_direction(struct sway_container *container,
377 container_move_to_container_from_direction(container, 385 container_move_to_container_from_direction(container,
378 target, move_dir); 386 target, move_dir);
379 return true; 387 return true;
380 } else if (!wrapped && !container->parent->parent && 388 } else if (!wrapped && !container->pending.parent->pending.parent &&
381 container->parent->children->length == 1) { 389 container->pending.parent->pending.children->length == 1) {
382 // Treat singleton children as if they are at workspace level like i3 390 // Treat singleton children as if they are at workspace level like i3
383 // https://github.com/i3/i3/blob/1d9160f2d247dbaa83fb62f02fd7041dec767fc2/src/move.c#L367 391 // https://github.com/i3/i3/blob/1d9160f2d247dbaa83fb62f02fd7041dec767fc2/src/move.c#L367
384 return container_move_to_next_output(container, 392 return container_move_to_next_output(container,
385 ancestor->workspace->output, move_dir); 393 ancestor->pending.workspace->output, move_dir);
386 } else { 394 } else {
387 // Container will be promoted 395 // Container will be promoted
388 struct sway_container *old_parent = container->parent; 396 struct sway_container *old_parent = container->pending.parent;
389 if (ancestor->parent) { 397 if (ancestor->pending.parent) {
390 // Container will move in with its parent 398 // Container will move in with its parent
391 container_insert_child(ancestor->parent, container, 399 container_insert_child(ancestor->pending.parent, container,
392 index + (offs < 0 ? 0 : 1)); 400 index + (offs < 0 ? 0 : 1));
393 } else { 401 } else {
394 // Container will move to workspace level, 402 // Container will move to workspace level,
395 // may be re-split by workspace_layout 403 // may be re-split by workspace_layout
396 workspace_insert_tiling(ancestor->workspace, container, 404 workspace_insert_tiling(ancestor->pending.workspace, container,
397 index + (offs < 0 ? 0 : 1)); 405 index + (offs < 0 ? 0 : 1));
398 } 406 }
399 ancestor->height = ancestor->width = 0; 407 ancestor->pending.height = ancestor->pending.width = 0;
400 ancestor->height_fraction = ancestor->width_fraction = 0; 408 ancestor->height_fraction = ancestor->width_fraction = 0;
401 if (old_parent) { 409 if (old_parent) {
402 container_reap_empty(old_parent); 410 container_reap_empty(old_parent);
403 } 411 }
404 workspace_squash(container->workspace); 412 workspace_squash(container->pending.workspace);
405 return true; 413 return true;
406 } 414 }
407} 415}
@@ -427,14 +435,14 @@ static struct cmd_results *cmd_move_container(bool no_auto_back_and_forth,
427 container = workspace_wrap_children(workspace); 435 container = workspace_wrap_children(workspace);
428 } 436 }
429 437
430 if (container->fullscreen_mode == FULLSCREEN_GLOBAL) { 438 if (container->pending.fullscreen_mode == FULLSCREEN_GLOBAL) {
431 return cmd_results_new(CMD_FAILURE, 439 return cmd_results_new(CMD_FAILURE,
432 "Can't move fullscreen global container"); 440 "Can't move fullscreen global container");
433 } 441 }
434 442
435 struct sway_seat *seat = config->handler_context.seat; 443 struct sway_seat *seat = config->handler_context.seat;
436 struct sway_container *old_parent = container->parent; 444 struct sway_container *old_parent = container->pending.parent;
437 struct sway_workspace *old_ws = container->workspace; 445 struct sway_workspace *old_ws = container->pending.workspace;
438 struct sway_output *old_output = old_ws ? old_ws->output : NULL; 446 struct sway_output *old_output = old_ws ? old_ws->output : NULL;
439 struct sway_node *destination = NULL; 447 struct sway_node *destination = NULL;
440 448
@@ -462,7 +470,7 @@ static struct cmd_results *cmd_move_container(bool no_auto_back_and_forth,
462 if (strcasecmp(argv[1], "number") == 0) { 470 if (strcasecmp(argv[1], "number") == 0) {
463 // move [window|container] [to] "workspace number x" 471 // move [window|container] [to] "workspace number x"
464 if (argc < 3) { 472 if (argc < 3) {
465 return cmd_results_new(CMD_INVALID, expected_syntax); 473 return cmd_results_new(CMD_INVALID, "%s", expected_syntax);
466 } 474 }
467 if (!isdigit(argv[2][0])) { 475 if (!isdigit(argv[2][0])) {
468 return cmd_results_new(CMD_INVALID, 476 return cmd_results_new(CMD_INVALID,
@@ -508,7 +516,7 @@ static struct cmd_results *cmd_move_container(bool no_auto_back_and_forth,
508 destination = dst ? &dst->node : &ws->node; 516 destination = dst ? &dst->node : &ws->node;
509 } else if (strcasecmp(argv[0], "output") == 0) { 517 } else if (strcasecmp(argv[0], "output") == 0) {
510 struct sway_output *new_output = output_in_direction(argv[1], 518 struct sway_output *new_output = output_in_direction(argv[1],
511 old_output, container->x, container->y); 519 old_output, container->pending.x, container->pending.y);
512 if (!new_output) { 520 if (!new_output) {
513 return cmd_results_new(CMD_FAILURE, 521 return cmd_results_new(CMD_FAILURE,
514 "Can't find output with name/direction '%s'", argv[1]); 522 "Can't find output with name/direction '%s'", argv[1]);
@@ -522,7 +530,7 @@ static struct cmd_results *cmd_move_container(bool no_auto_back_and_forth,
522 } 530 }
523 destination = &dest_con->node; 531 destination = &dest_con->node;
524 } else { 532 } else {
525 return cmd_results_new(CMD_INVALID, expected_syntax); 533 return cmd_results_new(CMD_INVALID, "%s", expected_syntax);
526 } 534 }
527 535
528 if (destination->type == N_CONTAINER && 536 if (destination->type == N_CONTAINER &&
@@ -686,6 +694,9 @@ static struct cmd_results *cmd_move_workspace(int argc, char **argv) {
686 arrange_output(old_output); 694 arrange_output(old_output);
687 arrange_output(new_output); 695 arrange_output(new_output);
688 696
697 struct sway_seat *seat = config->handler_context.seat;
698 seat_consider_warp_to_focus(seat);
699
689 return cmd_results_new(CMD_SUCCESS, NULL); 700 return cmd_results_new(CMD_SUCCESS, NULL);
690} 701}
691 702
@@ -706,12 +717,12 @@ static struct cmd_results *cmd_move_in_direction(
706 "Cannot move workspaces in a direction"); 717 "Cannot move workspaces in a direction");
707 } 718 }
708 if (container_is_floating(container)) { 719 if (container_is_floating(container)) {
709 if (container->fullscreen_mode) { 720 if (container->pending.fullscreen_mode) {
710 return cmd_results_new(CMD_FAILURE, 721 return cmd_results_new(CMD_FAILURE,
711 "Cannot move fullscreen floating container"); 722 "Cannot move fullscreen floating container");
712 } 723 }
713 double lx = container->x; 724 double lx = container->pending.x;
714 double ly = container->y; 725 double ly = container->pending.y;
715 switch (direction) { 726 switch (direction) {
716 case WLR_DIRECTION_LEFT: 727 case WLR_DIRECTION_LEFT:
717 lx -= move_amt; 728 lx -= move_amt;
@@ -729,8 +740,8 @@ static struct cmd_results *cmd_move_in_direction(
729 container_floating_move_to(container, lx, ly); 740 container_floating_move_to(container, lx, ly);
730 return cmd_results_new(CMD_SUCCESS, NULL); 741 return cmd_results_new(CMD_SUCCESS, NULL);
731 } 742 }
732 struct sway_workspace *old_ws = container->workspace; 743 struct sway_workspace *old_ws = container->pending.workspace;
733 struct sway_container *old_parent = container->parent; 744 struct sway_container *old_parent = container->pending.parent;
734 745
735 if (!container_move_in_direction(container, direction)) { 746 if (!container_move_in_direction(container, direction)) {
736 // Container didn't move 747 // Container didn't move
@@ -744,7 +755,7 @@ static struct cmd_results *cmd_move_in_direction(
744 workspace_consider_destroy(old_ws); 755 workspace_consider_destroy(old_ws);
745 } 756 }
746 757
747 struct sway_workspace *new_ws = container->workspace; 758 struct sway_workspace *new_ws = container->pending.workspace;
748 759
749 if (root->fullscreen_global) { 760 if (root->fullscreen_global) {
750 arrange_root(); 761 arrange_root();
@@ -781,22 +792,22 @@ static struct cmd_results *cmd_move_to_position_pointer(
781 } 792 }
782 struct wlr_cursor *cursor = seat->cursor->cursor; 793 struct wlr_cursor *cursor = seat->cursor->cursor;
783 /* Determine where to put the window. */ 794 /* Determine where to put the window. */
784 double lx = cursor->x - container->width / 2; 795 double lx = cursor->x - container->pending.width / 2;
785 double ly = cursor->y - container->height / 2; 796 double ly = cursor->y - container->pending.height / 2;
786 797
787 /* Correct target coordinates to be in bounds (on screen). */ 798 /* Correct target coordinates to be in bounds (on screen). */
788 struct wlr_output *output = wlr_output_layout_output_at( 799 struct wlr_output *output = wlr_output_layout_output_at(
789 root->output_layout, cursor->x, cursor->y); 800 root->output_layout, cursor->x, cursor->y);
790 if (output) { 801 if (output) {
791 struct wlr_box *box = 802 struct wlr_box box;
792 wlr_output_layout_get_box(root->output_layout, output); 803 wlr_output_layout_get_box(root->output_layout, output, &box);
793 lx = fmax(lx, box->x); 804 lx = fmax(lx, box.x);
794 ly = fmax(ly, box->y); 805 ly = fmax(ly, box.y);
795 if (lx + container->width > box->x + box->width) { 806 if (lx + container->pending.width > box.x + box.width) {
796 lx = box->x + box->width - container->width; 807 lx = box.x + box.width - container->pending.width;
797 } 808 }
798 if (ly + container->height > box->y + box->height) { 809 if (ly + container->pending.height > box.y + box.height) {
799 ly = box->y + box->height - container->height; 810 ly = box.y + box.height - container->pending.height;
800 } 811 }
801 } 812 }
802 813
@@ -818,7 +829,7 @@ static struct cmd_results *cmd_move_to_position(int argc, char **argv) {
818 } 829 }
819 830
820 if (!argc) { 831 if (!argc) {
821 return cmd_results_new(CMD_INVALID, expected_position_syntax); 832 return cmd_results_new(CMD_INVALID, "%s", expected_position_syntax);
822 } 833 }
823 834
824 bool absolute = false; 835 bool absolute = false;
@@ -828,41 +839,41 @@ static struct cmd_results *cmd_move_to_position(int argc, char **argv) {
828 ++argv; 839 ++argv;
829 } 840 }
830 if (!argc) { 841 if (!argc) {
831 return cmd_results_new(CMD_INVALID, expected_position_syntax); 842 return cmd_results_new(CMD_INVALID, "%s", expected_position_syntax);
832 } 843 }
833 if (strcmp(argv[0], "position") == 0) { 844 if (strcmp(argv[0], "position") == 0) {
834 --argc; 845 --argc;
835 ++argv; 846 ++argv;
836 } 847 }
837 if (!argc) { 848 if (!argc) {
838 return cmd_results_new(CMD_INVALID, expected_position_syntax); 849 return cmd_results_new(CMD_INVALID, "%s", expected_position_syntax);
839 } 850 }
840 if (strcmp(argv[0], "cursor") == 0 || strcmp(argv[0], "mouse") == 0 || 851 if (strcmp(argv[0], "cursor") == 0 || strcmp(argv[0], "mouse") == 0 ||
841 strcmp(argv[0], "pointer") == 0) { 852 strcmp(argv[0], "pointer") == 0) {
842 if (absolute) { 853 if (absolute) {
843 return cmd_results_new(CMD_INVALID, expected_position_syntax); 854 return cmd_results_new(CMD_INVALID, "%s", expected_position_syntax);
844 } 855 }
845 return cmd_move_to_position_pointer(container); 856 return cmd_move_to_position_pointer(container);
846 } else if (strcmp(argv[0], "center") == 0) { 857 } else if (strcmp(argv[0], "center") == 0) {
847 double lx, ly; 858 double lx, ly;
848 if (absolute) { 859 if (absolute) {
849 lx = root->x + (root->width - container->width) / 2; 860 lx = root->x + (root->width - container->pending.width) / 2;
850 ly = root->y + (root->height - container->height) / 2; 861 ly = root->y + (root->height - container->pending.height) / 2;
851 } else { 862 } else {
852 struct sway_workspace *ws = container->workspace; 863 struct sway_workspace *ws = container->pending.workspace;
853 if (!ws) { 864 if (!ws) {
854 struct sway_seat *seat = config->handler_context.seat; 865 struct sway_seat *seat = config->handler_context.seat;
855 ws = seat_get_focused_workspace(seat); 866 ws = seat_get_focused_workspace(seat);
856 } 867 }
857 lx = ws->x + (ws->width - container->width) / 2; 868 lx = ws->x + (ws->width - container->pending.width) / 2;
858 ly = ws->y + (ws->height - container->height) / 2; 869 ly = ws->y + (ws->height - container->pending.height) / 2;
859 } 870 }
860 container_floating_move_to(container, lx, ly); 871 container_floating_move_to(container, lx, ly);
861 return cmd_results_new(CMD_SUCCESS, NULL); 872 return cmd_results_new(CMD_SUCCESS, NULL);
862 } 873 }
863 874
864 if (argc < 2) { 875 if (argc < 2) {
865 return cmd_results_new(CMD_FAILURE, expected_position_syntax); 876 return cmd_results_new(CMD_FAILURE, "%s", expected_position_syntax);
866 } 877 }
867 878
868 struct movement_amount lx = { .amount = 0, .unit = MOVEMENT_UNIT_INVALID }; 879 struct movement_amount lx = { .amount = 0, .unit = MOVEMENT_UNIT_INVALID };
@@ -874,19 +885,23 @@ static struct cmd_results *cmd_move_to_position(int argc, char **argv) {
874 return cmd_results_new(CMD_INVALID, "Invalid x position specified"); 885 return cmd_results_new(CMD_INVALID, "Invalid x position specified");
875 } 886 }
876 887
888 if (argc < 1) {
889 return cmd_results_new(CMD_FAILURE, "%s", expected_position_syntax);
890 }
891
877 struct movement_amount ly = { .amount = 0, .unit = MOVEMENT_UNIT_INVALID }; 892 struct movement_amount ly = { .amount = 0, .unit = MOVEMENT_UNIT_INVALID };
878 // Y direction 893 // Y direction
879 num_consumed_args = parse_movement_amount(argc, argv, &ly); 894 num_consumed_args = parse_movement_amount(argc, argv, &ly);
880 argc -= num_consumed_args; 895 argc -= num_consumed_args;
881 argv += num_consumed_args; 896 argv += num_consumed_args;
882 if (argc > 0) { 897 if (argc > 0) {
883 return cmd_results_new(CMD_INVALID, expected_position_syntax); 898 return cmd_results_new(CMD_INVALID, "%s", expected_position_syntax);
884 } 899 }
885 if (ly.unit == MOVEMENT_UNIT_INVALID) { 900 if (ly.unit == MOVEMENT_UNIT_INVALID) {
886 return cmd_results_new(CMD_INVALID, "Invalid y position specified"); 901 return cmd_results_new(CMD_INVALID, "Invalid y position specified");
887 } 902 }
888 903
889 struct sway_workspace *ws = container->workspace; 904 struct sway_workspace *ws = container->pending.workspace;
890 if (!ws) { 905 if (!ws) {
891 struct sway_seat *seat = config->handler_context.seat; 906 struct sway_seat *seat = config->handler_context.seat;
892 ws = seat_get_focused_workspace(seat); 907 ws = seat_get_focused_workspace(seat);
@@ -960,14 +975,14 @@ static struct cmd_results *cmd_move_to_scratchpad(void) {
960 // If the container is in a floating split container, 975 // If the container is in a floating split container,
961 // operate on the split container instead of the child. 976 // operate on the split container instead of the child.
962 if (container_is_floating_or_child(con)) { 977 if (container_is_floating_or_child(con)) {
963 while (con->parent) { 978 while (con->pending.parent) {
964 con = con->parent; 979 con = con->pending.parent;
965 } 980 }
966 } 981 }
967 982
968 if (!con->scratchpad) { 983 if (!con->scratchpad) {
969 root_scratchpad_add_container(con, NULL); 984 root_scratchpad_add_container(con, NULL);
970 } else if (con->workspace) { 985 } else if (con->pending.workspace) {
971 root_scratchpad_hide(con); 986 root_scratchpad_hide(con);
972 } 987 }
973 return cmd_results_new(CMD_SUCCESS, NULL); 988 return cmd_results_new(CMD_SUCCESS, NULL);
@@ -1026,13 +1041,13 @@ struct cmd_results *cmd_move(int argc, char **argv) {
1026 } 1041 }
1027 1042
1028 if (!argc) { 1043 if (!argc) {
1029 return cmd_results_new(CMD_INVALID, expected_full_syntax); 1044 return cmd_results_new(CMD_INVALID, "%s", expected_full_syntax);
1030 } 1045 }
1031 1046
1032 // Only `move [window|container] [to] workspace` supports 1047 // Only `move [window|container] [to] workspace` supports
1033 // `--no-auto-back-and-forth` so treat others as invalid syntax 1048 // `--no-auto-back-and-forth` so treat others as invalid syntax
1034 if (no_auto_back_and_forth && strcasecmp(argv[0], "workspace") != 0) { 1049 if (no_auto_back_and_forth && strcasecmp(argv[0], "workspace") != 0) {
1035 return cmd_results_new(CMD_INVALID, expected_full_syntax); 1050 return cmd_results_new(CMD_INVALID, "%s", expected_full_syntax);
1036 } 1051 }
1037 1052
1038 if (strcasecmp(argv[0], "workspace") == 0 || 1053 if (strcasecmp(argv[0], "workspace") == 0 ||
@@ -1046,5 +1061,5 @@ struct cmd_results *cmd_move(int argc, char **argv) {
1046 strcasecmp(argv[1], "position") == 0)) { 1061 strcasecmp(argv[1], "position") == 0)) {
1047 return cmd_move_to_position(argc, argv); 1062 return cmd_move_to_position(argc, argv);
1048 } 1063 }
1049 return cmd_results_new(CMD_INVALID, expected_full_syntax); 1064 return cmd_results_new(CMD_INVALID, "%s", expected_full_syntax);
1050} 1065}