mirror of
https://github.com/swaywm/sway.git
synced 2024-11-22 07:51:28 +00:00
added "move container to workspace"
makes the previous commit actually testable
This commit is contained in:
parent
f22c937953
commit
03e4a97dbe
|
@ -22,6 +22,7 @@ swayc_t *remove_child(swayc_t *child);
|
|||
void swap_container(swayc_t *a, swayc_t *b);
|
||||
|
||||
void move_container(swayc_t* container,swayc_t* root,enum movement_direction direction);
|
||||
void move_container_to(swayc_t* container, swayc_t* destination);
|
||||
|
||||
// Layout
|
||||
void update_geometry(swayc_t *view);
|
||||
|
|
|
@ -344,7 +344,7 @@ static bool cmd_focus_follows_mouse(struct sway_config *config, int argc, char *
|
|||
}
|
||||
|
||||
static bool cmd_move(struct sway_config *config, int argc, char **argv) {
|
||||
if (!checkarg(argc, "workspace", EXPECTED_EQUAL_TO, 1)) {
|
||||
if (!checkarg(argc, "workspace", EXPECTED_AT_LEAST, 1)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -358,6 +358,29 @@ static bool cmd_move(struct sway_config *config, int argc, char **argv) {
|
|||
move_container(view,&root_container,MOVE_UP);
|
||||
} else if (strcasecmp(argv[0], "down") == 0) {
|
||||
move_container(view,&root_container,MOVE_DOWN);
|
||||
} else if (strcasecmp(argv[0], "container") == 0 || strcasecmp(argv[0], "window") == 0) {
|
||||
// "move container to workspace x"
|
||||
if (!checkarg(argc, "move container/window", EXPECTED_EQUAL_TO, 4) ||
|
||||
strcasecmp(argv[1], "to") != 0 ||
|
||||
strcasecmp(argv[2], "workspace") != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (view->type != C_CONTAINER && view->type != C_VIEW) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const char *ws_name = argv[3];
|
||||
if (argc == 5) {
|
||||
// move "container to workspace number x"
|
||||
ws_name = argv[4];
|
||||
}
|
||||
|
||||
swayc_t *ws = workspace_by_name(ws_name);
|
||||
if (ws == NULL) {
|
||||
ws = workspace_create(ws_name);
|
||||
}
|
||||
move_container_to(view, ws);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -203,6 +203,21 @@ void move_container(swayc_t *container,swayc_t* root,enum movement_direction dir
|
|||
|
||||
}
|
||||
|
||||
void move_container_to(swayc_t* container, swayc_t* destination) {
|
||||
if (container->parent == destination) {
|
||||
return;
|
||||
}
|
||||
destroy_container(remove_child(container));
|
||||
set_focused_container(get_focused_view(&root_container));
|
||||
if (container->is_floating) {
|
||||
add_floating(destination, container);
|
||||
} else {
|
||||
add_child(destination, container);
|
||||
}
|
||||
update_visibility(container);
|
||||
arrange_windows(&root_container, -1, -1);
|
||||
}
|
||||
|
||||
void update_geometry(swayc_t *container) {
|
||||
if (container->type != C_VIEW) {
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue