Refactor tree_next
- Makes `tree_next` not recursive. - Adds `focus next|prev [sibling]` command. See (1.) and (2.) in https://github.com/i3/i3/issues/2587#issuecomment-378505551 (Issue also requests move command, not implemented here). - Directional focus command now supports command criteria. Wrapping is not implemented inside a floating container. This was also true before the refactor so I am not changing it here.
This commit is contained in:
committed by
Orestis Floros
parent
f402f45702
commit
bbc4c99c72
@ -35,9 +35,13 @@ my $bottom = open_window;
|
||||
# end sleeping for half a second to make sure i3 reacted
|
||||
#
|
||||
sub focus_after {
|
||||
my $msg = shift;
|
||||
my ($msg, $win_id) = @_;
|
||||
|
||||
cmd $msg;
|
||||
if (defined($win_id)) {
|
||||
cmd "[id=$win_id] $msg";
|
||||
} else {
|
||||
cmd $msg;
|
||||
}
|
||||
return $x->input_focus;
|
||||
}
|
||||
|
||||
@ -50,6 +54,14 @@ is($focus, $mid->id, "Middle window focused");
|
||||
$focus = focus_after('focus up');
|
||||
is($focus, $top->id, "Top window focused");
|
||||
|
||||
# Same using command criteria
|
||||
$focus = focus_after('focus up', $bottom->id);
|
||||
is($focus, $mid->id, "Middle window focused");
|
||||
|
||||
cmd 'focus down';
|
||||
$focus = focus_after('focus up', $mid->id);
|
||||
is($focus, $top->id, "Top window focused");
|
||||
|
||||
#####################################################################
|
||||
# Test focus wrapping
|
||||
#####################################################################
|
||||
|
72
testcases/t/307-focus-next-prev.t
Normal file
72
testcases/t/307-focus-next-prev.t
Normal file
@ -0,0 +1,72 @@
|
||||
#!perl
|
||||
# vim:ts=4:sw=4:expandtab
|
||||
#
|
||||
# Please read the following documents before working on tests:
|
||||
# • https://build.i3wm.org/docs/testsuite.html
|
||||
# (or docs/testsuite)
|
||||
#
|
||||
# • https://build.i3wm.org/docs/lib-i3test.html
|
||||
# (alternatively: perldoc ./testcases/lib/i3test.pm)
|
||||
#
|
||||
# • https://build.i3wm.org/docs/ipc.html
|
||||
# (or docs/ipc)
|
||||
#
|
||||
# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
|
||||
# (unless you are already familiar with Perl)
|
||||
#
|
||||
# Test focus next|prev
|
||||
# Ticket: #2587
|
||||
use i3test;
|
||||
|
||||
cmp_tree(
|
||||
msg => "cmd 'prev' selects leaf 1/2",
|
||||
layout_before => 'S[a b] V[c d* T[e f g]]',
|
||||
layout_after => 'S[a b] V[c* d T[e f g]]',
|
||||
cb => sub {
|
||||
cmd 'focus prev';
|
||||
});
|
||||
|
||||
cmp_tree(
|
||||
msg => "cmd 'prev' selects leaf 2/2",
|
||||
layout_before => 'S[a b] V[c* d T[e f g]]',
|
||||
layout_after => 'S[a b*] V[c d T[e f g]]',
|
||||
cb => sub {
|
||||
# c* -> V -> b*
|
||||
cmd 'focus parent, focus prev';
|
||||
});
|
||||
|
||||
cmp_tree(
|
||||
msg => "cmd 'prev sibling' selects leaf again",
|
||||
layout_before => 'S[a b] V[c d* T[e f g]]',
|
||||
layout_after => 'S[a b] V[c* d T[e f g]]',
|
||||
cb => sub {
|
||||
cmd 'focus prev sibling';
|
||||
});
|
||||
|
||||
cmp_tree(
|
||||
msg => "cmd 'next' selects leaf",
|
||||
# Notice that g is the last to open before focus moves to d*
|
||||
layout_before => 'S[a b] V[c d* T[e f g]]',
|
||||
layout_after => 'S[a b] V[c d T[e f g*]]',
|
||||
cb => sub {
|
||||
cmd 'focus next';
|
||||
});
|
||||
|
||||
cmp_tree(
|
||||
msg => "cmd 'next sibling' selects parent 1/2",
|
||||
layout_before => 'S[a b] V[c d* T[e f g]]',
|
||||
layout_after => 'S[a b] V[c d T*[e f g]]',
|
||||
cb => sub {
|
||||
cmd 'focus next sibling';
|
||||
});
|
||||
|
||||
cmp_tree(
|
||||
msg => "cmd 'next sibling' selects parent 2/2",
|
||||
layout_before => 'S[a b*] V[c d T[e f g]]',
|
||||
layout_after => 'S[a b] V*[c d T[e f g]]',
|
||||
cb => sub {
|
||||
# b* -> S* -> V*
|
||||
cmd 'focus parent, focus next sibling';
|
||||
});
|
||||
|
||||
done_testing;
|
Reference in New Issue
Block a user