fix workspace splits

This commit is contained in:
Tony Crisci 2018-04-02 15:40:40 -04:00
parent 357a4401fa
commit d070244362
2 changed files with 23 additions and 40 deletions

View file

@ -25,29 +25,8 @@ static struct cmd_results *_do_split(int argc, char **argv, int layout) {
} }
struct sway_container *focused = config->handler_context.current_container; struct sway_container *focused = config->handler_context.current_container;
struct sway_container *parent = container_split(focused, layout);
// TODO floating: dont split arrange_windows(parent, -1, -1);
/* Case that focus is on an workspace with 0/1 children.change its layout */
if (focused->type == C_WORKSPACE && focused->children->length <= 1) {
wlr_log(L_DEBUG, "changing workspace layout");
container_set_layout(focused, layout);
} else if (focused->type != C_WORKSPACE &&
focused->parent->children->length == 1) {
/* Case of no siblings. change parent layout */
wlr_log(L_DEBUG, "changing container layout");
container_set_layout(focused->parent, layout);
} else {
// regular case where new split container is build around focused
// container or in case of workspace, container inherits its children
wlr_log(L_DEBUG,
"Adding new container around current focused container");
wlr_log(L_INFO, "FOCUSED SIZE: %.f %.f",
focused->width, focused->height);
struct sway_container *parent = container_split(focused, layout);
arrange_windows(parent, -1, -1);
}
// TODO borders: update borders // TODO borders: update borders

View file

@ -405,7 +405,12 @@ void apply_vert_layout(struct sway_container *container,
wlr_log(L_DEBUG, wlr_log(L_DEBUG,
"Calculating arrangement for %p:%d (will scale %f by %f)", "Calculating arrangement for %p:%d (will scale %f by %f)",
child, child->type, height, scale); child, child->type, height, scale);
view_set_position(child->sway_view, x, child_y); if (child->type == C_VIEW) {
view_set_position(child->sway_view, x, child_y);
} else {
child->x = x;
child->y = child_y;
}
if (i == end - 1) { if (i == end - 1) {
double remaining_height = y + height - child_y; double remaining_height = y + height - child_y;
@ -691,34 +696,33 @@ struct sway_container *container_split(struct sway_container *child,
wlr_log(L_DEBUG, "creating container %p around %p", cont, child); wlr_log(L_DEBUG, "creating container %p around %p", cont, child);
cont->prev_layout = L_NONE; cont->prev_layout = L_NONE;
cont->layout = layout;
cont->width = child->width; cont->width = child->width;
cont->height = child->height; cont->height = child->height;
cont->x = child->x; cont->x = child->x;
cont->y = child->y; cont->y = child->y;
/* Container inherits all of workspaces children, layout and whatnot */
if (child->type == C_WORKSPACE) { if (child->type == C_WORKSPACE) {
struct sway_seat *seat = sway_input_manager_get_default_seat(input_manager);
struct sway_container *workspace = child; struct sway_container *workspace = child;
// reorder focus bool set_focus = (sway_seat_get_focus(seat) == workspace);
int i;
for (i = 0; i < workspace->children->length; ++i) { while (workspace->children->length) {
((struct sway_container *)workspace->children->items[i])->parent = struct sway_container *ws_child = workspace->children->items[0];
cont; container_remove_child(ws_child);
container_add_child(cont, ws_child);
} }
// Swap children
list_t *tmp_list = workspace->children;
workspace->children = cont->children;
cont->children = tmp_list;
// add container to workspace chidren
container_add_child(workspace, cont); container_add_child(workspace, cont);
// give them proper layouts container_set_layout(workspace, layout);
cont->layout = workspace->workspace_layout;
cont->prev_layout = workspace->prev_layout; if (set_focus) {
} else { // Or is built around container sway_seat_set_focus(seat, cont);
}
} else {
cont->layout = layout;
container_replace_child(child, cont); container_replace_child(child, cont);
container_add_child(cont, child); container_add_child(cont, child);
} }
return cont; return cont;
} }