Merge pull request #1665 from Airblader/feature-1658

Added criterion 'window_type'
This commit is contained in:
Michael Stapelberg
2015-04-21 08:42:16 +02:00
18 changed files with 301 additions and 51 deletions

View File

@ -287,9 +287,6 @@ exit_gracefully($pid);
# 8: check that the role criterion works properly
##############################################################
# this configuration is broken because "asdf" is not a valid integer
# the for_window should therefore recognize this error and dont add the
# assignment
$config = <<EOT;
# i3 config file (v4)
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
@ -329,9 +326,6 @@ exit_gracefully($pid);
# *after* the window has been mapped
##############################################################
# this configuration is broken because "asdf" is not a valid integer
# the for_window should therefore recognize this error and dont add the
# assignment
$config = <<EOT;
# i3 config file (v4)
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
@ -370,5 +364,77 @@ is($content[0]->{border}, 'none', 'no border (window_role 2)');
exit_gracefully($pid);
##############################################################
# 10: check that the criterion 'window_type' works
##############################################################
# test all window types
my %window_types = (
'normal' => '_NET_WM_WINDOW_TYPE_NORMAL',
'dialog' => '_NET_WM_WINDOW_TYPE_DIALOG',
'utility' => '_NET_WM_WINDOW_TYPE_UTILITY',
'toolbar' => '_NET_WM_WINDOW_TYPE_TOOLBAR',
'splash' => '_NET_WM_WINDOW_TYPE_SPLASH',
'menu' => '_NET_WM_WINDOW_TYPE_MENU',
'dropdown_menu' => '_NET_WM_WINDOW_TYPE_DROPDOWN_MENU',
'popup_menu' => '_NET_WM_WINDOW_TYPE_POPUP_MENU',
'tooltip' => '_NET_WM_WINDOW_TYPE_TOOLTIP'
);
while (my ($window_type, $atom) = each %window_types) {
$config = <<"EOT";
# i3 config file (v4)
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
for_window [window_type="$window_type"] floating enable, mark branded
EOT
$pid = launch_with_config($config);
$tmp = fresh_workspace;
$window = open_window(window_type => $x->atom(name => $atom));
my @nodes = @{get_ws($tmp)->{floating_nodes}};
cmp_ok(@nodes, '==', 1, 'one floating container on this workspace');
is($nodes[0]->{nodes}[0]->{mark}, 'branded', "mark set (window_type = $atom)");
exit_gracefully($pid);
}
##############################################################
# 11: check that the criterion 'window_type' works if the
# _NET_WM_WINDOW_TYPE is changed after managing.
##############################################################
while (my ($window_type, $atom) = each %window_types) {
$config = <<"EOT";
# i3 config file (v4)
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
for_window [window_type="$window_type"] floating enable, mark branded
EOT
$pid = launch_with_config($config);
$tmp = fresh_workspace;
$window = open_window();
my $atomname = $x->atom(name => '_NET_WM_WINDOW_TYPE');
my $atomtype = $x->atom(name => 'ATOM');
$x->change_property(PROP_MODE_REPLACE, $window->id, $atomname->id, $atomtype->id,
32, 1, pack('L1', $x->atom(name => $atom)->id));
$x->flush;
sync_with_i3;
my @nodes = @{get_ws($tmp)->{floating_nodes}};
cmp_ok(@nodes, '==', 1, 'one floating container on this workspace');
is($nodes[0]->{nodes}[0]->{mark}, 'branded', "mark set (window_type = $atom)");
exit_gracefully($pid);
}
##############################################################
done_testing;

View File

@ -18,20 +18,61 @@
# Bug still in: 4.8-16-g6888a1f
use i3test;
my $ws = fresh_workspace;
my ($ws, $win1, $win2, $win3, $ws_con);
my $win1 = open_window;
my $win2 = open_window;
my $win3 = open_window;
###############################################################################
# Tets moving with 'id' criterion.
###############################################################################
$ws = fresh_workspace;
$win1 = open_window;
$win2 = open_window;
$win3 = open_window;
# move win1 from the left to the right
cmd '[id="' . $win1->{id} . '"] move right';
# now they should be switched, with win2 still being focused
my $ws_con = get_ws($ws);
$ws_con = get_ws($ws);
# win2 should be on the left
is($ws_con->{nodes}[0]->{window}, $win2->{id}, 'the `move [direction]` command should work with criteria');
is($x->input_focus, $win3->{id}, 'it should not disturb focus');
###############################################################################
# Tets moving with 'window_type' criterion.
###############################################################################
# test all window types
my %window_types = (
'normal' => '_NET_WM_WINDOW_TYPE_NORMAL',
'dialog' => '_NET_WM_WINDOW_TYPE_DIALOG',
'utility' => '_NET_WM_WINDOW_TYPE_UTILITY',
'toolbar' => '_NET_WM_WINDOW_TYPE_TOOLBAR',
'splash' => '_NET_WM_WINDOW_TYPE_SPLASH',
'menu' => '_NET_WM_WINDOW_TYPE_MENU',
'dropdown_menu' => '_NET_WM_WINDOW_TYPE_DROPDOWN_MENU',
'popup_menu' => '_NET_WM_WINDOW_TYPE_POPUP_MENU',
'tooltip' => '_NET_WM_WINDOW_TYPE_TOOLTIP'
);
while (my ($window_type, $atom) = each %window_types) {
$ws = fresh_workspace;
$win1 = open_window(window_type => $x->atom(name => $atom));
$win2 = open_window;
$win3 = open_window;
cmd '[window_type="' . $window_type . '"] move right';
$ws_con = get_ws($ws);
is($ws_con->{nodes}[0]->{window}, $win2->{id}, 'the `move [direction]` command should work with window_type = ' . $window_type);
is($x->input_focus, $win3->{id}, 'it should not disturb focus');
}
###############################################################################
done_testing;