summaryrefslogtreecommitdiff
path: root/sway/commands/move.c
diff options
context:
space:
mode:
Diffstat (limited to 'sway/commands/move.c')
-rw-r--r--sway/commands/move.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/sway/commands/move.c b/sway/commands/move.c
index 7bd1fe3e..69ed06c0 100644
--- a/sway/commands/move.c
+++ b/sway/commands/move.c
@@ -206,9 +206,17 @@ static void container_move_to_workspace(struct sway_container *container,
container_detach(container);
workspace_add_floating(workspace, container);
container_handle_fullscreen_reparent(container);
- // If changing output, center it within the workspace
+ // If changing output, adjust the coordinates of the window.
if (old_output != workspace->output && !container->pending.fullscreen_mode) {
- container_floating_move_to_center(container);
+ struct wlr_box workspace_box, old_workspace_box;
+ workspace_get_box(workspace, &workspace_box);
+ workspace_get_box(old_workspace, &old_workspace_box);
+ floating_fix_coordinates(container, &old_workspace_box, &workspace_box);
+ if (container->scratchpad && workspace->output) {
+ struct wlr_box output_box;
+ output_get_box(workspace->output, &output_box);
+ container->transform = workspace_box;
+ }
}
} else {
container_detach(container);
@@ -462,7 +470,7 @@ static struct cmd_results *cmd_move_container(bool no_auto_back_and_forth,
if (strcasecmp(argv[1], "number") == 0) {
// move [window|container] [to] "workspace number x"
if (argc < 3) {
- return cmd_results_new(CMD_INVALID, expected_syntax);
+ return cmd_results_new(CMD_INVALID, "%s", expected_syntax);
}
if (!isdigit(argv[2][0])) {
return cmd_results_new(CMD_INVALID,
@@ -522,7 +530,7 @@ static struct cmd_results *cmd_move_container(bool no_auto_back_and_forth,
}
destination = &dest_con->node;
} else {
- return cmd_results_new(CMD_INVALID, expected_syntax);
+ return cmd_results_new(CMD_INVALID, "%s", expected_syntax);
}
if (destination->type == N_CONTAINER &&
@@ -821,7 +829,7 @@ static struct cmd_results *cmd_move_to_position(int argc, char **argv) {
}
if (!argc) {
- return cmd_results_new(CMD_INVALID, expected_position_syntax);
+ return cmd_results_new(CMD_INVALID, "%s", expected_position_syntax);
}
bool absolute = false;
@@ -831,19 +839,19 @@ static struct cmd_results *cmd_move_to_position(int argc, char **argv) {
++argv;
}
if (!argc) {
- return cmd_results_new(CMD_INVALID, expected_position_syntax);
+ return cmd_results_new(CMD_INVALID, "%s", expected_position_syntax);
}
if (strcmp(argv[0], "position") == 0) {
--argc;
++argv;
}
if (!argc) {
- return cmd_results_new(CMD_INVALID, expected_position_syntax);
+ return cmd_results_new(CMD_INVALID, "%s", expected_position_syntax);
}
if (strcmp(argv[0], "cursor") == 0 || strcmp(argv[0], "mouse") == 0 ||
strcmp(argv[0], "pointer") == 0) {
if (absolute) {
- return cmd_results_new(CMD_INVALID, expected_position_syntax);
+ return cmd_results_new(CMD_INVALID, "%s", expected_position_syntax);
}
return cmd_move_to_position_pointer(container);
} else if (strcmp(argv[0], "center") == 0) {
@@ -865,7 +873,7 @@ static struct cmd_results *cmd_move_to_position(int argc, char **argv) {
}
if (argc < 2) {
- return cmd_results_new(CMD_FAILURE, expected_position_syntax);
+ return cmd_results_new(CMD_FAILURE, "%s", expected_position_syntax);
}
struct movement_amount lx = { .amount = 0, .unit = MOVEMENT_UNIT_INVALID };
@@ -878,7 +886,7 @@ static struct cmd_results *cmd_move_to_position(int argc, char **argv) {
}
if (argc < 1) {
- return cmd_results_new(CMD_FAILURE, expected_position_syntax);
+ return cmd_results_new(CMD_FAILURE, "%s", expected_position_syntax);
}
struct movement_amount ly = { .amount = 0, .unit = MOVEMENT_UNIT_INVALID };
@@ -887,7 +895,7 @@ static struct cmd_results *cmd_move_to_position(int argc, char **argv) {
argc -= num_consumed_args;
argv += num_consumed_args;
if (argc > 0) {
- return cmd_results_new(CMD_INVALID, expected_position_syntax);
+ return cmd_results_new(CMD_INVALID, "%s", expected_position_syntax);
}
if (ly.unit == MOVEMENT_UNIT_INVALID) {
return cmd_results_new(CMD_INVALID, "Invalid y position specified");
@@ -1033,13 +1041,13 @@ struct cmd_results *cmd_move(int argc, char **argv) {
}
if (!argc) {
- return cmd_results_new(CMD_INVALID, expected_full_syntax);
+ return cmd_results_new(CMD_INVALID, "%s", expected_full_syntax);
}
// Only `move [window|container] [to] workspace` supports
// `--no-auto-back-and-forth` so treat others as invalid syntax
if (no_auto_back_and_forth && strcasecmp(argv[0], "workspace") != 0) {
- return cmd_results_new(CMD_INVALID, expected_full_syntax);
+ return cmd_results_new(CMD_INVALID, "%s", expected_full_syntax);
}
if (strcasecmp(argv[0], "workspace") == 0 ||
@@ -1053,5 +1061,5 @@ struct cmd_results *cmd_move(int argc, char **argv) {
strcasecmp(argv[1], "position") == 0)) {
return cmd_move_to_position(argc, argv);
}
- return cmd_results_new(CMD_INVALID, expected_full_syntax);
+ return cmd_results_new(CMD_INVALID, "%s", expected_full_syntax);
}