2 # vim:ts=4:sw=4:expandtab
4 # Please read the following documents before working on tests:
5 # • https://build.i3wm.org/docs/testsuite.html
8 # • https://build.i3wm.org/docs/lib-i3test.html
9 # (alternatively: perldoc ./testcases/lib/i3test.pm)
11 # • https://build.i3wm.org/docs/ipc.html
14 # • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
15 # (unless you are already familiar with Perl)
17 # Test the 'no_focus' directive.
19 use i3test i3_autostart => 0;
21 my ($config, $pid, $ws, $first, $second, $focused);
23 #####################################################################
24 # 1: open a window and check that it takes focus
25 #####################################################################
29 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
32 $pid = launch_with_config($config);
34 $ws = fresh_workspace;
36 $focused = get_focused($ws);
37 $second = open_window;
40 isnt(get_focused($ws), $focused, 'focus has changed');
41 is($x->input_focus, $second->id, 'input focus has changed');
43 exit_gracefully($pid);
45 #####################################################################
46 # 2: open a window matched by a no_focus directive and check that
47 # it doesn't take focus
48 #####################################################################
52 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
54 no_focus [instance=notme]
57 $pid = launch_with_config($config);
59 $ws = fresh_workspace;
61 $focused = get_focused($ws);
62 $second = open_window(wm_class => 'notme');
65 is(get_focused($ws), $focused, 'focus has not changed');
66 is($x->input_focus, $first->id, 'input focus has not changed');
68 exit_gracefully($pid);
70 #####################################################################
71 ## 3: no_focus doesn't affect the first window opened on a workspace
72 #####################################################################
76 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
78 no_focus [instance=focusme]
81 $pid = launch_with_config($config);
83 $ws = fresh_workspace;
84 $focused = get_focused($ws);
85 $first = open_window(wm_class => 'focusme');
88 is($x->input_focus, $first->id, 'input focus has changed');
90 exit_gracefully($pid);
92 #####################################################################