Implement 'prev', extend testcase
This commit is contained in:
parent
d8307f4b4a
commit
145ebc7584
|
@ -100,6 +100,9 @@ focus { return TOK_FOCUS; }
|
||||||
move { return TOK_MOVE; }
|
move { return TOK_MOVE; }
|
||||||
open { return TOK_OPEN; }
|
open { return TOK_OPEN; }
|
||||||
next { return TOK_NEXT; }
|
next { return TOK_NEXT; }
|
||||||
|
prev { return TOK_PREV; }
|
||||||
|
horizontal { return TOK_HORIZONTAL; }
|
||||||
|
vertical { return TOK_VERTICAL; }
|
||||||
|
|
||||||
class { BEGIN(WANT_QSTRING); return TOK_CLASS; }
|
class { BEGIN(WANT_QSTRING); return TOK_CLASS; }
|
||||||
id { BEGIN(WANT_QSTRING); return TOK_ID; }
|
id { BEGIN(WANT_QSTRING); return TOK_ID; }
|
||||||
|
|
|
@ -112,6 +112,9 @@ void parse_cmd(const char *new) {
|
||||||
%token TOK_MOVE "move"
|
%token TOK_MOVE "move"
|
||||||
%token TOK_OPEN "open"
|
%token TOK_OPEN "open"
|
||||||
%token TOK_NEXT "next"
|
%token TOK_NEXT "next"
|
||||||
|
%token TOK_PREV "prev"
|
||||||
|
%token TOK_HORIZONTAL "horizontal"
|
||||||
|
%token TOK_VERTICAL "vertical"
|
||||||
|
|
||||||
%token TOK_CLASS "class"
|
%token TOK_CLASS "class"
|
||||||
%token TOK_ID "id"
|
%token TOK_ID "id"
|
||||||
|
@ -252,6 +255,7 @@ operation:
|
||||||
| open
|
| open
|
||||||
| fullscreen
|
| fullscreen
|
||||||
| next
|
| next
|
||||||
|
| prev
|
||||||
;
|
;
|
||||||
|
|
||||||
exec:
|
exec:
|
||||||
|
@ -345,9 +349,17 @@ next:
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
direction:
|
prev:
|
||||||
'h' { $<chr>$ = 'h'; }
|
TOK_PREV WHITESPACE direction
|
||||||
| 'horizontal' { $<chr>$ = 'h'; }
|
{
|
||||||
| 'v' { $<chr>$ = 'v'; }
|
printf("should select prev window in direction %c\n", $<chr>3);
|
||||||
| 'vertical' { $<chr>$ = 'v'; }
|
tree_next('p', ($<chr>3 == 'v' ? VERT : HORIZ));
|
||||||
|
}
|
||||||
|
;
|
||||||
|
|
||||||
|
direction:
|
||||||
|
TOK_HORIZONTAL { $<chr>$ = 'h'; }
|
||||||
|
| 'h' { $<chr>$ = 'h'; }
|
||||||
|
| TOK_VERTICAL { $<chr>$ = 'v'; }
|
||||||
|
| 'v' { $<chr>$ = 'v'; }
|
||||||
;
|
;
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#
|
#
|
||||||
# Tests focus switching (next/prev)
|
# Tests focus switching (next/prev)
|
||||||
#
|
#
|
||||||
use i3test tests => 4;
|
use i3test tests => 13;
|
||||||
use X11::XCB qw(:all);
|
use X11::XCB qw(:all);
|
||||||
use v5.10;
|
use v5.10;
|
||||||
|
|
||||||
|
@ -31,22 +31,60 @@ is($focus->[0], $old_focused, 'focus did not change with only one con');
|
||||||
######################################################################
|
######################################################################
|
||||||
# Open another container, verify that 'next h' switches
|
# Open another container, verify that 'next h' switches
|
||||||
######################################################################
|
######################################################################
|
||||||
$i3->command('open')->recv;
|
my $left = $old_focused;
|
||||||
|
|
||||||
|
$i3->command('open')->recv;
|
||||||
($nodes, $focus) = get_ws_content($tmp);
|
($nodes, $focus) = get_ws_content($tmp);
|
||||||
isnt($old_focused, $focus->[0], 'new container is focused');
|
isnt($old_focused, $focus->[0], 'new container is focused');
|
||||||
$old_focused = $focus->[0];
|
my $mid = $focus->[0];
|
||||||
|
|
||||||
|
$i3->command('open')->recv;
|
||||||
|
($nodes, $focus) = get_ws_content($tmp);
|
||||||
|
isnt($old_focused, $focus->[0], 'new container is focused');
|
||||||
|
my $right = $focus->[0];
|
||||||
|
|
||||||
$i3->command('next h')->recv;
|
$i3->command('next h')->recv;
|
||||||
|
|
||||||
($nodes, $focus) = get_ws_content($tmp);
|
($nodes, $focus) = get_ws_content($tmp);
|
||||||
isnt($focus->[0], $old_focused, 'focus did change');
|
isnt($focus->[0], $right, 'focus did change');
|
||||||
|
is($focus->[0], $left, 'left container focused (wrapping)');
|
||||||
|
|
||||||
|
$i3->command('next h')->recv;
|
||||||
|
($nodes, $focus) = get_ws_content($tmp);
|
||||||
|
is($focus->[0], $mid, 'middle container focused');
|
||||||
|
|
||||||
|
$i3->command('next h')->recv;
|
||||||
|
($nodes, $focus) = get_ws_content($tmp);
|
||||||
|
is($focus->[0], $right, 'right container focused');
|
||||||
|
|
||||||
|
$i3->command('prev h')->recv;
|
||||||
|
($nodes, $focus) = get_ws_content($tmp);
|
||||||
|
is($focus->[0], $mid, 'middle container focused');
|
||||||
|
|
||||||
|
$i3->command('prev h')->recv;
|
||||||
|
($nodes, $focus) = get_ws_content($tmp);
|
||||||
|
is($focus->[0], $left, 'left container focused');
|
||||||
|
|
||||||
|
$i3->command('prev h')->recv;
|
||||||
|
($nodes, $focus) = get_ws_content($tmp);
|
||||||
|
is($focus->[0], $right, 'right container focused');
|
||||||
|
|
||||||
|
|
||||||
|
######################################################################
|
||||||
|
# Test synonyms (horizontal/vertical instead of h/v)
|
||||||
|
######################################################################
|
||||||
|
|
||||||
|
$i3->command('prev horizontal')->recv;
|
||||||
|
($nodes, $focus) = get_ws_content($tmp);
|
||||||
|
is($focus->[0], $mid, 'middle container focused');
|
||||||
|
|
||||||
|
$i3->command('next horizontal')->recv;
|
||||||
|
($nodes, $focus) = get_ws_content($tmp);
|
||||||
|
is($focus->[0], $right, 'right container focused');
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# TODO: extend this test-case:
|
# TODO: extend this test-case (as soon as splitting is implemented):
|
||||||
# - implement prev
|
|
||||||
# - wrapping (no horizontal switch possible, goes level-up)
|
# - wrapping (no horizontal switch possible, goes level-up)
|
||||||
# - going level-up "manually"
|
# - going level-up "manually"
|
||||||
# - different synonyms (horizontal/vertical)
|
|
||||||
|
|
||||||
diag( "Testing i3, Perl $], $^X" );
|
diag( "Testing i3, Perl $], $^X" );
|
||||||
|
|
Loading…
Reference in New Issue