test:
- PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(1, '/home/michael//X11-XCB/lib/', '/home/michael//X11-XCB/blib/lib', '/home/michael//X11-XCB/blib/arch', '/home/michael/X11-XCB/X11-XCB-XS/lib', '/home/michael/X11-XCB/X11-XCB-XS/blib/arch')" t/11-*.t
+ PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(1)" t/*.t
all: test
use_ok('X11::XCB::Window');
}
-X11::XCB::Connection->connect(':0');
+my $x = X11::XCB::Connection->new;
my $original_rect = X11::XCB::Rect->new(x => 0, y => 0, width => 30, height => 30);
-my $window = X11::XCB::Window->new(
+my $window = $x->root->create_child(
class => WINDOW_CLASS_INPUT_OUTPUT,
rect => $original_rect,
background_color => '#C0C0C0',
is_deeply($window->rect, $original_rect, "rect unmodified before mapping");
-$window->create;
$window->map;
sleep(0.25);
use_ok('X11::XCB::Window');
}
-X11::XCB::Connection->connect(':0');
+my $x = X11::XCB::Connection->new;
my $original_rect = X11::XCB::Rect->new(x => 0, y => 0, width => 30, height => 30);
-my $window = X11::XCB::Window->new(
+my $window = $x->root->create_child(
class => WINDOW_CLASS_INPUT_OUTPUT,
rect => $original_rect,
background_color => '#C0C0C0',
is_deeply($window->rect, $original_rect, "rect unmodified before mapping");
-$window->create;
$window->map;
sleep(0.25);
$window->unmap;
-$window = X11::XCB::Window->new(
+$window = $x->root->create_child(
class => WINDOW_CLASS_INPUT_OUTPUT,
rect => $original_rect,
background_color => 61440,
is_deeply($window->rect, $original_rect, "rect unmodified before mapping");
-$window->create;
$window->fullscreen(1);
$window->map;
use_ok('X11::XCB::Window');
}
-X11::XCB::Connection->connect(':0');
+my $x = X11::XCB::Connection->new;
my $original_rect = X11::XCB::Rect->new(x => 0, y => 0, width => 30, height => 30);
-my $window = X11::XCB::Window->new(
+my $window = $x->root->create_child(
class => WINDOW_CLASS_INPUT_OUTPUT,
rect => $original_rect,
override_redirect => 1,
is_deeply($window->rect, $original_rect, "rect unmodified before mapping");
-$window->create;
$window->map;
my $new_rect = $window->rect;
use_ok('X11::XCB::Window');
}
-X11::XCB::Connection->connect(':0');
+my $x = X11::XCB::Connection->new;
# Create a floating window which is smaller than the minimum enforced size of i3
-my $window = X11::XCB::Window->new(
+my $window = $x->root->create_child(
class => WINDOW_CLASS_INPUT_OUTPUT,
rect => [ 0, 0, 30, 30],
background_color => '#C0C0C0',
- type => 'utility',
+ # replace the type with 'utility' as soon as the coercion works again in X11::XCB
+ type => $x->atom(name => '_NET_WM_WINDOW_TYPE_UTILITY'),
);
isa_ok($window, 'X11::XCB::Window');
-$window->create;
$window->map;
sleep(0.25);
$window->unmap;
-$window = X11::XCB::Window->new(
+$window = $x->root->create_child(
class => WINDOW_CLASS_INPUT_OUTPUT,
rect => [ 1, 1, 80, 90],
background_color => '#C0C0C0',
- type => 'utility',
+ type => $x->atom(name => '_NET_WM_WINDOW_TYPE_UTILITY'),
);
isa_ok($window, 'X11::XCB::Window');
-$window->create;
$window->map;
sleep(0.25);
use_ok('X11::XCB::Connection') or BAIL_OUT('Cannot load X11::XCB::Connection');
}
-X11::XCB::Connection->connect(':0');
+my $x = X11::XCB::Connection->new;
my $sock = IO::Socket::UNIX->new(Peer => '/tmp/i3-ipc.sock');
sleep(0.25);
# Create a window so we can get a focus different from NULL
-my $window = i3test::open_standard_window;
+my $window = i3test::open_standard_window($x);
diag("window->id = " . $window->id);
sleep(0.25);
-my $focus = X11::XCB::Connection->input_focus;
+my $focus = $x->input_focus;
diag("old focus = $focus");
# Switch to the nineth workspace
sleep(0.25);
-my $new_focus = X11::XCB::Connection->input_focus;
+my $new_focus = $x->input_focus;
isnt($focus, $new_focus, "Focus changed");
diag( "Testing i3, Perl $], $^X" );
use_ok('X11::XCB::Connection') or BAIL_OUT('Cannot load X11::XCB::Connection');
}
-X11::XCB::Connection->connect(':0');
+my $x = X11::XCB::Connection->new;
my $sock = IO::Socket::UNIX->new(Peer => '/tmp/i3-ipc.sock');
isa_ok($sock, 'IO::Socket::UNIX');
$sock->write(i3test::format_ipc_command("d"));
sleep(0.25);
-my $top = i3test::open_standard_window;
-my $mid = i3test::open_standard_window;
-my $bottom = i3test::open_standard_window;
+my $top = i3test::open_standard_window($x);
+my $mid = i3test::open_standard_window($x);
+my $bottom = i3test::open_standard_window($x);
sleep(0.25);
diag("top id = " . $top->id);
$sock->write(i3test::format_ipc_command($msg));
sleep(0.5);
- return X11::XCB::Connection->input_focus;
+ return $x->input_focus;
}
-$focus = X11::XCB::Connection->input_focus;
+$focus = $x->input_focus;
is($focus, $bottom->id, "Latest window focused");
$focus = focus_after("k");
use_ok('X11::XCB::Connection') or BAIL_OUT('Cannot load X11::XCB::Connection');
}
-X11::XCB::Connection->connect(':0');
+my $x = X11::XCB::Connection->new;
my $sock = IO::Socket::UNIX->new(Peer => '/tmp/i3-ipc.sock');
isa_ok($sock, 'IO::Socket::UNIX');
# Create two windows and make sure focus switching works
#####################################################################
-my $top = i3test::open_standard_window;
+my $top = i3test::open_standard_window($x);
sleep(0.25);
-my $mid = i3test::open_standard_window;
+my $mid = i3test::open_standard_window($x);
sleep(0.25);
-my $bottom = i3test::open_standard_window;
+my $bottom = i3test::open_standard_window($x);
sleep(0.25);
diag("top id = " . $top->id);
$sock->write(i3test::format_ipc_command($msg));
sleep(0.5);
- return X11::XCB::Connection->input_focus;
+ return $x->input_focus;
}
-$focus = X11::XCB::Connection->input_focus;
+$focus = $x->input_focus;
is($focus, $bottom->id, "Latest window focused");
$focus = focus_after("ml");
use_ok('X11::XCB::Window') or BAIL_OUT('Could not load X11::XCB::Window');
}
-X11::XCB::Connection->connect(':0');
+my $x = X11::XCB::Connection->new;
my $sock = IO::Socket::UNIX->new(Peer => '/tmp/i3-ipc.sock');
isa_ok($sock, 'IO::Socket::UNIX');
sleep(0.25);
-
-my $tiled_left = i3test::open_standard_window;
-my $tiled_right = i3test::open_standard_window;
+my $tiled_left = i3test::open_standard_window($x);
+my $tiled_right = i3test::open_standard_window($x);
sleep(0.25);
$sock->write(i3test::format_ipc_command("ml"));
# Get input focus before creating the floating window
-my $focus = X11::XCB::Connection->input_focus;
+my $focus = $x->input_focus;
# Create a floating window which is smaller than the minimum enforced size of i3
-my $window = X11::XCB::Window->new(
+my $window = $x->root->create_child(
class => WINDOW_CLASS_INPUT_OUTPUT,
rect => [ 1, 1, 30, 30],
background_color => '#C0C0C0',
- type => 'utility',
+ type => $x->atom(name => '_NET_WM_WINDOW_TYPE_UTILITY'),
);
isa_ok($window, 'X11::XCB::Window');
-$window->create;
$window->map;
sleep(0.25);
-is(X11::XCB::Connection->input_focus, $window->id, 'floating window focused');
+is($x->input_focus, $window->id, 'floating window focused');
$window->unmap;
sleep(0.25);
-is(X11::XCB::Connection->input_focus, $focus, 'Focus correctly restored');
+is($x->input_focus, $focus, 'Focus correctly restored');
diag( "Testing i3, Perl $], $^X" );
use_ok('X11::XCB::Connection') or BAIL_OUT('Cannot load X11::XCB::Connection');
}
-X11::XCB::Connection->connect(':0');
+my $x = X11::XCB::Connection->new;
my $sock = IO::Socket::UNIX->new(Peer => '/tmp/i3-ipc.sock');
isa_ok($sock, 'IO::Socket::UNIX');
# Create two windows and make sure focus switching works
#####################################################################
-my $top = i3test::open_standard_window;
+my $top = i3test::open_standard_window($x);
sleep(0.25);
-my $mid = i3test::open_standard_window;
+my $mid = i3test::open_standard_window($x);
sleep(0.25);
-my $bottom = i3test::open_standard_window;
+my $bottom = i3test::open_standard_window($x);
sleep(0.25);
diag("top id = " . $top->id);
$sock->write(i3test::format_ipc_command($msg));
sleep(0.25);
- return X11::XCB::Connection->input_focus;
+ return $x->input_focus;
}
-$focus = X11::XCB::Connection->input_focus;
+$focus = $x->input_focus;
is($focus, $bottom->id, "Latest window focused");
$focus = focus_after("s");
$focus = focus_after("h");
is($focus, $bottom->id, "Bottom window focused (focus after moving)");
-my $new = i3test::open_standard_window;
+my $new = i3test::open_standard_window($x);
sleep(0.25);
# By now, we have this layout:
use_ok('X11::XCB::Connection') or BAIL_OUT('Cannot load X11::XCB::Connection');
}
-X11::XCB::Connection->connect(':0');
+my $x = X11::XCB::Connection->new;
#####################################################################
# Create a dock window and see if it gets managed
#####################################################################
-my $screens = X11::XCB::Connection->screens;
+my $screens = $x->screens;
# Get the primary screen
my $primary = first { $_->primary } @{$screens};
# TODO: focus the primary screen before
-my $window = X11::XCB::Window->new(
+my $window = $x->root->create_child(
class => WINDOW_CLASS_INPUT_OUTPUT,
rect => [ 0, 0, 30, 30],
background_color => '#FF0000',
- type => 'dock',
+ type => $x->atom(name => '_NET_WM_WINDOW_TYPE_DOCK'),
);
-$window->create;
$window->map;
sleep 0.25;
use_ok('X11::XCB::Connection') or BAIL_OUT('Cannot load X11::XCB::Connection');
}
-X11::XCB::Connection->connect(':0');
+my $x = X11::XCB::Connection->new;
my $sock = IO::Socket::UNIX->new(Peer => '/tmp/i3-ipc.sock');
isa_ok($sock, 'IO::Socket::UNIX');
# Create two windows and make sure focus switching works
#####################################################################
-my $top = i3test::open_standard_window;
+my $top = i3test::open_standard_window($x);
sleep(0.25);
-my $mid = i3test::open_standard_window;
+my $mid = i3test::open_standard_window($x);
sleep(0.25);
-my $bottom = i3test::open_standard_window;
+my $bottom = i3test::open_standard_window($x);
sleep(0.25);
diag("top id = " . $top->id);
$sock->write(i3test::format_ipc_command($msg));
sleep(0.5);
- return X11::XCB::Connection->input_focus;
+ return $x->input_focus;
}
-$focus = X11::XCB::Connection->input_focus;
+$focus = $x->input_focus;
is($focus, $bottom->id, "Latest window focused");
$focus = focus_after("ml");
}
sub open_standard_window {
- my $original_rect = X11::XCB::Rect->new(x => 0, y => 0, width => 30, height => 30);
+ my ($x) = @_;
- my $window = X11::XCB::Window->new(
+ my $window = $x->root->create_child(
class => WINDOW_CLASS_INPUT_OUTPUT,
- rect => $original_rect,
+ rect => [ 0, 0, 30, 30 ],
background_color => '#C0C0C0',
);
- $window->create;
$window->name('Window ' . counter_window());
$window->map;