From 28bfeadbb0e3b2f9da282d905cc4272ba749ad10 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Thu, 14 Sep 2017 11:44:49 +0200 Subject: [PATCH] =?utf8?q?i3test::XTEST:=20don=E2=80=99t=20=E2=80=9Cuse=20?= =?utf8?q?i3test=E2=80=9D=20to=20avoid=20clobbering=20state?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Before this commit, the $i3_autostart variable was accidentally overridden. --- testcases/lib/i3test.pm.in | 9 +-------- testcases/lib/i3test/Util.pm | 23 +++++++++++++++++++++++ testcases/lib/i3test/XTEST.pm | 3 ++- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/testcases/lib/i3test.pm.in b/testcases/lib/i3test.pm.in index 5e3f8b2d..0f28a7a9 100644 --- a/testcases/lib/i3test.pm.in +++ b/testcases/lib/i3test.pm.in @@ -793,14 +793,7 @@ sub get_socket_path { if ($cache && defined($_cached_socket_path)) { return $_cached_socket_path; } - - my $atom = $x->atom(name => 'I3_SOCKET_PATH'); - my $cookie = $x->get_property(0, $x->get_root_window(), $atom->id, GET_PROPERTY_TYPE_ANY, 0, 256); - my $reply = $x->get_property_reply($cookie->{sequence}); - my $socketpath = $reply->{value}; - if ($socketpath eq "/tmp/nested-$ENV{DISPLAY}") { - $socketpath .= '-activation'; - } + my $socketpath = i3test::Util::get_socket_path($x); $_cached_socket_path = $socketpath; return $socketpath; } diff --git a/testcases/lib/i3test/Util.pm b/testcases/lib/i3test/Util.pm index 74913681..725ca4e1 100644 --- a/testcases/lib/i3test/Util.pm +++ b/testcases/lib/i3test/Util.pm @@ -5,9 +5,13 @@ use strict; use warnings; use v5.10; +use X11::XCB qw(GET_PROPERTY_TYPE_ANY); +use X11::XCB::Connection; + use Exporter qw(import); our @EXPORT = qw( slurp + get_socket_path ); =encoding utf-8 @@ -38,6 +42,25 @@ sub slurp { return $content; } +=head2 get_socket_path([X11::XCB::Connection]) + +Gets the socket path from the C atom stored on the X11 root +window. + +=cut +sub get_socket_path { + my ($x) = @_; + $x //= X11::XCB::Connection->new(); + my $atom = $x->atom(name => 'I3_SOCKET_PATH'); + my $cookie = $x->get_property(0, $x->get_root_window(), $atom->id, GET_PROPERTY_TYPE_ANY, 0, 256); + my $reply = $x->get_property_reply($cookie->{sequence}); + my $socketpath = $reply->{value}; + if ($socketpath eq "/tmp/nested-$ENV{DISPLAY}") { + $socketpath .= '-activation'; + } + return $socketpath; +} + =head1 AUTHOR Michael Stapelberg diff --git a/testcases/lib/i3test/XTEST.pm b/testcases/lib/i3test/XTEST.pm index 3937b70a..b7a9cdc5 100644 --- a/testcases/lib/i3test/XTEST.pm +++ b/testcases/lib/i3test/XTEST.pm @@ -5,7 +5,8 @@ use strict; use warnings; use v5.10; -use i3test i3_autostart => 0; +use Test::More; +use i3test::Util qw(get_socket_path); use lib qw(@abs_top_srcdir@/AnyEvent-I3/blib/lib); use AnyEvent::I3; use ExtUtils::PkgConfig; -- 2.39.2