]> git.sur5r.net Git - i3/i3/blob - testcases/t/08-focus-stack.t
bugfix: don’t clean up workspace when switching to the same workspace
[i3/i3] / testcases / t / 08-focus-stack.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 # Checks if the focus is correctly restored, when creating a floating client
4 # over an unfocused tiling client and destroying the floating one again.
5
6 use i3test tests => 4;
7 use X11::XCB qw(:all);
8 use Time::HiRes qw(sleep);
9
10 BEGIN {
11     use_ok('X11::XCB::Window') or BAIL_OUT('Could not load X11::XCB::Window');
12 }
13
14 my $x = X11::XCB::Connection->new;
15
16 my $i3 = i3;
17
18 # Switch to the nineth workspace
19 $i3->command('9')->recv;
20
21 my $tiled_left = i3test::open_standard_window($x);
22 my $tiled_right = i3test::open_standard_window($x);
23
24 sleep(0.25);
25
26 $i3->command('ml')->recv;
27
28 # Get input focus before creating the floating window
29 my $focus = $x->input_focus;
30
31 # Create a floating window which is smaller than the minimum enforced size of i3
32 my $window = $x->root->create_child(
33     class => WINDOW_CLASS_INPUT_OUTPUT,
34     rect => [ 1, 1, 30, 30],
35     background_color => '#C0C0C0',
36     type => $x->atom(name => '_NET_WM_WINDOW_TYPE_UTILITY'),
37 );
38
39 isa_ok($window, 'X11::XCB::Window');
40
41 $window->map;
42
43 sleep(0.25);
44 is($x->input_focus, $window->id, 'floating window focused');
45
46 $window->unmap;
47
48 sleep(0.25);
49
50 is($x->input_focus, $focus, 'Focus correctly restored');
51
52 diag( "Testing i3, Perl $], $^X" );