void move_container_to(swayc_t* container, swayc_t* destination) { if (container == destination || swayc_is_parent_of(container, destination)) { return; } swayc_t *parent = remove_child(container); // reset container geometry container->width = container->height = 0; // Send to new destination if (container->is_floating) { add_floating(swayc_active_workspace_for(destination), container); } else if (destination->type == C_WORKSPACE) { add_child(destination, container); } else { add_sibling(destination, container); } // Destroy old container if we need to parent = destroy_container(parent); // Refocus swayc_t *op1 = swayc_parent_by_type(destination, C_OUTPUT); swayc_t *op2 = swayc_parent_by_type(parent, C_OUTPUT); set_focused_container(get_focused_view(op1)); arrange_windows(op1, -1, -1); update_visibility(op1); if (op1 != op2) { set_focused_container(get_focused_view(op2)); arrange_windows(op2, -1, -1); update_visibility(op2); } }
void move_container_to(swayc_t* container, swayc_t* destination) { if (container == destination || swayc_is_parent_of(container, destination)) { return; } swayc_t *parent = remove_child(container); // Send to new destination if (container->is_floating) { swayc_t *ws = swayc_active_workspace_for(destination); add_floating(ws, container); // If the workspace only has one child after adding one, it // means that the workspace was just initialized. if (ws->children->length + ws->floating->length == 1) { ipc_event_workspace(NULL, ws, "init"); } } else if (destination->type == C_WORKSPACE) { // reset container geometry container->width = container->height = 0; add_child(destination, container); // If the workspace only has one child after adding one, it // means that the workspace was just initialized. if (destination->children->length + destination->floating->length == 1) { ipc_event_workspace(NULL, destination, "init"); } } else { // reset container geometry container->width = container->height = 0; add_sibling(destination, container); } // Destroy old container if we need to parent = destroy_container(parent); // Refocus swayc_t *op1 = swayc_parent_by_type(destination, C_OUTPUT); swayc_t *op2 = swayc_parent_by_type(parent, C_OUTPUT); set_focused_container(get_focused_view(op1)); arrange_windows(op1, -1, -1); update_visibility(op1); if (op1 != op2) { set_focused_container(get_focused_view(op2)); arrange_windows(op2, -1, -1); update_visibility(op2); } }
void move_workspace_to(swayc_t* workspace, swayc_t* destination) { if (workspace == destination || swayc_is_parent_of(workspace, destination)) { return; } swayc_t *src_op = remove_child(workspace); // reset container geometry workspace->width = workspace->height = 0; add_child(destination, workspace); // Refocus destination (change to new workspace) set_focused_container(get_focused_view(workspace)); arrange_windows(destination, -1, -1); update_visibility(destination); // make sure source output has a workspace if (src_op->children->length == 0) { char *ws_name = workspace_next_name(src_op->name); swayc_t *ws = new_workspace(src_op, ws_name); ws->is_focused = true; free(ws_name); } set_focused_container(get_focused_view(src_op)); update_visibility(src_op); }