]> git.sur5r.net Git - i3/i3/blob - testcases/t/242-no-focus.t
5b507a78d98d2c2f988e5fead0de339773aed7f7
[i3/i3] / testcases / t / 242-no-focus.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 #
4 # Please read the following documents before working on tests:
5 # • https://build.i3wm.org/docs/testsuite.html
6 #   (or docs/testsuite)
7 #
8 # • https://build.i3wm.org/docs/lib-i3test.html
9 #   (alternatively: perldoc ./testcases/lib/i3test.pm)
10 #
11 # • https://build.i3wm.org/docs/ipc.html
12 #   (or docs/ipc)
13 #
14 # • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
15 #   (unless you are already familiar with Perl)
16 #
17 # Test the 'no_focus' directive.
18 # Ticket: #1416
19 use i3test i3_autostart => 0;
20
21 my ($config, $pid, $ws, $first, $second, $focused);
22
23 #####################################################################
24 # 1: open a window and check that it takes focus
25 #####################################################################
26
27 $config = <<EOT;
28 # i3 config file (v4)
29 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
30 EOT
31
32 $pid = launch_with_config($config);
33
34 $ws = fresh_workspace;
35 $first = open_window;
36 $focused = get_focused($ws);
37 $second = open_window;
38
39 sync_with_i3;
40 isnt(get_focused($ws), $focused, 'focus has changed');
41 is($x->input_focus, $second->id, 'input focus has changed');
42
43 exit_gracefully($pid);
44
45 #####################################################################
46 # 2: open a window matched by a no_focus directive and check that
47 #    it doesn't take focus
48 #####################################################################
49
50 $config = <<EOT;
51 # i3 config file (v4)
52 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
53
54 no_focus [instance=notme]
55 EOT
56
57 $pid = launch_with_config($config);
58
59 $ws = fresh_workspace;
60 $first = open_window;
61 $focused = get_focused($ws);
62 $second = open_window(wm_class => 'notme');
63
64 sync_with_i3;
65 is(get_focused($ws), $focused, 'focus has not changed');
66 is($x->input_focus, $first->id, 'input focus has not changed');
67
68 exit_gracefully($pid);
69
70 #####################################################################
71 ## 3: no_focus doesn't affect the first window opened on a workspace
72 #####################################################################
73
74 $config = <<EOT;
75 # i3 config file (v4)
76 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
77
78 no_focus [instance=focusme]
79 EOT
80
81 $pid = launch_with_config($config);
82
83 $ws = fresh_workspace;
84 $focused = get_focused($ws);
85 $first = open_window(wm_class => 'focusme');
86
87 sync_with_i3;
88 is($x->input_focus, $first->id, 'input focus has changed');
89
90 exit_gracefully($pid);
91
92 #####################################################################
93
94 done_testing;