*/
bool con_is_split(Con *con);
+/**
+ * Returns true if this node has regular or floating children.
+ *
+ */
+bool con_has_children(Con *con);
+
/**
* Returns true if this node accepts a window (if the node swallows windows,
* it might already have swallowed enough and cannot hold any more).
* when criteria wasn't specified and we don't have any window focused. */
if ((!match_is_empty(current_match) && TAILQ_EMPTY(&owindows)) ||
(match_is_empty(current_match) && focused->type == CT_WORKSPACE &&
- con_is_leaf(focused))) {
+ !con_has_children(focused))) {
ysuccess(false);
return;
}
return;
}
else if (match_is_empty(current_match) && focused->type == CT_WORKSPACE &&
- con_is_leaf(focused)) {
+ !con_has_children(focused)) {
ysuccess(false);
return;
}
* when criteria wasn't specified and we don't have any window focused. */
if ((!match_is_empty(current_match) && TAILQ_EMPTY(&owindows)) ||
(match_is_empty(current_match) && focused->type == CT_WORKSPACE &&
- con_is_leaf(focused))) {
+ !con_has_children(focused))) {
ysuccess(false);
return;
}
return TAILQ_EMPTY(&(con->nodes_head));
}
+/**
+ * Returns true if this node has regular or floating children.
+ *
+ */
+bool con_has_children(Con *con) {
+ return (!con_is_leaf(con) || !TAILQ_EMPTY(&(con->floating_head)));
+}
+
/*
* Returns true if a container should be considered split.
*
}
if (con->type == CT_WORKSPACE) {
- con = workspace_encapsulate(con);
- if (con == NULL) {
- ELOG("Workspace failed to move its contents into a container!\n");
- return;
- }
-
/* Re-parent all of the old workspace's floating windows. */
Con *child;
while (!TAILQ_EMPTY(&(source_ws->floating_head))) {
child = TAILQ_FIRST(&(source_ws->floating_head));
con_move_to_workspace(child, workspace, true, true);
}
+
+ /* If there are no non-floating children, ignore the workspace. */
+ if (con_is_leaf(con))
+ return;
+
+ con = workspace_encapsulate(con);
+ if (con == NULL) {
+ ELOG("Workspace failed to move its contents into a container!\n");
+ return;
+ }
}
/* Save the current workspace. So we can call workspace_show() by the end
is_num_children($tmp2, 1, 'one container on second workspace');
is(@{$ws->{floating_nodes}}, 2, 'two floating nodes on second workspace');
+###################################################################
+# same as the above, but with only floating children
+###################################################################
+$tmp2 = get_unused_workspace();
+$tmp = fresh_workspace();
+cmd 'open';
+cmd 'floating toggle';
+
+$ws = get_ws($tmp);
+is_num_children($tmp, 0, 'no regular nodes on first workspace');
+is(@{$ws->{floating_nodes}}, 1, 'one floating node on first workspace');
+
+cmd 'focus parent';
+cmd "move workspace $tmp2";
+
+$ws = get_ws($tmp2);
+is_num_children($tmp2, 0, 'no regular nodes on second workspace');
+is(@{$ws->{floating_nodes}}, 1, 'one floating node on second workspace');
+
done_testing;