mirror of
https://github.com/swaywm/sway.git
synced 2026-04-22 06:46:27 -04:00
Add move [container|window] [to] con_id <con_id>
This commit is contained in:
parent
471099d82e
commit
788ebe76aa
4 changed files with 35 additions and 2 deletions
|
|
@ -373,4 +373,9 @@ bool container_is_sticky_or_child(struct sway_container *con);
|
||||||
*/
|
*/
|
||||||
int container_squash(struct sway_container *con);
|
int container_squash(struct sway_container *con);
|
||||||
|
|
||||||
|
bool container_has_con_id(struct sway_container *con, size_t *con_id);
|
||||||
|
|
||||||
|
/** Returns a container with the given con_id */
|
||||||
|
struct sway_container *container_find_con_id(size_t *con_id);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,8 @@ static const char expected_syntax[] =
|
||||||
"Expected 'move <left|right|up|down> <[px] px>' or "
|
"Expected 'move <left|right|up|down> <[px] px>' or "
|
||||||
"'move [--no-auto-back-and-forth] <container|window> [to] workspace <name>' or "
|
"'move [--no-auto-back-and-forth] <container|window> [to] workspace <name>' or "
|
||||||
"'move <container|window|workspace> [to] output <name|direction>' or "
|
"'move <container|window|workspace> [to] output <name|direction>' or "
|
||||||
"'move <container|window> [to] mark <mark>'";
|
"'move <container|window> [to] mark <mark>' or "
|
||||||
|
"'move <container|window> [to] con_id <con_id>'";
|
||||||
|
|
||||||
static struct sway_output *output_in_direction(const char *direction_string,
|
static struct sway_output *output_in_direction(const char *direction_string,
|
||||||
struct sway_output *reference, int ref_lx, int ref_ly) {
|
struct sway_output *reference, int ref_lx, int ref_ly) {
|
||||||
|
|
@ -520,6 +521,14 @@ static struct cmd_results *cmd_move_container(bool no_auto_back_and_forth,
|
||||||
"Mark '%s' not found", argv[1]);
|
"Mark '%s' not found", argv[1]);
|
||||||
}
|
}
|
||||||
destination = &dest_con->node;
|
destination = &dest_con->node;
|
||||||
|
} else if (strcasecmp(argv[0], "con_id") == 0) {
|
||||||
|
size_t con_id = atoi(argv[1]);
|
||||||
|
struct sway_container *dest_con = container_find_con_id(&con_id);
|
||||||
|
if (dest_con == NULL) {
|
||||||
|
return cmd_results_new(CMD_FAILURE,
|
||||||
|
"No container with con_id '%s' found", argv[1]);
|
||||||
|
}
|
||||||
|
destination = &dest_con->node;
|
||||||
} else {
|
} else {
|
||||||
return cmd_results_new(CMD_INVALID, expected_syntax);
|
return cmd_results_new(CMD_INVALID, expected_syntax);
|
||||||
}
|
}
|
||||||
|
|
@ -982,6 +991,7 @@ static const char expected_full_syntax[] = "Expected "
|
||||||
" <name>|next|prev|next_on_output|prev_on_output|current|(number <num>)'"
|
" <name>|next|prev|next_on_output|prev_on_output|current|(number <num>)'"
|
||||||
" or 'move [window|container] [to] output <name/id>|left|right|up|down'"
|
" or 'move [window|container] [to] output <name/id>|left|right|up|down'"
|
||||||
" or 'move [window|container] [to] mark <mark>'"
|
" or 'move [window|container] [to] mark <mark>'"
|
||||||
|
" or 'move [window|container] [to] con_id <con_id>'"
|
||||||
" or 'move [window|container] [to] scratchpad'"
|
" or 'move [window|container] [to] scratchpad'"
|
||||||
" or 'move workspace to [output] <name/id>|left|right|up|down'"
|
" or 'move workspace to [output] <name/id>|left|right|up|down'"
|
||||||
" or 'move [window|container] [to] [absolute] position <x> [px] <y> [px]'"
|
" or 'move [window|container] [to] [absolute] position <x> [px] <y> [px]'"
|
||||||
|
|
@ -1040,7 +1050,8 @@ struct cmd_results *cmd_move(int argc, char **argv) {
|
||||||
|
|
||||||
if (strcasecmp(argv[0], "workspace") == 0 ||
|
if (strcasecmp(argv[0], "workspace") == 0 ||
|
||||||
strcasecmp(argv[0], "output") == 0 ||
|
strcasecmp(argv[0], "output") == 0 ||
|
||||||
strcasecmp(argv[0], "mark") == 0) {
|
strcasecmp(argv[0], "mark") == 0 ||
|
||||||
|
strcasecmp(argv[0], "con_id") == 0) {
|
||||||
return cmd_move_container(no_auto_back_and_forth, argc, argv);
|
return cmd_move_container(no_auto_back_and_forth, argc, argv);
|
||||||
} else if (strcasecmp(argv[0], "scratchpad") == 0) {
|
} else if (strcasecmp(argv[0], "scratchpad") == 0) {
|
||||||
return cmd_move_to_scratchpad();
|
return cmd_move_to_scratchpad();
|
||||||
|
|
|
||||||
|
|
@ -231,6 +231,10 @@ set|plus|minus|toggle <amount>
|
||||||
*move* [container|window] [to] mark <mark>
|
*move* [container|window] [to] mark <mark>
|
||||||
Moves the focused container to the specified mark.
|
Moves the focused container to the specified mark.
|
||||||
|
|
||||||
|
*move* [container|window] [to] con_id <con_id>
|
||||||
|
Moves the focused container to become a direct descendant of the specified
|
||||||
|
con_id. If the destination can't have descendants, the command does nothing.
|
||||||
|
|
||||||
*move* [--no-auto-back-and-forth] [container|window] [to] workspace [number] <name>
|
*move* [--no-auto-back-and-forth] [container|window] [to] workspace [number] <name>
|
||||||
Moves the focused container to the specified workspace. The string _number_
|
Moves the focused container to the specified workspace. The string _number_
|
||||||
is optional and is used to match a workspace with the same number, even if
|
is optional and is used to match a workspace with the same number, even if
|
||||||
|
|
|
||||||
|
|
@ -1821,3 +1821,16 @@ int container_squash(struct sway_container *con) {
|
||||||
}
|
}
|
||||||
return change;
|
return change;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool container_has_con_id(struct sway_container *con, size_t *con_id) {
|
||||||
|
return con->node.id == *con_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool find_by_con_id(struct sway_container *con, void *data) {
|
||||||
|
size_t *con_id = data;
|
||||||
|
return con->node.id == *con_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct sway_container *container_find_con_id(size_t *con_id) {
|
||||||
|
return root_find_container(find_by_con_id, con_id);
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue