# vim:ts=4:sw=4:expandtab
#
# Please read the following documents before working on tests:
-# • http://build.i3wm.org/docs/testsuite.html
+# • https://build.i3wm.org/docs/testsuite.html
# (or docs/testsuite)
#
-# • http://build.i3wm.org/docs/lib-i3test.html
+# • https://build.i3wm.org/docs/lib-i3test.html
# (alternatively: perldoc ./testcases/lib/i3test.pm)
#
-# • http://build.i3wm.org/docs/ipc.html
+# • https://build.i3wm.org/docs/ipc.html
# (or docs/ipc)
#
# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
use i3test i3_autostart => 0;
use List::Util qw(first);
+my ($config, $pid, $first, $second, $ws1, $ws2);
+
sub send_net_active_window {
- my ($id) = @_;
+ my ($id) = @_;
my $msg = pack "CCSLLLLLLL",
X11::XCB::CLIENT_MESSAGE, # response_type
# check that the urgent flag is set and focus is not lost.
#####################################################################
-my $config = <<EOT;
+$config = <<EOT;
# i3 config file (v4)
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
focus_on_window_activation urgent
EOT
-my $pid = launch_with_config($config);
+$pid = launch_with_config($config);
my $ws = fresh_workspace;
-my $first = open_window;
-my $second = open_window;
+$first = open_window;
+$second = open_window;
send_net_active_window($first->id);
sync_with_i3;
# visible, check that the urgent flag is set and focus is not lost.
#####################################################################
-my $config = <<EOT;
+$config = <<EOT;
# i3 config file (v4)
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
focus_on_window_activation urgent
EOT
-my $pid = launch_with_config($config);
+$pid = launch_with_config($config);
-my $ws1 = fresh_workspace;
-my $first = open_window;
-my $ws2 = fresh_workspace;
-my $second = open_window;
+$ws1 = fresh_workspace;
+$first = open_window;
+$ws2 = fresh_workspace;
+$second = open_window;
send_net_active_window($first->id);
sync_with_i3;
# check that the focus is switched.
#####################################################################
-my $config = <<EOT;
+$config = <<EOT;
# i3 config file (v4)
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
focus_on_window_activation focus
EOT
-my $pid = launch_with_config($config);
+$pid = launch_with_config($config);
-my $ws = fresh_workspace;
-my $first = open_window;
-my $second = open_window;
+$ws = fresh_workspace;
+$first = open_window;
+$second = open_window;
send_net_active_window($first->id);
sync_with_i3;
# visible, check that the focus switched.
#####################################################################
-my $config = <<EOT;
+$config = <<EOT;
# i3 config file (v4)
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
focus_on_window_activation focus
EOT
-my $pid = launch_with_config($config);
+$pid = launch_with_config($config);
-my $ws1 = fresh_workspace;
-my $first = open_window;
-my $ws2 = fresh_workspace;
-my $second = open_window;
+$ws1 = fresh_workspace;
+$first = open_window;
+$ws2 = fresh_workspace;
+$second = open_window;
send_net_active_window($first->id);
sync_with_i3;
# check that nothing happens.
#####################################################################
-my $config = <<EOT;
+$config = <<EOT;
# i3 config file (v4)
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
focus_on_window_activation none
EOT
-my $pid = launch_with_config($config);
+$pid = launch_with_config($config);
-my $ws = fresh_workspace;
-my $first = open_window;
-my $second = open_window;
+$ws = fresh_workspace;
+$first = open_window;
+$second = open_window;
send_net_active_window($first->id);
sync_with_i3;
# visible, check that nothing happens.
#####################################################################
-my $config = <<EOT;
+$config = <<EOT;
# i3 config file (v4)
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
focus_on_window_activation none
EOT
-my $pid = launch_with_config($config);
+$pid = launch_with_config($config);
-my $ws1 = fresh_workspace;
-my $first = open_window;
-my $ws2 = fresh_workspace;
-my $second = open_window;
+$ws1 = fresh_workspace;
+$first = open_window;
+$ws2 = fresh_workspace;
+$second = open_window;
send_net_active_window($first->id);
sync_with_i3;