2015-08-23 22:19:20 +02:00
|
|
|
#!perl
|
|
|
|
# vim:ts=4:sw=4:expandtab
|
|
|
|
#
|
|
|
|
# Please read the following documents before working on tests:
|
2017-09-24 10:19:50 +02:00
|
|
|
# • https://build.i3wm.org/docs/testsuite.html
|
2015-08-23 22:19:20 +02:00
|
|
|
# (or docs/testsuite)
|
|
|
|
#
|
2017-09-24 10:19:50 +02:00
|
|
|
# • https://build.i3wm.org/docs/lib-i3test.html
|
2015-08-23 22:19:20 +02:00
|
|
|
# (alternatively: perldoc ./testcases/lib/i3test.pm)
|
|
|
|
#
|
2017-09-24 10:19:50 +02:00
|
|
|
# • https://build.i3wm.org/docs/ipc.html
|
2015-08-23 22:19:20 +02:00
|
|
|
# (or docs/ipc)
|
|
|
|
#
|
|
|
|
# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
|
|
|
|
# (unless you are already familiar with Perl)
|
|
|
|
#
|
|
|
|
# Tests sticky windows.
|
|
|
|
# Ticket: #1455
|
2018-10-11 11:06:17 +02:00
|
|
|
use i3test i3_config => <<EOT;
|
|
|
|
# i3 config file (v4)
|
|
|
|
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
|
|
|
|
|
|
|
|
workspace ws-on-0 output fake-0
|
|
|
|
|
|
|
|
fake-outputs 1024x768+0+0,1024x768+1024+0
|
|
|
|
EOT
|
2015-08-23 22:19:20 +02:00
|
|
|
|
2015-09-17 22:52:56 +02:00
|
|
|
my ($ws, $tmp, $focused);
|
2015-08-23 22:19:20 +02:00
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# 1: Given a sticky tiling container, when the workspace is switched, then
|
|
|
|
# nothing happens.
|
|
|
|
###############################################################################
|
|
|
|
fresh_workspace;
|
2018-10-11 00:21:56 +02:00
|
|
|
open_window;
|
2015-08-23 22:19:20 +02:00
|
|
|
cmd 'sticky enable';
|
|
|
|
$ws = fresh_workspace;
|
|
|
|
|
|
|
|
is(@{get_ws($ws)->{nodes}}, 0, 'tiling sticky container did not move');
|
|
|
|
is(@{get_ws($ws)->{floating_nodes}}, 0, 'tiling sticky container did not move');
|
2018-10-11 00:21:56 +02:00
|
|
|
kill_all_windows;
|
2015-08-23 22:19:20 +02:00
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# 2: Given a sticky floating container, when the workspace is switched, then
|
|
|
|
# the container moves to the new workspace.
|
|
|
|
###############################################################################
|
|
|
|
$ws = fresh_workspace;
|
2018-10-11 00:21:56 +02:00
|
|
|
open_floating_window;
|
2015-08-23 22:19:20 +02:00
|
|
|
$focused = get_focused($ws);
|
|
|
|
cmd 'sticky enable';
|
|
|
|
$ws = fresh_workspace;
|
|
|
|
|
|
|
|
is(@{get_ws($ws)->{floating_nodes}}, 1, 'floating sticky container moved to new workspace');
|
|
|
|
is(get_focused($ws), $focused, 'sticky container has focus');
|
2018-10-11 00:21:56 +02:00
|
|
|
kill_all_windows;
|
2015-08-23 22:19:20 +02:00
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# 3: Given two sticky floating containers, when the workspace is switched,
|
|
|
|
# then both containers move to the new workspace.
|
|
|
|
###############################################################################
|
|
|
|
fresh_workspace;
|
2018-10-11 00:21:56 +02:00
|
|
|
open_floating_window;
|
2015-08-23 22:19:20 +02:00
|
|
|
cmd 'sticky enable';
|
2018-10-11 00:21:56 +02:00
|
|
|
open_floating_window;
|
2015-08-23 22:19:20 +02:00
|
|
|
cmd 'sticky enable';
|
|
|
|
$ws = fresh_workspace;
|
|
|
|
|
|
|
|
is(@{get_ws($ws)->{floating_nodes}}, 2, 'multiple sticky windows can be used at the same time');
|
2018-10-11 00:21:56 +02:00
|
|
|
kill_all_windows;
|
2015-08-23 22:19:20 +02:00
|
|
|
|
|
|
|
###############################################################################
|
2015-09-17 22:52:56 +02:00
|
|
|
# 4: Given an unfocused sticky floating container and a tiling container on the
|
|
|
|
# target workspace, when the workspace is switched, then the tiling container
|
|
|
|
# is focused.
|
2015-08-23 22:19:20 +02:00
|
|
|
###############################################################################
|
|
|
|
$ws = fresh_workspace;
|
|
|
|
open_window;
|
|
|
|
$focused = get_focused($ws);
|
|
|
|
fresh_workspace;
|
2018-10-11 00:21:56 +02:00
|
|
|
open_floating_window;
|
2015-08-23 22:19:20 +02:00
|
|
|
cmd 'sticky enable';
|
2015-09-17 22:52:56 +02:00
|
|
|
open_window;
|
2015-08-23 22:19:20 +02:00
|
|
|
cmd 'workspace ' . $ws;
|
|
|
|
|
|
|
|
is(get_focused($ws), $focused, 'the tiling container has focus');
|
2018-10-11 00:21:56 +02:00
|
|
|
kill_all_windows;
|
2015-08-23 22:19:20 +02:00
|
|
|
|
2015-08-26 21:06:53 +02:00
|
|
|
###############################################################################
|
2015-09-17 22:52:56 +02:00
|
|
|
# 5: Given a focused sticky floating container and a tiling container on the
|
|
|
|
# target workspace, when the workspace is switched, then the tiling container
|
|
|
|
# is focused.
|
|
|
|
###############################################################################
|
|
|
|
$ws = fresh_workspace;
|
|
|
|
open_window;
|
|
|
|
$tmp = fresh_workspace;
|
2018-10-11 00:21:56 +02:00
|
|
|
open_floating_window;
|
2015-09-17 22:52:56 +02:00
|
|
|
$focused = get_focused($tmp);
|
|
|
|
cmd 'sticky enable';
|
|
|
|
cmd 'workspace ' . $ws;
|
|
|
|
|
|
|
|
is(get_focused($ws), $focused, 'the sticky container has focus');
|
2018-10-11 00:21:56 +02:00
|
|
|
kill_all_windows;
|
2015-09-17 22:52:56 +02:00
|
|
|
|
|
|
|
###############################################################################
|
|
|
|
# 6: Given a floating container on a non-visible workspace, when the window
|
2015-08-26 21:06:53 +02:00
|
|
|
# is made sticky, then the window immediately jumps to the currently
|
|
|
|
# visible workspace.
|
|
|
|
###############################################################################
|
|
|
|
fresh_workspace;
|
2018-10-11 00:21:56 +02:00
|
|
|
open_floating_window;
|
2015-08-26 21:06:53 +02:00
|
|
|
cmd 'mark sticky';
|
|
|
|
$ws = fresh_workspace;
|
|
|
|
cmd '[con_mark=sticky] sticky enable';
|
|
|
|
|
|
|
|
is(@{get_ws($ws)->{floating_nodes}}, 1, 'the sticky window jumps to the front');
|
2018-10-11 00:21:56 +02:00
|
|
|
kill_all_windows;
|
2015-08-26 21:06:53 +02:00
|
|
|
|
2018-10-11 11:06:17 +02:00
|
|
|
###############################################################################
|
|
|
|
# 7: Given a sticky floating container and a workspace on another output, when
|
|
|
|
# a new workspace assigned to the first output is focused, then the sticky
|
|
|
|
# container should jump to the new workspace and have input focus correctly.
|
|
|
|
###############################################################################
|
|
|
|
$ws = fresh_workspace(output => 0);
|
|
|
|
open_floating_window;
|
|
|
|
cmd 'sticky enabled';
|
|
|
|
$focused = get_focused($ws);
|
|
|
|
$ws = fresh_workspace(output => 1);
|
|
|
|
|
|
|
|
is(@{get_ws($ws)->{floating_nodes}}, 0, 'the sticky window didn\'t jump to a workspace on a different output');
|
|
|
|
$ws = 'ws-on-0';
|
|
|
|
cmd "workspace $ws";
|
|
|
|
is(@{get_ws($ws)->{floating_nodes}}, 1, 'the sticky window moved to new workspace on first output');
|
|
|
|
is(get_focused($ws), $focused, 'the sticky window has focus');
|
|
|
|
kill_all_windows;
|
|
|
|
|
2015-08-23 22:19:20 +02:00
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
done_testing;
|