aboutsummaryrefslogtreecommitdiff
path: root/sway/tree
diff options
context:
space:
mode:
authorRyan Dwyer <ryandwyer1@gmail.com>2018-08-07 00:03:01 +1000
committerRyan Dwyer <ryandwyer1@gmail.com>2018-08-07 00:03:01 +1000
commitf57a3919cf5ad7c3edbf9e2e19051971a5f2d42f (patch)
tree0f802f51d929d830133c1aada040e051ff79a9e3 /sway/tree
parent0cd418ba42bf7fa9570a2c1c09cea153d3337c7a (diff)
Move workspace moving code out of container_move_to
container_move_to handled moving containers to new parents, as well as moving workspaces to new outputs. This commit removes the workspace-moving code from this function and introduces workspace_move_to_output. Moving workspaces using container_move_to only happened from the move command, so it's been implemented as a static function in that file. Simplifying container_move_to makes it easier for me to fix some issues in #2420.
Diffstat (limited to 'sway/tree')
-rw-r--r--sway/tree/layout.c28
1 files changed, 6 insertions, 22 deletions
diff --git a/sway/tree/layout.c b/sway/tree/layout.c
index 07de9664..9485e675 100644
--- a/sway/tree/layout.c
+++ b/sway/tree/layout.c
@@ -142,6 +142,10 @@ struct sway_container *container_remove_child(struct sway_container *child) {
void container_move_to(struct sway_container *container,
struct sway_container *destination) {
+ if (!sway_assert(container->type == C_CONTAINER ||
+ container->type == C_VIEW, "Expected a container or view")) {
+ return;
+ }
if (container == destination
|| container_has_ancestor(container, destination)) {
return;
@@ -154,11 +158,8 @@ void container_move_to(struct sway_container *container,
container->width = container->height = 0;
container->saved_width = container->saved_height = 0;
- struct sway_container *new_parent, *new_parent_focus;
- struct sway_seat *seat = input_manager_get_default_seat(input_manager);
+ struct sway_container *new_parent;
- // Get the focus of the destination before we change it.
- new_parent_focus = seat_get_focus_inactive(seat, destination);
if (destination->type == C_VIEW) {
new_parent = container_add_sibling(destination, container);
} else {
@@ -167,24 +168,7 @@ void container_move_to(struct sway_container *container,
}
wl_signal_emit(&container->events.reparent, old_parent);
- if (container->type == C_WORKSPACE) {
- // If moving a workspace to a new output, maybe create a new workspace
- // on the previous output
- if (old_parent->children->length == 0) {
- char *ws_name = workspace_next_name(old_parent->name);
- struct sway_container *ws = workspace_create(old_parent, ws_name);
- free(ws_name);
- seat_set_focus(seat, ws);
- }
-
- // Try to remove an empty workspace from the destination output.
- container_reap_empty_recursive(new_parent_focus);
-
- container_sort_workspaces(new_parent);
- seat_set_focus(seat, new_parent);
- workspace_output_raise_priority(container, old_parent, new_parent);
- ipc_event_workspace(NULL, container, "move");
- } else if (container->type == C_VIEW) {
+ if (container->type == C_VIEW) {
ipc_event_window(container, "move");
}
container_notify_subtree_changed(old_parent);