]> git.sur5r.net Git - i3/i3/blob - testcases/t/173-regress-focus-assign.t
Merge branch 'fix-fullscreen-enternotify'
[i3/i3] / testcases / t / 173-regress-focus-assign.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 # !NO_I3_INSTANCE! will prevent complete-run.pl from starting i3
4 #
5 # Regression: Checks if focus is stolen when a window is managed which is
6 # assigned to an invisible workspace
7 #
8 use i3test;
9 use X11::XCB qw(:all);
10 use X11::XCB::Connection;
11 use v5.10;
12
13 my $x = X11::XCB::Connection->new;
14
15 # TODO: move to X11::XCB
16 sub set_wm_class {
17     my ($id, $class, $instance) = @_;
18
19     # Add a _NET_WM_STRUT_PARTIAL hint
20     my $atomname = $x->atom(name => 'WM_CLASS');
21     my $atomtype = $x->atom(name => 'STRING');
22
23     $x->change_property(
24         PROP_MODE_REPLACE,
25         $id,
26         $atomname->id,
27         $atomtype->id,
28         8,
29         length($class) + length($instance) + 2,
30         "$instance\x00$class\x00"
31     );
32 }
33
34
35 #####################################################################
36 # start a window and see that it does not get assigned with an empty config
37 #####################################################################
38
39 my $config = <<EOT;
40 # i3 config file (v4)
41 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
42 assign "special" → targetws
43 EOT
44
45 my $pid = launch_with_config($config);
46
47 my $tmp = fresh_workspace;
48
49 ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
50 ok(get_ws($tmp)->{focused}, 'current workspace focused');
51
52 my $window = $x->root->create_child(
53     class => WINDOW_CLASS_INPUT_OUTPUT,
54     rect => [ 0, 0, 30, 30 ],
55     background_color => '#0000ff',
56 );
57
58 $window->_create;
59 set_wm_class($window->id, 'special', 'special');
60 $window->name('special window');
61 $window->map;
62 sleep 0.25;
63
64
65 ok(@{get_ws_content($tmp)} == 0, 'special window not on current workspace');
66 ok(@{get_ws_content('targetws')} == 1, 'special window on targetws');
67 ok(get_ws($tmp)->{focused}, 'current workspace still focused');
68
69 #####################################################################
70 # the same test, but with a floating window
71 #####################################################################
72
73 $window = $x->root->create_child(
74     class => WINDOW_CLASS_INPUT_OUTPUT,
75     rect => [ 0, 0, 30, 30 ],
76     background_color => '#0000ff',
77     window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_UTILITY'),
78 );
79
80 $window->_create;
81 set_wm_class($window->id, 'special', 'special');
82 $window->name('special window');
83 $window->map;
84 sleep 0.25;
85
86
87 ok(@{get_ws_content($tmp)} == 0, 'special window not on current workspace');
88 ok(@{get_ws_content('targetws')} == 1, 'special window on targetws');
89 ok(get_ws($tmp)->{focused}, 'current workspace still focused');
90
91 exit_gracefully($pid);
92
93 $window->destroy;
94
95 done_testing;