sway

i3-compatible Wayland compositor
git clone https://git.awy.one/sway
Log | Files | Refs | README | LICENSE

commit 03e4a97dbe5391cfaa7e9d3f1da86fa0a5fa4b4f
parent f22c9379530ebaacefcc337714cc2a5fe0db8902
Author: minus <minus@mnus.de>
Date:   Tue, 25 Aug 2015 18:25:36 +0200

added "move container to workspace"

makes the previous commit actually testable

Diffstat:
Minclude/layout.h | 1+
Msway/commands.c | 25++++++++++++++++++++++++-
Msway/layout.c | 15+++++++++++++++
3 files changed, 40 insertions(+), 1 deletion(-)

diff --git a/include/layout.h b/include/layout.h @@ -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); diff --git a/sway/commands.c b/sway/commands.c @@ -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; } diff --git a/sway/layout.c b/sway/layout.c @@ -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;