Skip floating cons in focus (child|parent) and stop them from being split
Focusing child from a workspace should now skip over the floating con and go directly to its child. Focusing parent from that grandchild should leave the workspace focused again.
This commit is contained in:
parent
b9885ff21e
commit
c406b4c2fe
26
src/tree.c
26
src/tree.c
@ -356,6 +356,10 @@ void tree_split(Con *con, orientation_t orientation) {
|
|||||||
con->layout = (orientation == HORIZ) ? L_SPLITH : L_SPLITV;
|
con->layout = (orientation == HORIZ) ? L_SPLITH : L_SPLITV;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
else if (con->type == CT_FLOATING_CON) {
|
||||||
|
DLOG("Floating containers can't be split.\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Con *parent = con->parent;
|
Con *parent = con->parent;
|
||||||
|
|
||||||
@ -396,9 +400,15 @@ void tree_split(Con *con, orientation_t orientation) {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
bool level_up(void) {
|
bool level_up(void) {
|
||||||
|
/* Skip over floating containers and go directly to the grandparent
|
||||||
|
* (which should always be a workspace) */
|
||||||
|
if (focused->parent->type == CT_FLOATING_CON) {
|
||||||
|
con_focus(focused->parent->parent);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/* We can focus up to the workspace, but not any higher in the tree */
|
/* We can focus up to the workspace, but not any higher in the tree */
|
||||||
if ((focused->parent->type != CT_CON &&
|
if ((focused->parent->type != CT_CON &&
|
||||||
focused->parent->type != CT_FLOATING_CON &&
|
|
||||||
focused->parent->type != CT_WORKSPACE) ||
|
focused->parent->type != CT_WORKSPACE) ||
|
||||||
focused->type == CT_WORKSPACE) {
|
focused->type == CT_WORKSPACE) {
|
||||||
ELOG("'focus parent': Focus is already on the workspace, cannot go higher than that.\n");
|
ELOG("'focus parent': Focus is already on the workspace, cannot go higher than that.\n");
|
||||||
@ -416,9 +426,21 @@ bool level_down(void) {
|
|||||||
/* Go down the focus stack of the current node */
|
/* Go down the focus stack of the current node */
|
||||||
Con *next = TAILQ_FIRST(&(focused->focus_head));
|
Con *next = TAILQ_FIRST(&(focused->focus_head));
|
||||||
if (next == TAILQ_END(&(focused->focus_head))) {
|
if (next == TAILQ_END(&(focused->focus_head))) {
|
||||||
printf("cannot go down\n");
|
DLOG("cannot go down\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
else if (next->type == CT_FLOATING_CON) {
|
||||||
|
/* Floating cons shouldn't be directly focused; try immediately
|
||||||
|
* going to the grandchild of the focused con. */
|
||||||
|
Con *child = TAILQ_FIRST(&(next->focus_head));
|
||||||
|
if (child == TAILQ_END(&(next->focus_head))) {
|
||||||
|
DLOG("cannot go down\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
next = TAILQ_FIRST(&(next->focus_head));
|
||||||
|
}
|
||||||
|
|
||||||
con_focus(next);
|
con_focus(next);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -197,4 +197,23 @@ cmd 'focus right';
|
|||||||
|
|
||||||
is($x->input_focus, $second->id, 'focus on second container');
|
is($x->input_focus, $second->id, 'focus on second container');
|
||||||
|
|
||||||
|
#############################################################################
|
||||||
|
# 7: verify that focusing the parent of a window inside a floating con goes
|
||||||
|
# up to the grandparent (workspace) and that focusing child from the ws
|
||||||
|
# goes back down to the child of the floating con
|
||||||
|
#############################################################################
|
||||||
|
|
||||||
|
$tmp = fresh_workspace;
|
||||||
|
|
||||||
|
my $tiled = open_window;
|
||||||
|
my $floating = open_floating_window;
|
||||||
|
is($x->input_focus, $floating->id, 'floating window focused');
|
||||||
|
|
||||||
|
cmd 'focus parent';
|
||||||
|
|
||||||
|
is(get_ws($tmp)->{focused}, 1, 'workspace is focused');
|
||||||
|
cmd 'focus child';
|
||||||
|
|
||||||
|
is($x->input_focus, $floating->id, 'floating window focused');
|
||||||
|
|
||||||
done_testing;
|
done_testing;
|
||||||
|
Loading…
Reference in New Issue
Block a user