# name => 'Window <n>'
#
sub open_window {
- my ($x, $args) = @_;
+ my ($args) = @_;
my %args = ($args ? %$args : ());
my $dont_map = delete $args{dont_map};
$args{window_type} = $x->atom(name => '_NET_WM_WINDOW_TYPE_UTILITY');
- return open_window($x, \%args);
+ return open_window(\%args);
}
sub open_empty_con {
#####################################################################
# Create a window so we can get a focus different from NULL
-my $window = open_window($x);
+my $window = open_window;
my $focus = $x->input_focus;
cmd 'layout default';
cmd 'split v';
-my $top = open_window($x);
-my $mid = open_window($x);
-my $bottom = open_window($x);
+my $top = open_window;
+my $mid = open_window;
+my $bottom = open_window;
#
# Returns the input focus after sending the given command to i3 via IPC
my $primary = first { $_->primary } @{$screens};
# TODO: focus the primary screen before
-my $window = open_window($x, {
+my $window = open_window({
window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
});
# check if it gets placed on bottom (by coordinates)
#####################################################################
-$window = open_window($x, {
+$window = open_window({
rect => [ 0, 1000, 30, 30 ],
background_color => '#FF0000',
window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
# check if it gets placed on bottom (by hint)
#####################################################################
-$window = open_window($x, {
+$window = open_window({
dont_map => 1,
rect => [ 0, 1000, 30, 30 ],
background_color => '#FF0000',
@docked = get_dock_clients();
is(@docked, 0, 'no more dock clients');
-$window = open_window($x, {
+$window = open_window({
dont_map => 1,
rect => [ 0, 1000, 30, 30 ],
background_color => '#FF0000',
# regression test: transient dock client
#####################################################################
-my $fwindow = open_window($x, {
+my $fwindow = open_window({
dont_map => 1,
background_color => '#FF0000',
window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
fresh_workspace;
cmd 'split h';
-my $tiled_left = open_window($x);
-my $tiled_right = open_window($x);
+my $tiled_left = open_window;
+my $tiled_right = open_window;
# Get input focus before creating the floating window
my $focus = $x->input_focus;
# Create two windows and make sure focus switching works
#####################################################################
-my $top = open_window($x);
-my $mid = open_window($x);
-my $bottom = open_window($x);
+my $top = open_window;
+my $mid = open_window;
+my $bottom = open_window;
#
# Returns the input focus after sending the given command to i3 via IPC
cmd 'split v';
-my $top = open_window($x);
-my $bottom = open_window($x);
+my $top = open_window;
+my $bottom = open_window;
my @urgent = grep { $_->{urgent} } @{get_ws_content($tmp)};
is(@urgent, 0, 'no window got the urgent flag');
# one of both (depending on your screen resolution) will be positioned wrong.
####################################################################################
-my $left = open_window($x, { name => 'Left' });
-my $right = open_window($x, { name => 'Right' });
+my $left = open_window({ name => 'Left' });
+my $right = open_window({ name => 'Right' });
my ($abs, $rgeom) = $right->rect;
cmp_ok(($cgeom->x + $cgeom->width), '<', $rgeom->x, 'child above left window');
# check wm_transient_for
-my $fwindow = open_window($x, { dont_map => 1 });
+my $fwindow = open_window({ dont_map => 1 });
$fwindow->transient_for($right);
$fwindow->map;
# Create a parent window
#####################################################################
-my $window = open_window($x, { dont_map => 1, name => 'Parent window' });
+my $window = open_window({ dont_map => 1, name => 'Parent window' });
$window->map;
ok(wait_for_map($window), 'parent window mapped');
#########################################################################
fresh_workspace;
-my $child = open_window($x, { dont_map => 1, name => 'Child window' });
+my $child = open_window({ dont_map => 1, name => 'Child window' });
$child->client_leader($window);
$child->map;
ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
# Open a new window
-my $window = open_window($x);
+my $window = open_window;
my $content = get_ws_content($tmp);
ok(@{$content} == 1, 'window mapped');
my $win = $content->[0];
$middle = open_empty_con($i3);
# XXX: the $right empty con will be filled with the x11 window we are creating afterwards
$right = open_empty_con($i3);
-my $win = open_window($x, { background_color => '#00ff00' });
+my $win = open_window({ background_color => '#00ff00' });
cmd qq|[con_id="$middle"] focus|;
$win->destroy;
ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
-my $win = open_window($x, { dont_map => 1 });
+my $win = open_window({ dont_map => 1 });
# XXX: we should check screen size. in screens with an AR of 2.0,
# this is not a good idea.
my $aspect = X11::XCB::Sizehints::Aspect->new;
# 1: see if focus stays the same when toggling tiling/floating mode
#############################################################################
-my $first = open_window($x);
-my $second = open_window($x);
+my $first = open_window;
+my $second = open_window;
is($x->input_focus, $second->id, 'second window focused');
$tmp = fresh_workspace;
-$first = open_window($x); # window 2
-$second = open_window($x); # window 3
-my $third = open_window($x); # window 4
+$first = open_window; # window 2
+$second = open_window; # window 3
+my $third = open_window; # window 4
is($x->input_focus, $third->id, 'last container focused');
$tmp = fresh_workspace;
-$first = open_window($x, { background_color => '#ff0000' }); # window 5
-$second = open_window($x, { background_color => '#00ff00' }); # window 6
-$third = open_window($x, { background_color => '#0000ff' }); # window 7
+$first = open_window({ background_color => '#ff0000' }); # window 5
+$second = open_window({ background_color => '#00ff00' }); # window 6
+$third = open_window({ background_color => '#0000ff' }); # window 7
is($x->input_focus, $third->id, 'last container focused');
$tmp = fresh_workspace;
-$first = open_window($x, { background_color => '#ff0000' }); # window 5
+$first = open_window({ background_color => '#ff0000' }); # window 5
cmd 'split v';
cmd 'layout stacked';
-$second = open_window($x, { background_color => '#00ff00' }); # window 6
-$third = open_window($x, { background_color => '#0000ff' }); # window 7
+$second = open_window({ background_color => '#00ff00' }); # window 6
+$third = open_window({ background_color => '#0000ff' }); # window 7
is($x->input_focus, $third->id, 'last container focused');
$tmp = fresh_workspace;
-$first = open_window($x, { background_color => '#ff0000' }); # window 8
-$second = open_window($x, { background_color => '#00ff00' }); # window 9
+$first = open_window({ background_color => '#ff0000' }); # window 8
+$second = open_window({ background_color => '#00ff00' }); # window 9
sync_with_i3($x);
is(@{$nodes}, 0, 'no tiling nodes');
# Create a tiling window
-my $twindow = open_window($x);
+my $twindow = open_window;
($nodes, $focus) = get_ws_content($tmp);
$tmp = fresh_workspace;
-my $first = open_window($x);
-my $second = open_window($x);
+my $first = open_window;
+my $second = open_window;
cmd 'layout stacked';
is(@{$ws->{floating_nodes}}, 1, 'one floating nodes');
is(@{$ws->{nodes}}, 1, 'one tiling node (stacked con)');
-my $third = open_window($x);
+my $third = open_window;
$ws = get_ws($tmp);
cmd "workspace 93";
-open_window($x);
+open_window;
my @ws = @{$i3->get_workspaces->recv};
my @f = grep { defined($_->{num}) && $_->{num} == 93 } @ws;
check_order('workspace order alright after opening 93');
cmd "workspace 92";
-open_window($x);
+open_window;
check_order('workspace order alright after opening 92');
cmd "workspace 94";
-open_window($x);
+open_window;
check_order('workspace order alright after opening 94');
cmd "workspace 96";
-open_window($x);
+open_window;
check_order('workspace order alright after opening 96');
cmd "workspace foo";
-open_window($x);
+open_window;
check_order('workspace order alright after opening foo');
cmd "workspace 91";
-open_window($x);
+open_window;
check_order('workspace order alright after opening 91');
done_testing;
my $tmp = fresh_workspace;
-my $left = open_window($x);
-my $mid = open_window($x);
-my $right = open_window($x);
+my $left = open_window;
+my $mid = open_window;
+my $right = open_window;
sync_with_i3($x);
cmd 'split v';
-my $top = open_window($x);
-my $bottom = open_window($x);
+my $top = open_window;
+my $bottom = open_window;
sync_with_i3($x);
cmd 'split v';
-$top = open_window($x);
-$bottom = open_window($x);
+$top = open_window;
+$bottom = open_window;
cmd 'split h';
cmd 'layout stacked';
$tmp = fresh_workspace;
-$top = open_window($x);
+$top = open_window;
cmd 'floating enable';
my $tmp = fresh_workspace;
-my $left = open_window($x);
-my $mid = open_window($x);
-my $right = open_window($x);
+my $left = open_window;
+my $mid = open_window;
+my $right = open_window;
cmd 'move up';
cmd 'move right';
my $tmp = fresh_workspace;
-my $left = open_window($x);
-my $mid = open_window($x);
+my $left = open_window;
+my $mid = open_window;
cmd 'split v';
-my $bottom = open_window($x);
+my $bottom = open_window;
my ($nodes, $focus) = get_ws_content($tmp);
my $tmp = fresh_workspace;
-my $left = open_window($x);
-my $mid = open_window($x);
-my $right = open_window($x);
+my $left = open_window;
+my $mid = open_window;
+my $right = open_window;
# go to workspace level
cmd 'level up';
my $tmp = fresh_workspace;
# open a tiling window on the first workspace
-open_window($x);
+open_window;
#sleep 0.25;
my $first = get_focused($tmp);
# on a different ws, open a floating window
my $otmp = fresh_workspace;
-open_window($x);
+open_window;
#sleep 0.25;
my $float = get_focused($otmp);
cmd 'mode toggle';
# open a dock client
-my $window = open_window($x, {
+my $window = open_window({
background_color => '#FF0000',
window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
});
# create a dock client with a 1px border
#####################################################################
-$window = open_window($x, {
+$window = open_window({
border => 1,
rect => [ 0, 0, 30, 20 ],
background_color => '#00FF00',
my $tmp = fresh_workspace;
# Create a floating window which is smaller than the minimum enforced size of i3
-my $window = open_window($x, { rect => [ 0, 0, 400, 150 ] });
+my $window = open_window({ rect => [ 0, 0, 400, 150 ] });
my ($absolute, $top) = $window->rect;
# open a dock client
#####################################################################
-my $first = open_window($x, {
+my $first = open_window({
background_color => '#FF0000',
window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
});
# Open a second dock client
#####################################################################
-my $second = open_window($x, {
+my $second = open_window({
background_color => '#FF0000',
window_type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
});
# open a window with 200x80
#####################################################################
-my $first = open_window($x, {
+my $first = open_window({
rect => [ 0, 0, 200, 80],
background_color => '#FF0000',
});
# Open a second window with 300x90
#####################################################################
-my $second = open_window($x, {
+my $second = open_window({
rect => [ 0, 0, 300, 90],
background_color => '#00FF00',
});
# open the left window
#####################################################################
-my $left = open_window($x, { background_color => '#ff0000' });
+my $left = open_window({ background_color => '#ff0000' });
is($x->input_focus, $left->id, 'left window focused');
# Open the right window
#####################################################################
-my $right = open_window($x, { background_color => '#00ff00' });
+my $right = open_window({ background_color => '#00ff00' });
diag("right = " . $right->id);
# Open a third window
#####################################################################
-my $third = open_window($x, {
+my $third = open_window({
background_color => '#0000ff',
name => 'Third window',
dont_map => 1,
# open a window, verify it’s not in fullscreen mode
#####################################################################
-my $win = open_window($x);
+my $win = open_window;
my $nodes = get_ws_content $tmp;
is(@$nodes, 1, 'exactly one client');
subtest 'Window without WM_TAKE_FOCUS', sub {
fresh_workspace;
- my $window = open_window($x);
+ my $window = open_window;
ok(!wait_for_event(1, sub { $_[0]->{response_type} == 161 }), 'did not receive ClientMessage');
my $take_focus = $x->atom(name => 'WM_TAKE_FOCUS');
- my $window = open_window($x, {
+ my $window = open_window({
dont_map => 1,
protocols => [ $take_focus ],
});
my $i3 = i3(get_socket_path());
my $tmp = fresh_workspace;
-my $window = open_window($x);
+my $window = open_window;
sub get_border_style {
my @content = @{get_ws_content($tmp)};
use i3test;
use X11::XCB qw(ICCCM_WM_STATE_NORMAL ICCCM_WM_STATE_WITHDRAWN);
-my $window = open_window($x);
+my $window = open_window;
sync_with_i3($x);
ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
- my $first = open_window($x);
- my $second = open_window($x);
+ my $first = open_window;
+ my $second = open_window;
sync_with_i3 $x;
cmp_ok(@content, '==', 1, 'one node on this workspace now');
is($content[0]->{border}, 'none', 'no border');
-my $other = open_window($x);
+my $other = open_window;
@content = @{get_ws_content($tmp)};
cmp_ok(@content, '==', 2, 'two nodes');
ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
-my $first = open_window($x);
-my $second = open_window($x);
+my $first = open_window;
+my $second = open_window;
sync_with_i3($x);
ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
-$first = open_window($x);
-$second = open_window($x);
+$first = open_window;
+$second = open_window;
sync_with_i3($x);
#####################################################################
cmd 'focus parent';
-my $right_top = open_window($x);
-my $right_bot = open_window($x);
+my $right_top = open_window;
+my $right_bot = open_window;
@content = @{get_ws_content($tmp)};
is(@content, 2, 'two cons at workspace level after focus parent');
fresh_workspace;
-open_window($x);
-open_window($x);
+open_window;
+open_window;
cmd 'layout stacking';
sleep 1;
ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
-my $first = open_window($x);
-my $second = open_window($x);
+my $first = open_window;
+my $second = open_window;
cmd 'layout tabbed';
cmd 'focus parent';
-my $third = open_window($x);
+my $third = open_window;
is($x->input_focus, $third->id, 'third window focused');
cmd 'focus left';
ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
-$first = open_window($x);
-$second = open_window($x);
+$first = open_window;
+$second = open_window;
cmd 'layout tabbed';
cmd 'focus parent';
-$third = open_window($x);
+$third = open_window;
sync_with_i3($x);
ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
-my $first = open_window($x);
+my $first = open_window;
my @content = @{get_ws_content($tmp)};
ok(@content == 1, 'one container opened');
ok(@{get_ws_content($tmp)} == 0, 'no containers yet');
-$first = open_window($x);
+$first = open_window;
@content = @{get_ws_content($tmp)};
ok(@content == 1, 'one container opened');
is(@{get_ws_content($second_ws)}, 0, 'no containers on the second workspace yet');
-my $win = open_window($x, { dont_map => 1 });
+my $win = open_window({ dont_map => 1 });
mark_window($win->id);
$win->map;
# We don’t use wait_for_map because the window will not get mapped -- it is on
# same thing, but with _NET_STARTUP_ID set on the leader
######################################################################
-my $leader = open_window($x, { dont_map => 1 });
+my $leader = open_window({ dont_map => 1 });
mark_window($leader->id);
-$win = open_window($x, { dont_map => 1, client_leader => $leader });
+$win = open_window({ dont_map => 1, client_leader => $leader });
$win->map;
sync_with_i3($x);
complete_startup();
sync_with_i3($x);
-my $otherwin = open_window($x);
+my $otherwin = open_window;
is(@{get_ws_content($second_ws)}, 1, 'one container on the second workspace');
######################################################################