mirror of
https://github.com/swaywm/sway.git
synced 2026-04-22 06:46:27 -04:00
[opt] optimaztion the move
This commit is contained in:
parent
b69d637f7a
commit
57f021a0ec
1 changed files with 11 additions and 15 deletions
|
|
@ -826,24 +826,13 @@ static struct cmd_results *cmd_move_to_position(int argc, char **argv) {
|
||||||
absolute = true;
|
absolute = true;
|
||||||
--argc;
|
--argc;
|
||||||
++argv;
|
++argv;
|
||||||
}
|
}else if (strcmp(argv[0], "position") == 0) {
|
||||||
if (!argc) {
|
|
||||||
return cmd_results_new(CMD_INVALID, expected_position_syntax);
|
|
||||||
}
|
|
||||||
if (strcmp(argv[0], "position") == 0) {
|
|
||||||
--argc;
|
--argc;
|
||||||
++argv;
|
++argv;
|
||||||
}
|
}else if (strcmp(argv[0], "cursor") == 0 || strcmp(argv[0], "mouse") == 0 ||
|
||||||
if (!argc) {
|
|
||||||
return cmd_results_new(CMD_INVALID, expected_position_syntax);
|
|
||||||
}
|
|
||||||
if (strcmp(argv[0], "cursor") == 0 || strcmp(argv[0], "mouse") == 0 ||
|
|
||||||
strcmp(argv[0], "pointer") == 0) {
|
strcmp(argv[0], "pointer") == 0) {
|
||||||
if (absolute) {
|
|
||||||
return cmd_results_new(CMD_INVALID, expected_position_syntax);
|
|
||||||
}
|
|
||||||
return cmd_move_to_position_pointer(container);
|
return cmd_move_to_position_pointer(container);
|
||||||
} else if (strcmp(argv[0], "center") == 0) {
|
}else if(strcmp(argv[0], "centor") == 0) {
|
||||||
double lx, ly;
|
double lx, ly;
|
||||||
if (absolute) {
|
if (absolute) {
|
||||||
lx = root->x + (root->width - container->pending.width) / 2;
|
lx = root->x + (root->width - container->pending.width) / 2;
|
||||||
|
|
@ -859,6 +848,10 @@ static struct cmd_results *cmd_move_to_position(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
container_floating_move_to(container, lx, ly);
|
container_floating_move_to(container, lx, ly);
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!argc) {
|
||||||
|
return cmd_results_new(CMD_INVALID, expected_position_syntax);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc < 2) {
|
if (argc < 2) {
|
||||||
|
|
@ -866,6 +859,7 @@ static struct cmd_results *cmd_move_to_position(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct movement_amount lx = { .amount = 0, .unit = MOVEMENT_UNIT_INVALID };
|
struct movement_amount lx = { .amount = 0, .unit = MOVEMENT_UNIT_INVALID };
|
||||||
|
|
||||||
// X direction
|
// X direction
|
||||||
int num_consumed_args = parse_movement_amount(argc, argv, &lx);
|
int num_consumed_args = parse_movement_amount(argc, argv, &lx);
|
||||||
argc -= num_consumed_args;
|
argc -= num_consumed_args;
|
||||||
|
|
@ -879,10 +873,12 @@ static struct cmd_results *cmd_move_to_position(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct movement_amount ly = { .amount = 0, .unit = MOVEMENT_UNIT_INVALID };
|
struct movement_amount ly = { .amount = 0, .unit = MOVEMENT_UNIT_INVALID };
|
||||||
|
|
||||||
// Y direction
|
// Y direction
|
||||||
num_consumed_args = parse_movement_amount(argc, argv, &ly);
|
num_consumed_args = parse_movement_amount(argc, argv, &ly);
|
||||||
|
|
||||||
argc -= num_consumed_args;
|
argc -= num_consumed_args;
|
||||||
argv += num_consumed_args;
|
|
||||||
if (argc > 0) {
|
if (argc > 0) {
|
||||||
return cmd_results_new(CMD_INVALID, expected_position_syntax);
|
return cmd_results_new(CMD_INVALID, expected_position_syntax);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue