tests: move set_wm_class to X11::XCB::Window
This code was duplicated way too often for a long time :)
This commit is contained in:
parent
031de8f720
commit
8d38529bcd
|
@ -9,7 +9,7 @@ WriteMakefile(
|
|||
PREREQ_PM => {
|
||||
'AnyEvent' => 0,
|
||||
'AnyEvent::I3' => '0.14',
|
||||
'X11::XCB' => '0.03',
|
||||
'X11::XCB' => '0.09',
|
||||
'Inline' => 0,
|
||||
'ExtUtils::PkgConfig' => 0,
|
||||
'Test::More' => '0.94',
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
# Tests all kinds of matching methods
|
||||
#
|
||||
use i3test;
|
||||
use X11::XCB qw(PROP_MODE_REPLACE);
|
||||
|
||||
my $tmp = fresh_workspace;
|
||||
|
||||
|
@ -61,39 +60,10 @@ is_num_children($tmp, 0, 'window killed');
|
|||
|
||||
$tmp = fresh_workspace;
|
||||
|
||||
# TODO: move to X11::XCB
|
||||
sub set_wm_class {
|
||||
my ($id, $class, $instance) = @_;
|
||||
|
||||
# Add a _NET_WM_STRUT_PARTIAL hint
|
||||
my $atomname = $x->atom(name => 'WM_CLASS');
|
||||
my $atomtype = $x->atom(name => 'STRING');
|
||||
|
||||
$x->change_property(
|
||||
PROP_MODE_REPLACE,
|
||||
$id,
|
||||
$atomname->id,
|
||||
$atomtype->id,
|
||||
8,
|
||||
length($class) + length($instance) + 2,
|
||||
"$instance\x00$class\x00"
|
||||
);
|
||||
}
|
||||
|
||||
sub open_special {
|
||||
my %args = @_;
|
||||
my $wm_class = delete($args{wm_class}) || 'special';
|
||||
|
||||
return open_window(
|
||||
%args,
|
||||
before_map => sub { set_wm_class($_->id, $wm_class, $wm_class) },
|
||||
);
|
||||
}
|
||||
|
||||
my $left = open_special(name => 'left');
|
||||
my $left = open_window(wm_class => 'special', name => 'left');
|
||||
ok($left->mapped, 'left window mapped');
|
||||
|
||||
my $right = open_special(name => 'right');
|
||||
my $right = open_window(wm_class => 'special', name => 'right');
|
||||
ok($right->mapped, 'right window mapped');
|
||||
|
||||
# two windows should be here
|
||||
|
@ -111,7 +81,7 @@ is_num_children($tmp, 1, 'one window still there');
|
|||
|
||||
$tmp = fresh_workspace;
|
||||
|
||||
$left = open_special(name => 'left', wm_class => 'special7');
|
||||
$left = open_window(name => 'left', wm_class => 'special7');
|
||||
ok($left->mapped, 'left window mapped');
|
||||
is_num_children($tmp, 1, 'window opened');
|
||||
|
||||
|
@ -125,7 +95,7 @@ is_num_children($tmp, 0, 'window killed');
|
|||
|
||||
$tmp = fresh_workspace;
|
||||
|
||||
$left = open_special(name => 'ä 3', wm_class => 'special7');
|
||||
$left = open_window(name => 'ä 3', wm_class => 'special7');
|
||||
ok($left->mapped, 'left window mapped');
|
||||
is_num_children($tmp, 1, 'window opened');
|
||||
|
||||
|
|
|
@ -49,29 +49,9 @@ wait_for_unmap $window;
|
|||
cmp_ok(@content, '==', 0, 'no more nodes');
|
||||
diag('content = '. Dumper(\@content));
|
||||
|
||||
|
||||
# TODO: move this to X11::XCB::Window
|
||||
sub set_wm_class {
|
||||
my ($id, $class, $instance) = @_;
|
||||
|
||||
# Add a _NET_WM_STRUT_PARTIAL hint
|
||||
my $atomname = $x->atom(name => 'WM_CLASS');
|
||||
my $atomtype = $x->atom(name => 'STRING');
|
||||
|
||||
$x->change_property(
|
||||
PROP_MODE_REPLACE,
|
||||
$id,
|
||||
$atomname->id,
|
||||
$atomtype->id,
|
||||
8,
|
||||
length($class) + length($instance) + 2,
|
||||
"$instance\x00$class\x00"
|
||||
);
|
||||
}
|
||||
|
||||
$window = open_window(
|
||||
name => 'Borderless window',
|
||||
before_map => sub { set_wm_class($_->id, 'borderless', 'borderless') },
|
||||
wm_class => 'borderless',
|
||||
);
|
||||
|
||||
@content = @{get_ws_content($tmp)};
|
||||
|
@ -190,7 +170,7 @@ $tmp = fresh_workspace;
|
|||
|
||||
$window = open_window(
|
||||
name => 'usethis',
|
||||
before_map => sub { set_wm_class($_->id, 'borderless', 'borderless') },
|
||||
wm_class => 'borderless',
|
||||
);
|
||||
|
||||
@content = @{get_ws_content($tmp)};
|
||||
|
@ -208,8 +188,7 @@ sync_with_i3;
|
|||
cmp_ok(@content, '==', 0, 'no nodes on this workspace now');
|
||||
|
||||
$window->_create;
|
||||
|
||||
set_wm_class($window->id, 'borderless', 'borderless');
|
||||
$window->wm_class('borderless');
|
||||
$window->name('notthis');
|
||||
$window->map;
|
||||
wait_for_map $window;
|
||||
|
@ -238,7 +217,8 @@ $tmp = fresh_workspace;
|
|||
|
||||
$window = open_window(
|
||||
name => 'usethis',
|
||||
before_map => sub { set_wm_class($_->id, 'bar', 'foo') },
|
||||
wm_class => 'bar',
|
||||
instance => 'foo',
|
||||
);
|
||||
|
||||
@content = @{get_ws_content($tmp)};
|
||||
|
@ -264,7 +244,8 @@ $tmp = fresh_workspace;
|
|||
|
||||
$window = open_window(
|
||||
name => 'usethis',
|
||||
before_map => sub { set_wm_class($_->id, 'bar', 'foo') },
|
||||
wm_class => 'bar',
|
||||
instance => 'foo',
|
||||
);
|
||||
|
||||
@content = @{get_ws_content($tmp)};
|
||||
|
@ -292,7 +273,8 @@ $tmp = fresh_workspace;
|
|||
|
||||
$window = open_window(
|
||||
name => 'usethis',
|
||||
before_map => sub { set_wm_class($_->id, 'bar', 'foo') },
|
||||
wm_class => 'bar',
|
||||
instance => 'foo',
|
||||
);
|
||||
|
||||
@content = @{get_ws_content($tmp)};
|
||||
|
|
|
@ -17,37 +17,16 @@
|
|||
# Tests if assignments work
|
||||
#
|
||||
use i3test i3_autostart => 0;
|
||||
use X11::XCB qw(PROP_MODE_REPLACE);
|
||||
|
||||
# TODO: move to X11::XCB
|
||||
sub set_wm_class {
|
||||
my ($id, $class, $instance) = @_;
|
||||
|
||||
# Add a _NET_WM_STRUT_PARTIAL hint
|
||||
my $atomname = $x->atom(name => 'WM_CLASS');
|
||||
my $atomtype = $x->atom(name => 'STRING');
|
||||
|
||||
$x->change_property(
|
||||
PROP_MODE_REPLACE,
|
||||
$id,
|
||||
$atomname->id,
|
||||
$atomtype->id,
|
||||
8,
|
||||
length($class) + length($instance) + 2,
|
||||
"$instance\x00$class\x00"
|
||||
);
|
||||
}
|
||||
|
||||
sub open_special {
|
||||
my %args = @_;
|
||||
my $wm_class = delete($args{wm_class}) || 'special';
|
||||
$args{name} //= 'special window';
|
||||
|
||||
# We use dont_map because i3 will not map the window on the current
|
||||
# workspace. Thus, open_window would time out in wait_for_map (2 seconds).
|
||||
my $window = open_window(
|
||||
%args,
|
||||
before_map => sub { set_wm_class($_->id, $wm_class, $wm_class) },
|
||||
wm_class => 'special',
|
||||
dont_map => 1,
|
||||
);
|
||||
$window->map;
|
||||
|
|
|
@ -18,37 +18,16 @@
|
|||
# assigned to an invisible workspace
|
||||
#
|
||||
use i3test i3_autostart => 0;
|
||||
use X11::XCB qw(PROP_MODE_REPLACE);
|
||||
|
||||
# TODO: move to X11::XCB
|
||||
sub set_wm_class {
|
||||
my ($id, $class, $instance) = @_;
|
||||
|
||||
# Add a _NET_WM_STRUT_PARTIAL hint
|
||||
my $atomname = $x->atom(name => 'WM_CLASS');
|
||||
my $atomtype = $x->atom(name => 'STRING');
|
||||
|
||||
$x->change_property(
|
||||
PROP_MODE_REPLACE,
|
||||
$id,
|
||||
$atomname->id,
|
||||
$atomtype->id,
|
||||
8,
|
||||
length($class) + length($instance) + 2,
|
||||
"$instance\x00$class\x00"
|
||||
);
|
||||
}
|
||||
|
||||
sub open_special {
|
||||
my %args = @_;
|
||||
my $wm_class = delete($args{wm_class}) || 'special';
|
||||
$args{name} //= 'special window';
|
||||
|
||||
# We use dont_map because i3 will not map the window on the current
|
||||
# workspace. Thus, open_window would time out in wait_for_map (2 seconds).
|
||||
my $window = open_window(
|
||||
%args,
|
||||
before_map => sub { set_wm_class($_->id, $wm_class, $wm_class) },
|
||||
wm_class => 'special',
|
||||
dont_map => 1,
|
||||
);
|
||||
$window->map;
|
||||
|
|
|
@ -18,44 +18,13 @@
|
|||
# window is shown on another workspace.
|
||||
#
|
||||
use i3test;
|
||||
use List::Util qw(first);
|
||||
use X11::XCB qw(:all);
|
||||
|
||||
my $i3 = i3(get_socket_path());
|
||||
my $tmp = fresh_workspace;
|
||||
|
||||
# TODO: move to X11::XCB
|
||||
sub set_wm_class {
|
||||
my ($id, $class, $instance) = @_;
|
||||
|
||||
# Add a _NET_WM_STRUT_PARTIAL hint
|
||||
my $atomname = $x->atom(name => 'WM_CLASS');
|
||||
my $atomtype = $x->atom(name => 'STRING');
|
||||
|
||||
$x->change_property(
|
||||
PROP_MODE_REPLACE,
|
||||
$id,
|
||||
$atomname->id,
|
||||
$atomtype->id,
|
||||
8,
|
||||
length($class) + length($instance) + 2,
|
||||
"$instance\x00$class\x00"
|
||||
);
|
||||
}
|
||||
|
||||
sub open_special {
|
||||
my %args = @_;
|
||||
my $wm_class = delete($args{wm_class}) || 'special';
|
||||
|
||||
return open_window(
|
||||
%args,
|
||||
before_map => sub { set_wm_class($_->id, $wm_class, $wm_class) },
|
||||
);
|
||||
}
|
||||
|
||||
my $win = open_window;
|
||||
|
||||
my $scratch = open_special;
|
||||
my $scratch = open_window(wm_class => 'special');
|
||||
cmd '[class="special"] move scratchpad';
|
||||
|
||||
is_num_children($tmp, 1, 'one window on current ws');
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
# Ticket: #909
|
||||
# Bug still in: 4.4-69-g6856b23
|
||||
use i3test i3_autostart => 0;
|
||||
use X11::XCB qw(:all);
|
||||
|
||||
my $config = <<EOT;
|
||||
# i3 config file (v4)
|
||||
|
@ -31,28 +30,10 @@ EOT
|
|||
|
||||
my $pid = launch_with_config($config);
|
||||
|
||||
sub set_wm_class {
|
||||
my ($id, $class, $instance) = @_;
|
||||
|
||||
# Add a _NET_WM_STRUT_PARTIAL hint
|
||||
my $atomname = $x->atom(name => 'WM_CLASS');
|
||||
my $atomtype = $x->atom(name => 'STRING');
|
||||
|
||||
$x->change_property(
|
||||
PROP_MODE_REPLACE,
|
||||
$id,
|
||||
$atomname->id,
|
||||
$atomtype->id,
|
||||
8,
|
||||
length($class) + length($instance) + 2,
|
||||
"$instance\x00$class\x00"
|
||||
);
|
||||
}
|
||||
|
||||
# We use dont_map because i3 will not map the window on the current
|
||||
# workspace. Thus, open_window would time out in wait_for_map (2 seconds).
|
||||
my $window = open_window(
|
||||
before_map => sub { set_wm_class($_->id, '__i3-test-window', '__i3-test-window') },
|
||||
wm_class => '__i3-test-window',
|
||||
dont_map => 1,
|
||||
);
|
||||
$window->map;
|
||||
|
|
|
@ -20,41 +20,11 @@
|
|||
# Ticket: #913
|
||||
# Bug still in: 4.4-97-gf767ac3
|
||||
use i3test;
|
||||
use X11::XCB qw(:all);
|
||||
|
||||
# TODO: move to X11::XCB
|
||||
sub set_wm_class {
|
||||
my ($id, $class, $instance) = @_;
|
||||
|
||||
# Add a _NET_WM_STRUT_PARTIAL hint
|
||||
my $atomname = $x->atom(name => 'WM_CLASS');
|
||||
my $atomtype = $x->atom(name => 'STRING');
|
||||
|
||||
$x->change_property(
|
||||
PROP_MODE_REPLACE,
|
||||
$id,
|
||||
$atomname->id,
|
||||
$atomtype->id,
|
||||
8,
|
||||
length($class) + length($instance) + 2,
|
||||
"$instance\x00$class\x00"
|
||||
);
|
||||
}
|
||||
|
||||
sub open_special {
|
||||
my %args = @_;
|
||||
my $wm_class = delete($args{wm_class}) || 'special';
|
||||
|
||||
return open_window(
|
||||
%args,
|
||||
before_map => sub { set_wm_class($_->id, $wm_class, $wm_class) },
|
||||
);
|
||||
}
|
||||
|
||||
my $tmp = fresh_workspace;
|
||||
|
||||
# Open a new window which we can identify later on based on its WM_CLASS.
|
||||
my $scratch = open_special;
|
||||
my $scratch = open_window(wm_class => 'special');
|
||||
|
||||
my $tmp2 = fresh_workspace;
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
# Ticket: #1027
|
||||
# Bug still in: 4.5.1-90-g6582da9
|
||||
use i3test i3_autostart => 0;
|
||||
use X11::XCB qw(PROP_MODE_REPLACE);
|
||||
|
||||
my $config = <<'EOT';
|
||||
# i3 config file (v4)
|
||||
|
@ -31,28 +30,9 @@ EOT
|
|||
|
||||
my $pid = launch_with_config($config);
|
||||
|
||||
# TODO: move this to X11::XCB::Window
|
||||
sub set_wm_class {
|
||||
my ($id, $class, $instance) = @_;
|
||||
|
||||
# Add a _NET_WM_STRUT_PARTIAL hint
|
||||
my $atomname = $x->atom(name => 'WM_CLASS');
|
||||
my $atomtype = $x->atom(name => 'STRING');
|
||||
|
||||
$x->change_property(
|
||||
PROP_MODE_REPLACE,
|
||||
$id,
|
||||
$atomname->id,
|
||||
$atomtype->id,
|
||||
8,
|
||||
length($class) + length($instance) + 2,
|
||||
"$instance\x00$class\x00"
|
||||
);
|
||||
}
|
||||
|
||||
my $window = open_window(
|
||||
name => 'Borderless window',
|
||||
before_map => sub { set_wm_class($_->id, 'special', 'special') },
|
||||
wm_class => 'special',
|
||||
dont_map => 1,
|
||||
);
|
||||
$window->map;
|
||||
|
|
|
@ -21,37 +21,16 @@
|
|||
# Ticket: #1086
|
||||
# Bug still in: 4.6-62-g7098ef6
|
||||
use i3test i3_autostart => 0;
|
||||
use X11::XCB qw(:all);
|
||||
|
||||
# TODO: move to X11::XCB
|
||||
sub set_wm_class {
|
||||
my ($id, $class, $instance) = @_;
|
||||
|
||||
# Add a _NET_WM_STRUT_PARTIAL hint
|
||||
my $atomname = $x->atom(name => 'WM_CLASS');
|
||||
my $atomtype = $x->atom(name => 'STRING');
|
||||
|
||||
$x->change_property(
|
||||
PROP_MODE_REPLACE,
|
||||
$id,
|
||||
$atomname->id,
|
||||
$atomtype->id,
|
||||
8,
|
||||
length($class) + length($instance) + 2,
|
||||
"$instance\x00$class\x00"
|
||||
);
|
||||
}
|
||||
|
||||
sub open_special {
|
||||
my %args = @_;
|
||||
my $wm_class = delete($args{wm_class}) || 'special';
|
||||
$args{name} //= 'special window';
|
||||
|
||||
# We use dont_map because i3 will not map the window on the current
|
||||
# workspace. Thus, open_window would time out in wait_for_map (2 seconds).
|
||||
my $window = open_window(
|
||||
%args,
|
||||
before_map => sub { set_wm_class($_->id, $wm_class, $wm_class) },
|
||||
wm_class => 'special',
|
||||
dont_map => 1,
|
||||
);
|
||||
$window->add_hint('urgency');
|
||||
|
|
Loading…
Reference in New Issue