]> git.sur5r.net Git - i3/i3/blob - testcases/t/40-focus-lost.t
Merge branch 'fix-focus-ipc'
[i3/i3] / testcases / t / 40-focus-lost.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 # Regression: Check if the focus stays the same when switching the layout
4 # bug introduced by 77d0d42ed2d7ac8cafe267c92b35a81c1b9491eb
5 use i3test;
6 use X11::XCB qw(:all);
7 use Time::HiRes qw(sleep);
8
9 BEGIN {
10     use_ok('X11::XCB::Window');
11 }
12
13 my $i3 = i3(get_socket_path());
14 my $x = X11::XCB::Connection->new;
15
16 sub check_order {
17     my ($msg) = @_;
18
19     my @ws = @{$i3->get_workspaces->recv};
20     my @nums = map { $_->{num} } grep { defined($_->{num}) } @ws;
21     my @sorted = sort @nums;
22
23     cmp_deeply(\@nums, \@sorted, $msg);
24 }
25
26 my $tmp = fresh_workspace;
27
28 my $left = open_standard_window($x);
29 sleep 0.25;
30 my $mid = open_standard_window($x);
31 sleep 0.25;
32 my $right = open_standard_window($x);
33 sleep 0.25;
34
35 diag("left = " . $left->id . ", mid = " . $mid->id . ", right = " . $right->id);
36
37 is($x->input_focus, $right->id, 'Right window focused');
38
39 cmd 'focus left';
40
41 is($x->input_focus, $mid->id, 'Mid window focused');
42
43 cmd 'layout stacked';
44
45 is($x->input_focus, $mid->id, 'Mid window focused');
46
47 done_testing;