Fix the percentages when moving containers.
This commit is contained in:
parent
07eb20851f
commit
432563d6e7
|
@ -509,10 +509,14 @@ void con_move_to_workspace(Con *con, Con *workspace) {
|
||||||
con_detach(con);
|
con_detach(con);
|
||||||
con_attach(con, next, false);
|
con_attach(con, next, false);
|
||||||
|
|
||||||
/* 6: keep focus on the current workspace */
|
/* 6: fix the percentages */
|
||||||
|
con_fix_percent(parent);
|
||||||
|
con_fix_percent(next);
|
||||||
|
|
||||||
|
/* 7: keep focus on the current workspace */
|
||||||
con_focus(focus_next);
|
con_focus(focus_next);
|
||||||
|
|
||||||
/* 7: check if the parent container is empty now and close it */
|
/* 8: check if the parent container is empty now and close it */
|
||||||
if (parent->type != CT_WORKSPACE &&
|
if (parent->type != CT_WORKSPACE &&
|
||||||
TAILQ_EMPTY(&(parent->nodes_head))) {
|
TAILQ_EMPTY(&(parent->nodes_head))) {
|
||||||
DLOG("Closing empty parent container\n");
|
DLOG("Closing empty parent container\n");
|
||||||
|
|
20
src/tree.c
20
src/tree.c
|
@ -411,10 +411,14 @@ void tree_move(char way, orientation_t orientation) {
|
||||||
/* 4: switch workspace orientation */
|
/* 4: switch workspace orientation */
|
||||||
parent->orientation = orientation;
|
parent->orientation = orientation;
|
||||||
|
|
||||||
/* 4: attach the new split container to the workspace */
|
/* 5: attach the new split container to the workspace */
|
||||||
DLOG("Attaching new split to ws\n");
|
DLOG("Attaching new split to ws\n");
|
||||||
con_attach(new, parent, false);
|
con_attach(new, parent, false);
|
||||||
|
|
||||||
|
/* 6: fix the percentages */
|
||||||
|
con_fix_percent(new);
|
||||||
|
con_fix_percent(parent);
|
||||||
|
|
||||||
if (old_focused)
|
if (old_focused)
|
||||||
con_focus(old_focused);
|
con_focus(old_focused);
|
||||||
|
|
||||||
|
@ -452,6 +456,7 @@ void tree_move(char way, orientation_t orientation) {
|
||||||
}
|
}
|
||||||
|
|
||||||
con_detach(focused);
|
con_detach(focused);
|
||||||
|
con_fix_percent(focused->parent);
|
||||||
focused->parent = next->parent;
|
focused->parent = next->parent;
|
||||||
|
|
||||||
TAILQ_INSERT_AFTER(&(next->parent->nodes_head), next, focused, nodes);
|
TAILQ_INSERT_AFTER(&(next->parent->nodes_head), next, focused, nodes);
|
||||||
|
@ -478,6 +483,7 @@ void tree_move(char way, orientation_t orientation) {
|
||||||
}
|
}
|
||||||
|
|
||||||
con_detach(focused);
|
con_detach(focused);
|
||||||
|
con_fix_percent(focused);
|
||||||
focused->parent = next->parent;
|
focused->parent = next->parent;
|
||||||
|
|
||||||
/* After going down in the tree, we insert the container *after*
|
/* After going down in the tree, we insert the container *after*
|
||||||
|
@ -491,6 +497,14 @@ void tree_move(char way, orientation_t orientation) {
|
||||||
/* TODO: don’t influence focus handling? */
|
/* TODO: don’t influence focus handling? */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* fix the percentages in the container we moved to */
|
||||||
|
int children = con_num_children(next->parent);
|
||||||
|
if (children == 1)
|
||||||
|
focused->percent = 1.0;
|
||||||
|
else
|
||||||
|
focused->percent = 1.0 / (children - 1);
|
||||||
|
con_fix_percent(next->parent);
|
||||||
|
|
||||||
/* We need to call con_focus() to fix the focus stack "above" the container
|
/* We need to call con_focus() to fix the focus stack "above" the container
|
||||||
* we just inserted the focused container into (otherwise, the parent
|
* we just inserted the focused container into (otherwise, the parent
|
||||||
* container(s) would still point to the old container(s)). */
|
* container(s) would still point to the old container(s)). */
|
||||||
|
@ -500,6 +514,10 @@ void tree_move(char way, orientation_t orientation) {
|
||||||
DLOG("Old container empty after moving. Let's close it\n");
|
DLOG("Old container empty after moving. Let's close it\n");
|
||||||
tree_close(old_parent, false, false);
|
tree_close(old_parent, false, false);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
/* fix the percentages in the container we moved from */
|
||||||
|
con_fix_percent(old_parent);
|
||||||
|
}
|
||||||
|
|
||||||
tree_flatten(croot);
|
tree_flatten(croot);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue